You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by GitBox <gi...@apache.org> on 2021/04/20 06:52:10 UTC

[GitHub] [incubator-nuttx] xiewenxiang commented on a change in pull request #3543: feat(esp32c3): Support esp32c3 ble function

xiewenxiang commented on a change in pull request #3543:
URL: https://github.com/apache/incubator-nuttx/pull/3543#discussion_r616392024



##########
File path: arch/risc-v/src/esp32c3/esp32c3_ble_adapter.c
##########
@@ -0,0 +1,2059 @@
+/****************************************************************************
+ * arch/risc-v/src/esp32c3/esp32c3_ble_adapter.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>
+
+#ifdef CONFIG_ESP32C3_BLE
+
+#include <stddef.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <assert.h>
+#include <pthread.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <clock/clock.h>
+#include <sys/time.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+
+#include "esp32c3_ble_adapter.h"
+#include "hardware/esp32c3_syscon.h"
+#include "esp32c3.h"
+#include "esp32c3_attr.h"
+#include "esp32c3_irq.h"
+#include "esp32c3_rt_timer.h"
+
+#include "nuttx/kmalloc.h"
+#include <nuttx/mqueue.h>
+#include "nuttx/spinlock.h"
+#include <nuttx/irq.h>
+#include <nuttx/semaphore.h>
+#include <nuttx/kthread.h>
+#include <nuttx/wdog.h>
+#include <nuttx/wqueue.h>
+#include <nuttx/sched.h>
+#include <nuttx/signal.h>
+
+#include "espidf_wifi.h"
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+#define OSI_FUNCS_TIME_BLOCKING  0xffffffff
+#define OSI_VERSION              0x00010006
+#define OSI_MAGIC_VALUE          0xfadebead
+
+/****************************************************************************
+ * Private Types
+ ****************************************************************************/
+
+/* BLE message queue private data */
+
+struct mq_adpt
+{
+  struct file mq;           /* Message queue handle */
+  uint32_t    msgsize;      /* Message size */
+  char        name[16];     /* Message queue name */
+};
+
+/* BLE interrupt adapter private data */
+
+struct irq_adpt
+{
+  void (*func)(void *arg);  /* Interrupt callback function */
+  void *arg;                /* Interrupt private data */
+};
+
+/* BLE low power control struct */
+
+typedef union
+{
+    struct
+    {
+        uint32_t enable                  :  1; /* whether low power mode is required */
+        uint32_t lpclk_sel               :  2; /* low power clock source */
+        uint32_t mac_bb_pd               :  1; /* whether hardware(MAC, BB) force-power-down is required during sleep */
+        uint32_t wakeup_timer_required   :  1; /* whether system timer is needed */
+        uint32_t no_light_sleep          :  1; /* do not allow system to enter light sleep after bluetooth is enabled */
+        uint32_t reserved                : 26; /* reserved */
+    };
+    uint32_t val;
+} btdm_lpcntl_t;
+
+/* low power control status */
+
+typedef union
+{
+    struct
+    {
+        uint32_t pm_lock_released        :  1; /* whether power management lock is released */
+        uint32_t mac_bb_pd               :  1; /* whether hardware(MAC, BB) is powered down */
+        uint32_t phy_enabled             :  1; /* whether phy is switched on */
+        uint32_t wakeup_timer_started    :  1; /* whether wakeup timer is started */
+        uint32_t reserved                : 28; /* reserved */
+    };
+    uint32_t val;
+} btdm_lpstat_t;
+
+/* vendor dependent signals to be posted to controller task */
+
+typedef enum
+{
+    BTDM_VND_OL_SIG_WAKEUP_TMR = 0,
+    BTDM_VND_OL_SIG_NUM,
+} btdm_vnd_ol_sig_t;
+
+/* prototype of function to handle vendor dependent signals */
+
+typedef void (* btdm_vnd_ol_task_func_t)(void *param);
+
+/* VHCI function interface */
+
+typedef struct vhci_host_callback
+{
+    void (*notify_host_send_available)(void);               /* callback used to notify that the host can send packet to controller */
+    int (*notify_host_recv)(uint8_t *data, uint16_t len);   /* callback used to notify that the controller has a packet to send to the host */
+} vhci_host_callback_t;
+
+/* Dram region */

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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org