xiaoxiang781216 commented on code in PR #10441:
URL: https://github.com/apache/nuttx/pull/10441#discussion_r1310409561


##########
boards/xtensa/esp32/common/src/esp32_wiegand.c:
##########
@@ -0,0 +1,175 @@
+/****************************************************************************
+ * boards/xtensa/esp32/common/src/esp32_wiegand.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 <nuttx/config.h>
+
+#include <assert.h>
+#include <debug.h>
+#include <errno.h>
+#include <stdbool.h>
+#include <stdio.h>
+
+#include <nuttx/wiegand/wiegand.h>
+
+#include "esp32_gpio.h"
+#include "hardware/esp32_gpio_sigmap.h"
+
+#ifndef CONFIG_ESP32_GPIO_IRQ
+#error "This drive needs to enable config of CONFIG_ESP32_GPIO_IRQ," \
+       " please enable it"
+#endif
+
+#define GPIO_DATA_0 22
+#define GPIO_DATA_1 23
+#define GPIO_DATA_NUM 2
+
+struct esp32_wiegand_config_s
+{
+  struct wiegand_config_s config;
+  void *arg;
+  xcpt_t isr;
+};
+
+int gpio_data [GPIO_DATA_NUM] =
+{
+  GPIO_DATA_0,
+  GPIO_DATA_1
+};
+
+static int wiegand_irq_attach(struct wiegand_config_s *dev, xcpt_t isr,
+                              void *arg);
+static void wiegand_irq_enable(struct wiegand_config_s *dev, bool enable);
+static bool wiegand_read_data(const struct wiegand_config_s *dev, int index);
+
+static struct esp32_wiegand_config_s wiegand_config =
+{
+  .config =
+    {
+      .get_data = wiegand_read_data,
+      .irq_attach = wiegand_irq_attach,
+      .irq_enable = wiegand_irq_enable,
+    },
+};
+
+static bool wiegand_read_data(const struct wiegand_config_s *dev, int index)

Review Comment:
   @halyssonJr it can be more general by calling ioexpender interface:
   
https://github.com/apache/nuttx/blob/master/include/nuttx/ioexpander/ioexpander.h#L320-L349



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