fdcavalcanti commented on code in PR #16623:
URL: https://github.com/apache/nuttx/pull/16623#discussion_r2166640105


##########
drivers/net/ncv7410.c:
##########
@@ -0,0 +1,1703 @@
+/****************************************************************************
+ * drivers/net/ncv7410.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>
+
+#if defined(CONFIG_NET) && defined(CONFIG_NCV7410)
+
+#include <stdint.h>
+#include <stdbool.h>
+#include <string.h>
+#include <assert.h>
+#include <debug.h>
+#include <errno.h>
+
+#include <nuttx/spi/spi.h>
+#include <sys/endian.h>
+
+#include <nuttx/irq.h>
+#include <nuttx/kmalloc.h>
+#include <nuttx/wqueue.h>
+#include <nuttx/signal.h>
+#include <nuttx/mutex.h>
+#include <nuttx/net/ncv7410.h>
+#include <nuttx/net/netdev_lowerhalf.h>
+
+#include "ncv7410.h"
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+#define NCVWORK LPWORK
+
+#define NCV_RESET_TRIES 5
+
+/* Maximum frame size = (MTU + LL heaader size) + FCS size */
+
+#define NCV_MAX_FRAME_SIZE(p) (p->dev.netdev.d_pktsize + 4)
+
+/* Packet Memory ************************************************************/
+
+/* Maximum number of allocated tx and rx packets */
+
+#define NCV7410_TX_QUOTA        1
+#define NCV7410_RX_QUOTA        2
+
+#if CONFIG_IOB_NBUFFERS < (NCV7410_TX_QUOTA + NCV7410_RX_QUOTA)
+#  error "CONFIG_IOB_NBUFFERS must be > (NCV7410_TX_QUOTA + NCV7410_RX_QUOTA)"
+#endif
+
+#ifndef CONFIG_SCHED_LPWORK
+#  error "CONFIG_SCHED_LPWORK is needed by NCV7410 driver"
+#endif
+
+/****************************************************************************
+ * Private Types
+ ****************************************************************************/
+
+/* The ncv7410_driver_s encapsulates all state information for a single
+ * hardware interface
+ */
+
+enum ncv_ifstate_e
+{
+  NCV_RESET,
+  NCV_INIT_DOWN,
+  NCV_INIT_UP
+};
+
+struct ncv7410_driver_s
+{
+  /* This holds the information visible to the NuttX network
+   * (must be placed first)
+   */
+
+  struct netdev_lowerhalf_s dev;
+
+  mutex_t mutex;
+
+  /* This is the contained SPI driver instance */
+
+  FAR struct spi_dev_s *spi;
+
+  /* irq number of the interrupt signal pin */
+
+  int irqnum;
+
+  /* Work instances for work_queue handling */
+
+  struct work_s interrupt_work;
+  struct work_s io_work;
+
+  /* Driver state, one of ncv_ifstate_e values */
+
+  uint8_t ifstate;
+
+  /* MAC-PHY internal buffer status */
+
+  int txc;
+  int rca;
+
+  /* Packet buffer management */
+
+  FAR netpkt_t *tx_pkt;
+  FAR netpkt_t *rx_pkt;
+  int tx_pkt_idx;
+  int rx_pkt_idx;
+  int tx_pkt_len;
+  bool rx_pkt_ready;
+};
+
+/****************************************************************************
+ * Private Function Prototypes
+ ****************************************************************************/
+
+/* Bit calculations */
+
+static int ncv_get_parity(uint32_t w);
+uint8_t ncv_bitrev8(uint8_t b);

Review Comment:
   Static?



-- 
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

Reply via email to