linguini1 commented on code in PR #19478:
URL: https://github.com/apache/nuttx/pull/19478#discussion_r3610494535


##########
boards/arm/rk3506/luckfox-lyra-amp/src/rk3506_bringup.c:
##########
@@ -0,0 +1,213 @@
+/****************************************************************************
+ * boards/arm/rk3506/luckfox-lyra-amp/src/rk3506_bringup.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 <nuttx/config.h>
+
+#include <sys/types.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <fcntl.h>
+#include <syslog.h>
+#include <unistd.h>
+
+#include <nuttx/arch.h>
+#include <nuttx/fs/fs.h>
+#include <nuttx/kthread.h>
+#include <nuttx/serial/serial.h>
+
+#ifdef CONFIG_SENSORS_FAKESENSOR
+#  include <nuttx/uorb.h>
+#  include <nuttx/sensors/fakesensor.h>
+#endif
+
+#include "chip.h"
+#include "rk3506.h"
+
+/* Console uart_dev_t accessor exported by drivers/serial/uart_16550.c. */
+
+FAR uart_dev_t *u16550_consoledev(void);
+
+/****************************************************************************
+ * Private Functions
+ ****************************************************************************/
+
+/* Poll-driven console RX worker.
+ *
+ * UART4 RX is wired to GIC SPI IRQ70. On this AMP SoC the GIC distributor is
+ * shared with Linux, so IRQ70 cannot be delivered to CPU2 reliably (Linux
+ * owns/reconfigures the distributor and the SPI enable/target for IRQ70 does
+ * not stick). Polling the UART bypasses the GIC entirely and is reliable;
+ * TX and the per-CPU PPI timer are unaffected.
+ */
+
+static int rk3506_rxpoll(int argc, char *argv[])
+{
+  FAR uart_dev_t *con = u16550_consoledev();
+
+  /* Disable IRQ70 so the (unreliable) RX interrupt never races this poller
+   * for the same RBR byte. Give NSH a moment to open the console first.
+   */
+
+  usleep(200000);
+  up_disable_irq(70);
+
+  /* Poll the Line Status Register; when data is ready, push it up through
+   * the normal serial upper-half via uart_recvchars() - exactly what the RX
+   * ISR would have done.
+   *
+   *   LSR @ 0xff0e0000 + (5 << 2), Data-Ready = bit0
+   */
+
+  for (; ; )
+    {
+      uint32_t lsr = *(volatile uint32_t *)(0xff0e0000 + (5 << 2));
+
+      if (lsr & 0x01)
+        {
+          uart_recvchars(con);
+        }
+      else
+        {
+          usleep(2000);
+        }
+    }
+
+  return 0;
+}
+
+#ifdef CONFIG_SENSORS_FAKESENSOR
+/* Register a demo accelerometer backed by a small CSV that fakesensor
+ * replays in a loop. This brings up a live sensor node at
+ * /dev/uorb/sensor_accel0 with no real hardware, so the full uORB pipeline
+ * (sensor framework -> uORB -> read/poll) can be exercised on the board:
+ *
+ *   uorb_listener sensor_accel        # watch the live stream
+ *   cat /dev/uorb/sensor_accel0       # raw binary samples
+ *
+ * The CSV format is fakesensor's own: first line "interval:<ms>", second
+ * line the header, then rows of samples. EOF wraps back to the top, so a
+ * handful of rows produces an endless stream.
+ */
+
+static void rk3506_fakesensor_setup(void)
+{
+  static const char csv[] =
+    "interval:100\n"   /* 10 Hz */
+    "x,y,z\n"
+    "0.10,0.00,9.81\n"
+    "0.20,0.05,9.79\n"
+    "0.05,-0.05,9.82\n"
+    "-0.10,0.10,9.80\n";

Review Comment:
   This is unrelated to this PR, but I think you were the author of 
`uorb_generator`. Is this CSV format the same format that's expected by 
`uorb_generator -f`? Because it seems to also look for a topic in the first 
line.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to