From 901278a4bab1ef503de1569096ff01f95b25c3d3 Mon Sep 17 00:00:00 2001 From: Tiago Medicci Date: Mon, 20 Apr 2026 17:04:51 -0300 Subject: [PATCH] examples: Remove deprecated `rmtchar` example application The upper-half RMT driver is no longer available on NuttX. Instead, Espressif's RMT peripheral was bound directly to the lirc driver. For testing purposes, use the `irtest` application. NuttX OS PR https://github.com/apache/nuttx/pull/18654 removed the upper-half driver interface used by this application, so removing it does not break any existing feature on NuttX. Signed-off-by: Tiago Medicci --- examples/rmtchar/CMakeLists.txt | 40 --- examples/rmtchar/Kconfig | 68 ----- examples/rmtchar/Make.defs | 25 -- examples/rmtchar/Makefile | 43 --- examples/rmtchar/rmtchar.h | 129 --------- examples/rmtchar/rmtchar_common.c | 93 ------- examples/rmtchar/rmtchar_main.c | 362 ------------------------- examples/rmtchar/rmtchar_receiver.c | 140 ---------- examples/rmtchar/rmtchar_transmitter.c | 158 ----------- 9 files changed, 1058 deletions(-) delete mode 100644 examples/rmtchar/CMakeLists.txt delete mode 100644 examples/rmtchar/Kconfig delete mode 100644 examples/rmtchar/Make.defs delete mode 100644 examples/rmtchar/Makefile delete mode 100644 examples/rmtchar/rmtchar.h delete mode 100644 examples/rmtchar/rmtchar_common.c delete mode 100644 examples/rmtchar/rmtchar_main.c delete mode 100644 examples/rmtchar/rmtchar_receiver.c delete mode 100644 examples/rmtchar/rmtchar_transmitter.c diff --git a/examples/rmtchar/CMakeLists.txt b/examples/rmtchar/CMakeLists.txt deleted file mode 100644 index a01ebe080..000000000 --- a/examples/rmtchar/CMakeLists.txt +++ /dev/null @@ -1,40 +0,0 @@ -# ############################################################################## -# apps/examples/rmtchar/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. -# -# ############################################################################## - -if(CONFIG_EXAMPLES_RMTCHAR) - nuttx_add_application( - NAME - rmtchar - STACKSIZE - ${CONFIG_DEFAULT_TASK_STACKSIZE} - MODULE - ${CONFIG_EXAMPLES_RMTCHAR} - SRCS - rmtchar_main.c) - target_sources(apps PRIVATE rmtchar_common.c) - if(CONFIG_EXAMPLES_RMTCHAR_TX) - target_sources(apps PRIVATE rmtchar_transmitter.c) - endif() - if(CONFIG_EXAMPLES_RMTCHAR_RX) - target_sources(apps PRIVATE rmtchar_receiver.c) - endif() -endif() diff --git a/examples/rmtchar/Kconfig b/examples/rmtchar/Kconfig deleted file mode 100644 index e88da638a..000000000 --- a/examples/rmtchar/Kconfig +++ /dev/null @@ -1,68 +0,0 @@ -# -# For a description of the syntax of this configuration file, -# see the file kconfig-language.txt in the NuttX tools repository. -# - -config EXAMPLES_RMTCHAR - tristate "RMT character driver test" - default n - depends on RMT - ---help--- - Enable the RMT character driver test - -if EXAMPLES_RMTCHAR - -config EXAMPLES_RMTCHAR_TX - bool "Use RMT transmitter" - default n - ---help--- - This should be set if the RMT device supports a transmitter. - -if EXAMPLES_RMTCHAR_TX - -config EXAMPLES_RMTCHAR_TX_DEVPATH - string "RMT transmitter character device path" - default "/dev/rmt0" - ---help--- - The default path to the RMT transmitter character device. - Default: /dev/rmt0 - -config EXAMPLES_RMTCHAR_TXSTACKSIZE - int "Transmitter thread stack size" - default DEFAULT_TASK_STACKSIZE - ---help--- - This is the stack size to use when starting the transmitter thread. - -endif # EXAMPLES_RMTCHAR_TX - -config EXAMPLES_RMTCHAR_RX - bool "Use RMT receiver" - default n - ---help--- - This should be set if the RMT device supports a receiver. - -if EXAMPLES_RMTCHAR_RX - -config EXAMPLES_RMTCHAR_RX_DEVPATH - string "RMT receiver character device path" - default "/dev/rmt1" - ---help--- - The default path to the RMT receiver character device. - Default: /dev/rmt1 - -config EXAMPLES_RMTCHAR_RXSTACKSIZE - int "Receiver thread stack size" - default DEFAULT_TASK_STACKSIZE - ---help--- - This is the stack size to use when starting the receiver thread. - -endif # EXAMPLES_RMTCHAR_RX - -config EXAMPLES_RMTCHAR_ITEMS - int "Number of words to transmit or receive" - default 64 - ---help--- - This is the total amount of words to be transmitted or - received by the RMT RX device. - -endif diff --git a/examples/rmtchar/Make.defs b/examples/rmtchar/Make.defs deleted file mode 100644 index 0b14b2487..000000000 --- a/examples/rmtchar/Make.defs +++ /dev/null @@ -1,25 +0,0 @@ -############################################################################ -# apps/examples/rmtchar/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. -# -############################################################################ - -ifneq ($(CONFIG_EXAMPLES_RMTCHAR),) -CONFIGURED_APPS += $(APPDIR)/examples/rmtchar -endif diff --git a/examples/rmtchar/Makefile b/examples/rmtchar/Makefile deleted file mode 100644 index 2c6d454dd..000000000 --- a/examples/rmtchar/Makefile +++ /dev/null @@ -1,43 +0,0 @@ -############################################################################ -# apps/examples/rmtchar/Makefile -# -# 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. -# -############################################################################ - -include $(APPDIR)/Make.defs - -# rmt character driver test - -ifeq ($(CONFIG_EXAMPLES_RMTCHAR_TX),y) -CSRCS += rmtchar_transmitter.c -endif -ifeq ($(CONFIG_EXAMPLES_RMTCHAR_RX),y) -CSRCS += rmtchar_receiver.c -endif -CSRCS += rmtchar_common.c -MAINSRC = rmtchar_main.c - -# Touchscreen built-in application info - -PROGNAME = rmtchar -PRIORITY = SCHED_PRIORITY_DEFAULT -STACKSIZE = $(CONFIG_DEFAULT_TASK_STACKSIZE) -MODULE = $(CONFIG_EXAMPLES_RMTCHAR) - -include $(APPDIR)/Application.mk diff --git a/examples/rmtchar/rmtchar.h b/examples/rmtchar/rmtchar.h deleted file mode 100644 index 832b80a4c..000000000 --- a/examples/rmtchar/rmtchar.h +++ /dev/null @@ -1,129 +0,0 @@ -/**************************************************************************** - * apps/examples/rmtchar/rmtchar.h - * - * 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. - * - ****************************************************************************/ - -#ifndef __APPS_EXAMPLES_RMTCHAR_RMTCHAR_H -#define __APPS_EXAMPLES_RMTCHAR_RMTCHAR_H - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include -#include - -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/* Configuration */ - -#ifndef CONFIG_EXAMPLES_RMTCHAR_TX_DEVPATH -# define CONFIG_EXAMPLES_RMTCHAR_TX_DEVPATH "/dev/rmt0" -#endif - -#ifndef CONFIG_EXAMPLES_RMTCHAR_RX_DEVPATH -# define CONFIG_EXAMPLES_RMTCHAR_RX_DEVPATH "/dev/rmt1" -#endif - -/**************************************************************************** - * Public Types - ****************************************************************************/ - -struct rmtchar_state_s -{ - bool initialized; - int rmtchar_items; -#ifdef CONFIG_EXAMPLES_RMTCHAR_TX - FAR char *txdevpath; -#endif -#ifdef CONFIG_EXAMPLES_RMTCHAR_RX - FAR char *rxdevpath; -#endif -}; - -struct rmt_item32_s -{ - union - { - struct - { - uint32_t duration0 : 15; /* Duration of level0 */ - uint32_t level0 : 1; /* Level of the first part */ - uint32_t duration1 : 15; /* Duration of level1 */ - uint32_t level1 : 1; /* Level of the second part */ - }; - uint32_t val; /* Equivalent unsigned value for the RMT item */ - }; -}; - -/**************************************************************************** - * Public Data - ****************************************************************************/ - -/**************************************************************************** - * Public Function Prototypes - ****************************************************************************/ - -/**************************************************************************** - * Name: rmtchar_transmitter() - * - * Description: - * This is the entry point for the transmitter thread. - * - ****************************************************************************/ - -#ifdef CONFIG_EXAMPLES_RMTCHAR_TX -pthread_addr_t rmtchar_transmitter(pthread_addr_t arg); -#endif - -/**************************************************************************** - * Name: rmtchar_receiver() - * - * Description: - * This is the entry point for the receiver thread. - * - ****************************************************************************/ - -#ifdef CONFIG_EXAMPLES_RMTCHAR_RX -pthread_addr_t rmtchar_receiver(pthread_addr_t arg); -#endif - -/**************************************************************************** - * Name: print_items - * - * Description: - * This function prints the level and duration of RMT items stored in a - * buffer. It iterates over the buffer, printing the level and duration of - * each item in a formatted manner. - * - * Input Parameters: - * buf - Pointer to the buffer containing the RMT items. - * len - The number of RMT items in the buffer. - * - * Returned Value: - * None. - * - ****************************************************************************/ - -void print_items(struct rmt_item32_s *buf, int len); - -#endif /* __APPS_EXAMPLES_RMTCHAR_RMTCHAR_H */ diff --git a/examples/rmtchar/rmtchar_common.c b/examples/rmtchar/rmtchar_common.c deleted file mode 100644 index 098e5363a..000000000 --- a/examples/rmtchar/rmtchar_common.c +++ /dev/null @@ -1,93 +0,0 @@ -/**************************************************************************** - * apps/examples/rmtchar/rmtchar_common.c - * - * 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. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include - -#include -#include -#include -#include -#include -#include -#include - -#include "rmtchar.h" - -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/**************************************************************************** - * Private Types - ****************************************************************************/ - -/**************************************************************************** - * Private Function Prototypes - ****************************************************************************/ - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -/**************************************************************************** - * Public Data - ****************************************************************************/ - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: print_items - * - * Description: - * This function prints the level and duration of RMT items stored in a - * buffer. It iterates over the buffer, printing the level and duration of - * each item in a formatted manner. - * - * Input Parameters: - * buf - Pointer to the buffer containing the RMT items. - * len - The number of RMT items in the buffer. - * - * Returned Value: - * None. - * - ****************************************************************************/ - -void print_items(struct rmt_item32_s *buf, int len) -{ - int i; - - for (i = 0; i < len; i++, buf++) - { - printf("\t[%d]:\tL %d\tD %d\t", i, buf->level0, buf->duration0); - printf("L %d\t D %d\n", buf->level1, buf->duration1); - } -} diff --git a/examples/rmtchar/rmtchar_main.c b/examples/rmtchar/rmtchar_main.c deleted file mode 100644 index 63a8ced85..000000000 --- a/examples/rmtchar/rmtchar_main.c +++ /dev/null @@ -1,362 +0,0 @@ -/**************************************************************************** - * apps/examples/rmtchar/rmtchar_main.c - * - * 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. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include - -#include - -#include -#include -#include -#include -#include -#include - -#include "rmtchar.h" - -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -#if !defined(CONFIG_EXAMPLES_RMTCHAR_RX) && \ - !defined(CONFIG_EXAMPLES_RMTCHAR_TX) -# error "At least one of CONFIG_EXAMPLES_RMTCHAR_RX or \ - CONFIG_EXAMPLES_RMTCHAR_TX must be defined" -#endif - -/**************************************************************************** - * Private Types - ****************************************************************************/ - -/**************************************************************************** - * Private Function Prototypes - ****************************************************************************/ - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -static struct rmtchar_state_s g_rmtchar; - -/**************************************************************************** - * Public Data - ****************************************************************************/ - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: rmtchar_devpath - ****************************************************************************/ - -static void rmtchar_devpath(FAR struct rmtchar_state_s *rmtchar, - FAR const char *devpath, - bool is_tx) -{ - /* Get rid of any old device path */ - - if (is_tx) - { - if (rmtchar->txdevpath) - { - free(rmtchar->txdevpath); - } - - /* Then set-up the new device path by copying the string */ - - rmtchar->txdevpath = strdup(devpath); - } - else - { - if (rmtchar->rxdevpath) - { - free(rmtchar->rxdevpath); - } - - /* Then set-up the new device path by copying the string */ - - rmtchar->rxdevpath = strdup(devpath); - } -} - -/**************************************************************************** - * Name: rmtchar_help - ****************************************************************************/ - -static void rmtchar_help(FAR struct rmtchar_state_s *rmtchar) -{ - printf("Usage: rmtchar [OPTIONS]\n"); - printf("\nArguments are \"sticky\".\n"); - printf("For example, once the RMT character device is\n"); - printf("specified, that device will be reused until it is changed.\n"); - printf("\n\"sticky\" OPTIONS include:\n"); - printf(" [-i items] selects the number of words (items) to be transmitted" - " or received by the RMT character device. " - "Default: %d Current: %d\n", - CONFIG_EXAMPLES_RMTCHAR_ITEMS, - rmtchar->rmtchar_items ? rmtchar->rmtchar_items : - CONFIG_EXAMPLES_RMTCHAR_ITEMS); -#ifdef CONFIG_EXAMPLES_RMTCHAR_TX - printf(" [-t devpath] selects the RMT transmitter character device path. " - "Default: %s Current: %s\n", - CONFIG_EXAMPLES_RMTCHAR_TX_DEVPATH, - rmtchar->txdevpath ? rmtchar->txdevpath : "NONE"); -#endif -#ifdef CONFIG_EXAMPLES_RMTCHAR_RX - printf(" [-r devpath] selects the RMT receiver character device path. " - "Default: %s Current: %s\n", - CONFIG_EXAMPLES_RMTCHAR_RX_DEVPATH, - rmtchar->rxdevpath ? rmtchar->rxdevpath : "NONE"); -#endif - printf(" [-h] shows this message and exits\n"); -} - -/**************************************************************************** - * Name: arg_string - ****************************************************************************/ - -static int arg_string(FAR char **arg, FAR char **value) -{ - FAR char *ptr = *arg; - - if (ptr[2] == '\0') - { - *value = arg[1]; - return 2; - } - else - { - *value = &ptr[2]; - return 1; - } -} - -/**************************************************************************** - * Name: arg_decimal - ****************************************************************************/ - -static int arg_decimal(FAR char **arg, FAR int *value) -{ - FAR char *string; - int ret; - - ret = arg_string(arg, &string); - *value = strtol(string, NULL, 10); - return ret; -} - -/**************************************************************************** - * Name: parse_args - ****************************************************************************/ - -static void parse_args(FAR struct rmtchar_state_s *rmtchar, - int argc, - FAR char **argv) -{ - FAR char *ptr; - FAR char *str; - int value; - int index; - int nargs; - - for (index = 1; index < argc; ) - { - ptr = argv[index]; - if (ptr[0] != '-') - { - printf("Invalid options format: %s\n", ptr); - exit(0); - } - - switch (ptr[1]) - { - case 'i': - nargs = arg_decimal(&argv[index], &value); - if (value < 0) - { - printf("Count must be non-negative: %d\n", value); - exit(1); - } - - rmtchar->rmtchar_items = value; - index += nargs; - break; -#ifdef CONFIG_EXAMPLES_RMTCHAR_TX - case 't': - nargs = arg_string(&argv[index], &str); - rmtchar_devpath(rmtchar, str, true); - index += nargs; - break; -#endif - -#ifdef CONFIG_EXAMPLES_RMTCHAR_RX - case 'r': - nargs = arg_string(&argv[index], &str); - rmtchar_devpath(rmtchar, str, false); - index += nargs; - break; -#endif - case 'h': - rmtchar_help(rmtchar); - exit(0); - - default: - printf("Unsupported option: %s\n", ptr); - rmtchar_help(rmtchar); - exit(1); - } - } -} - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: rmtchar_main - ****************************************************************************/ - -int main(int argc, FAR char *argv[]) -{ - pthread_attr_t attr; - pthread_addr_t result; -#ifdef CONFIG_EXAMPLES_RMTCHAR_TX - pthread_t transmitter; -#endif -#ifdef CONFIG_EXAMPLES_RMTCHAR_RX - pthread_t receiver; -#endif -#if defined(CONFIG_EXAMPLES_RMTCHAR_RX) && defined(CONFIG_EXAMPLES_RMTCHAR_TX) - struct sched_param param; -#endif - int ret; - - UNUSED(ret); - - /* Check if we have initialized */ - - if (!g_rmtchar.initialized) - { - /* Set the default values */ - - g_rmtchar.rmtchar_items = CONFIG_EXAMPLES_RMTCHAR_ITEMS; - -#ifdef CONFIG_EXAMPLES_RMTCHAR_TX - rmtchar_devpath(&g_rmtchar, CONFIG_EXAMPLES_RMTCHAR_TX_DEVPATH, true); -#endif -#ifdef CONFIG_EXAMPLES_RMTCHAR_RX - rmtchar_devpath(&g_rmtchar, CONFIG_EXAMPLES_RMTCHAR_RX_DEVPATH, false); -#endif - - g_rmtchar.initialized = true; - } - - /* Parse the command line */ - - parse_args(&g_rmtchar, argc, argv); - -#ifdef CONFIG_EXAMPLES_RMTCHAR_RX - /* Start the receiver thread */ - - printf("rmtchar_main: Start receiver thread\n"); - pthread_attr_init(&attr); - -#ifdef CONFIG_EXAMPLES_RMTCHAR_TX - /* Bump the receiver priority from the default so that it will be above - * the priority of transmitter. This is important if a loopback test is - * being performed. - */ - - pthread_attr_getschedparam(&attr, ¶m); - param.sched_priority++; - pthread_attr_setschedparam(&attr, ¶m); -#endif - - /* Set the receiver stack size */ - - pthread_attr_setstacksize(&attr, CONFIG_EXAMPLES_RMTCHAR_RXSTACKSIZE); - - /* Start the receiver */ - - ret = pthread_create(&receiver, &attr, rmtchar_receiver, &g_rmtchar); - if (ret != OK) - { - printf("rmtchar_main: ERROR: failed to Start receiver thread: %d\n", - ret); - return EXIT_FAILURE; - } - - pthread_setname_np(receiver, "receiver"); -#endif - -#ifdef CONFIG_EXAMPLES_RMTCHAR_TX - /* Start the transmitter thread */ - - printf("rmtchar_main: Start transmitter thread\n"); - pthread_attr_init(&attr); - - /* Set the transmitter stack size */ - - pthread_attr_setstacksize(&attr, CONFIG_EXAMPLES_RMTCHAR_TXSTACKSIZE); - - /* Start the transmitter */ - - ret = pthread_create(&transmitter, &attr, rmtchar_transmitter, &g_rmtchar); - if (ret != OK) - { - printf("rmtchar_main: ERROR: failed to Start transmitter thread: %d\n", - ret); -#ifdef CONFIG_EXAMPLES_RMTCHAR_RX - printf("rmtchar_main: Waiting for the receiver thread\n"); - pthread_join(receiver, &result); -#endif - return EXIT_FAILURE; - } - - pthread_setname_np(transmitter, "transmitter"); -#endif - -#ifdef CONFIG_EXAMPLES_RMTCHAR_TX - printf("rmtchar_main: Waiting for the transmitter thread\n"); - ret = pthread_join(transmitter, &result); - if (ret != OK) - { - printf("rmtchar_main: ERROR: pthread_join failed: %d\n", ret); - } -#endif - -#ifdef CONFIG_EXAMPLES_RMTCHAR_RX - printf("rmtchar_main: Waiting for the receiver thread\n"); - ret = pthread_join(receiver, &result); - if (ret != OK) - { - printf("rmtchar_main: ERROR: pthread_join failed: %d\n", ret); - } -#endif - - return EXIT_SUCCESS; -} diff --git a/examples/rmtchar/rmtchar_receiver.c b/examples/rmtchar/rmtchar_receiver.c deleted file mode 100644 index 2e1b20e36..000000000 --- a/examples/rmtchar/rmtchar_receiver.c +++ /dev/null @@ -1,140 +0,0 @@ -/**************************************************************************** - * apps/examples/rmtchar/rmtchar_receiver.c - * - * 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. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include - -#include -#include -#include -#include -#include -#include -#include - -#include "rmtchar.h" - -#ifdef CONFIG_EXAMPLES_RMTCHAR_RX - -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/**************************************************************************** - * Private Types - ****************************************************************************/ - -/**************************************************************************** - * Private Function Prototypes - ****************************************************************************/ - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -/**************************************************************************** - * Public Data - ****************************************************************************/ - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: rmtchar_receiver() - * - * Description: - * This is the entry point for the receiver thread. - * - ****************************************************************************/ - -pthread_addr_t rmtchar_receiver(pthread_addr_t arg) -{ - FAR struct rmtchar_state_s *rmtchar = (FAR struct rmtchar_state_s *)arg; - struct rmt_item32_s buf[rmtchar->rmtchar_items]; - int nread; - int fd; - - /* Open the RMT character device */ - - fd = open(rmtchar->rxdevpath, O_RDONLY); - if (fd < 0) - { - int errcode = errno; - printf("rmtchar_receiver: ERROR: failed to open %s: %d\n", - rmtchar->rxdevpath, errcode); - pthread_exit(NULL); - } - - /* Flush any output before reading */ - - fflush(stdout); - - /* Read the buffer to the RMT character driver */ - - nread = read(fd, (char *)buf, rmtchar->rmtchar_items * - sizeof(struct rmt_item32_s)); - if (nread < 0) - { - int errcode = errno; - if (errcode != EINTR) - { - printf("rmtchar_receiver: ERROR: read failed: %d\n", - errcode); - close(fd); - pthread_exit(NULL); - } - } - else - { - if (nread != (rmtchar->rmtchar_items * sizeof(struct rmt_item32_s))) - { - printf("rmtchar_receiver: ERROR: partial read: %d\n", - nread); - printf("rmtchar_receiver: Received buffer:\n"); - print_items(buf, nread / sizeof(struct rmt_item32_s)); - close(fd); - pthread_exit(NULL); - } - else - { - printf("rmtchar_receiver: Received buffer:\n"); - print_items(buf, nread / sizeof(struct rmt_item32_s)); - } - } - - /* Make sure that the transmitter thread has a chance to run */ - - pthread_yield(); - - close(fd); - return NULL; -} - -#endif /* CONFIG_EXAMPLES_RMTCHAR_RX */ diff --git a/examples/rmtchar/rmtchar_transmitter.c b/examples/rmtchar/rmtchar_transmitter.c deleted file mode 100644 index 75fc0103b..000000000 --- a/examples/rmtchar/rmtchar_transmitter.c +++ /dev/null @@ -1,158 +0,0 @@ -/**************************************************************************** - * apps/examples/rmtchar/rmtchar_transmitter.c - * - * 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. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include - -#include -#include -#include -#include -#include -#include -#include - -#include - -#include "rmtchar.h" - -#ifdef CONFIG_EXAMPLES_RMTCHAR_TX - -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/**************************************************************************** - * Private Types - ****************************************************************************/ - -/**************************************************************************** - * Private Function Prototypes - ****************************************************************************/ - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -/**************************************************************************** - * Public Data - ****************************************************************************/ - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: rmtchar_transmitter() - * - * Description: - * This is the entry point for the transmitter thread. - * - ****************************************************************************/ - -pthread_addr_t rmtchar_transmitter(pthread_addr_t arg) -{ - FAR struct rmtchar_state_s *rmtchar = (FAR struct rmtchar_state_s *)arg; - struct rmt_item32_s buf[rmtchar->rmtchar_items]; - int duration = 1000; - int nwritten; - int fd; - int i; - - /* Open the RMT character device */ - - fd = open(rmtchar->txdevpath, O_WRONLY); - if (fd < 0) - { - int errcode = errno; - printf("rmtchar_transmitter: ERROR: failed to open %s: %d\n", - rmtchar->txdevpath, errcode); - pthread_exit(NULL); - } - - /* Fill the transmitter buffer with known items */ - - for (i = 0; i < rmtchar->rmtchar_items; i++) - { - buf[i].level0 = 1; - buf[i].duration0 = duration; - buf[i].level1 = 0; - buf[i].duration1 = duration; - - duration += 10; - } - - /* Flush any output before writing */ - - fflush(stdout); - - /* Print the buffer to be sent */ - - print_items(buf, rmtchar->rmtchar_items); - - /* Then send the buffer */ - - /* Write the buffer to the RMT character driver */ - - nwritten = write(fd, (char *)buf, rmtchar->rmtchar_items * - sizeof(struct rmt_item32_s)); - if (nwritten < 0) - { - int errcode = errno; - if (errcode != EINTR) - { - printf("rmtchar_transmitter: ERROR: write failed: %d\n", - errcode); - close(fd); - pthread_exit(NULL); - } - } - else if (nwritten != (rmtchar->rmtchar_items * - sizeof(struct rmt_item32_s))) - { - printf("rmtchar_transmitter: ERROR: partial write: %d\n", - nwritten); - close(fd); - pthread_exit(NULL); - } - else - { - printf("rmtchar_transmitter: Send buffer with %d bytes\n", - rmtchar->rmtchar_items * sizeof(struct rmt_item32_s)); - } - - /* Make sure that the receiver thread has a chance to run */ - - pthread_yield(); - - close(fd); - return NULL; -} - -#endif /* CONFIG_EXAMPLES_RMTCHAR_TX */