Gary-Hobson commented on code in PR #7554: URL: https://github.com/apache/incubator-nuttx/pull/7554#discussion_r1029160250
########## drivers/segger/serial_rtt.c: ########## @@ -0,0 +1,550 @@ +/**************************************************************************** + * drivers/segger/serial_rtt.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 <debug.h> +#include <errno.h> +#include <fcntl.h> +#include <stdint.h> + +#include <nuttx/config.h> +#include <nuttx/fs/ioctl.h> +#include <nuttx/kmalloc.h> +#include <nuttx/kthread.h> +#include <nuttx/serial/serial.h> + +#include <sys/types.h> + +#include <SEGGER_RTT.h> + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/**************************************************************************** + * Private Types + ****************************************************************************/ + +struct rtt_serial_dev_s +{ + int channel; + uint32_t rxsize; + uint32_t txsize; + char *devname; Review Comment: done ~ ########## drivers/segger/serial_rtt.c: ########## @@ -0,0 +1,550 @@ +/**************************************************************************** + * drivers/segger/serial_rtt.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 <debug.h> +#include <errno.h> +#include <fcntl.h> +#include <stdint.h> + +#include <nuttx/config.h> +#include <nuttx/fs/ioctl.h> +#include <nuttx/kmalloc.h> +#include <nuttx/kthread.h> +#include <nuttx/serial/serial.h> + +#include <sys/types.h> + +#include <SEGGER_RTT.h> + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/**************************************************************************** + * Private Types + ****************************************************************************/ + +struct rtt_serial_dev_s +{ + int channel; + uint32_t rxsize; + uint32_t txsize; + char *devname; +}; + +/**************************************************************************** + * Private Function Prototypes + ****************************************************************************/ + +#ifdef CONFIG_RTT_SERIAL_CONSOLE +static int rtt_setup(FAR struct uart_dev_s *dev); +static void rtt_shutdown(FAR struct uart_dev_s *dev); +static int rtt_attach(FAR struct uart_dev_s *dev); +static void rtt_detach(FAR struct uart_dev_s *dev); +static int rtt_ioctl(FAR struct file *filep, int cmd, unsigned long arg); +static int rtt_receive(FAR struct uart_dev_s *dev, unsigned int *status); +static void rtt_rxint(FAR struct uart_dev_s *dev, bool enable); +static bool rtt_rxavailable(FAR struct uart_dev_s *dev); +static void rtt_send(FAR struct uart_dev_s *dev, int ch); +static void rtt_txint(FAR struct uart_dev_s *dev, bool enable); +static bool rtt_txready(FAR struct uart_dev_s *dev); +static bool rtt_txempty(FAR struct uart_dev_s *dev); +static void rtt_dmasend(FAR struct uart_dev_s *dev); +static void rtt_dmareceive(FAR struct uart_dev_s *dev); +static void rtt_dmarxfree(FAR struct uart_dev_s *dev); +static void rtt_dmatxavail(FAR struct uart_dev_s *dev); +#endif + +#ifdef CONFIG_RTT_SERIAL +static int rtt_serial_open(FAR struct file *filep); +static int rtt_serial_close(FAR struct file *filep); +static ssize_t rtt_serial_read(FAR struct file *filep, FAR char *buffer, + size_t buflen); +static ssize_t rtt_serial_write(FAR struct file *filep, + FAR const char *buffer, size_t buflen); +static int rtt_serial_ioctl(FAR struct file *filep, int cmd, + unsigned long arg); +#endif + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +static struct rtt_serial_dev_s g_serial_priv[] = +{ +#if defined(CONFIG_RTT_SERIAL0) || defined(CONFIG_RTT_SERIAL_CONSOLE) + { + .channel = 0, + .devname = "/dev/rtt0", + }, +#endif +#if defined(CONFIG_RTT_SERIAL1) + { + .channel = 1, + .devname = "/dev/rtt1", + .rxsize = CONFIG_RTT_SERIAL1_RXBUF_SIZE, + .txsize = CONFIG_RTT_SERIAL1_TXBUF_SIZE + }, +#endif +#if defined(CONFIG_RTT_SERIAL2) + { + .channel = 2, + .devname = "/dev/rtt2", + .rxsize = CONFIG_RTT_SERIAL2_RXBUF_SIZE, + .txsize = CONFIG_RTT_SERIAL2_TXBUF_SIZE + }, +#endif Review Comment: done~ -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@nuttx.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org