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/03/12 07:05:27 UTC

[GitHub] [incubator-nuttx] donghengqaz opened a new pull request #3040: riscv/esp32c3: Add ESP32-C3 WLAN netcard driver

donghengqaz opened a new pull request #3040:
URL: https://github.com/apache/incubator-nuttx/pull/3040


   ## Summary
   
   Add ESP32-C3 WLAN netcard driver.
   
   ## Impact
   
   ## Testing
   
   


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



[GitHub] [incubator-nuttx] gustavonihei commented on a change in pull request #3040: riscv/esp32c3: Add ESP32-C3 WLAN netcard driver

Posted by GitBox <gi...@apache.org>.
gustavonihei commented on a change in pull request #3040:
URL: https://github.com/apache/incubator-nuttx/pull/3040#discussion_r594697180



##########
File path: arch/risc-v/Kconfig
##########
@@ -45,6 +45,12 @@ config ARCH_CHIP_ESP32C3
 	select RV32IM_HW_MULDIV
 	select ARCH_VECNOTIRQ
 	select ARCH_HAVE_RESET
+	select LIBC_ARCH_MEMCPY

Review comment:
       `CONFIG_RISCV_MEMCPY` already defines a RISC-V-specific memcpy version. This will probably end up in a double definition error.
   It may be necessary to make these options exclusive.




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



[GitHub] [incubator-nuttx] gustavonihei commented on a change in pull request #3040: riscv/esp32c3: Add ESP32-C3 WLAN netcard driver

Posted by GitBox <gi...@apache.org>.
gustavonihei commented on a change in pull request #3040:
URL: https://github.com/apache/incubator-nuttx/pull/3040#discussion_r594699263



##########
File path: arch/risc-v/src/esp32c3/Kconfig
##########
@@ -283,4 +297,84 @@ endif # ESP32C3_UART1
 
 endmenu
 
+menu "Real-Time Timer"
+	depends on ESP32C3_RT_TIMER
+
+config ESP32C3_RT_TIMER_TASK_NAME
+	string "Timer task name"
+	default "rt_timer"
+
+config ESP32C3_RT_TIMER_TASK_PRIORITY
+	int "Timer task priority"
+	default 223 # Lower than high priority workqueue
+
+config ESP32C3_RT_TIMER_TASK_STACK_SIZE
+	int "Timer task stack size"
+	default 2048
+
+endmenu # Real-Time Timer
+
+menu "WiFi configuration"
+	depends on ESP32C3_WIRELESS
+
+config ESP32C3_WIFI_STATIC_RXBUF_NUM
+    int "WiFi static RX buffer number"
+	default 10
+
+config ESP32C3_WIFI_DYNAMIC_RXBUF_NUM
+    int "WiFi dynamic RX buffer number"
+	default 32
+
+config ESP32C3_WIFI_DYNAMIC_TXBUF_NUM
+    int "WiFi dynamic TX buffer number"
+	default 32
+
+config ESP32C3_WIFI_TX_AMPDU
+	bool "WiFi TX AMPDU"
+	default y
+
+config ESP32C3_WIFI_RX_AMPDU
+	bool "WiFi RX AMPDU"
+	default y
+
+config ESP32C3_WIFI_RXBA_AMPDU_WZ
+    int "WiFi RX BA AMPDU windown size"
+	default 6
+
+config ESP32C3_WLAN_RXBUF_NUM
+	int "WLAN netcard RX buffer number"
+	default 16
+
+config ESP32C3_WIFI_CONNECT_TIMEOUT
+	int "Connect timeout by second"
+	default 10
+	help
+		Max waiting time of connecting to AP.
+
+config ESP32C3_WIFI_SAVE_PARAM
+	bool "Save WiFi Parameters"
+	default n
+	depends on !DISABLE_MOUNTPOINT
+	help
+		If you enable this option, WiFi adapter parameters will be saved

Review comment:
       ```suggestion
   		If you enable this option, Wi-Fi adapter parameters will be saved
   ```




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



[GitHub] [incubator-nuttx] donghengqaz commented on a change in pull request #3040: riscv/esp32c3: Add ESP32-C3 WLAN netcard driver

Posted by GitBox <gi...@apache.org>.
donghengqaz commented on a change in pull request #3040:
URL: https://github.com/apache/incubator-nuttx/pull/3040#discussion_r594077567



##########
File path: arch/risc-v/src/esp32c3/esp32c3_wifi_adapter.h
##########
@@ -0,0 +1,242 @@
+/****************************************************************************
+ * arch/risc-v/src/esp32c3/esp32c3_wifi_adapter.h
+ *
+ * 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.
+ *
+ ****************************************************************************/
+
+#ifndef __ARCH_RISCV_SRC_ESP32C3_ESP32C3_WIFI_ADAPTER_H
+#define __ARCH_RISCV_SRC_ESP32C3_ESP32C3_WIFI_ADAPTER_H
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <sys/types.h>
+
+#ifndef __ASSEMBLY__
+
+#undef EXTERN
+#if defined(__cplusplus)
+#define EXTERN extern "C"
+extern "C"
+{
+#else
+#define EXTERN extern
+#endif
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+/* WiFi event ID */
+
+enum wifi_adpt_evt_e
+{
+  WIFI_ADPT_EVT_STA_START = 0,
+  WIFI_ADPT_EVT_STA_CONNECT,
+  WIFI_ADPT_EVT_STA_DISCONNECT,
+  WIFI_ADPT_EVT_STA_AUTHMODE_CHANGE,
+  WIFI_ADPT_EVT_STA_STOP,
+  WIFI_ADPT_EVT_MAX,
+};
+
+/* WiFi event callback function */
+
+typedef void (*wifi_evt_cb_t)(void *p);
+
+typedef void (* wifi_tx_done_cb_t)(uint8_t ifidx, uint8_t *data,
+                                   uint16_t *len, bool txstatus);
+
+/****************************************************************************
+ * Public Function Prototypes
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: esp_wifi_adapter_init
+ *
+ * Description:
+ *   Initialize ESP32 WiFi adapter

Review comment:
       Of course.




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



[GitHub] [incubator-nuttx] gustavonihei commented on a change in pull request #3040: riscv/esp32c3: Add ESP32-C3 WLAN netcard driver

Posted by GitBox <gi...@apache.org>.
gustavonihei commented on a change in pull request #3040:
URL: https://github.com/apache/incubator-nuttx/pull/3040#discussion_r594700502



##########
File path: arch/risc-v/src/esp32c3/esp32c3_wifi_adapter.h
##########
@@ -0,0 +1,242 @@
+/****************************************************************************
+ * arch/risc-v/src/esp32c3/esp32c3_wifi_adapter.h
+ *
+ * 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.
+ *
+ ****************************************************************************/
+
+#ifndef __ARCH_RISCV_SRC_ESP32C3_ESP32C3_WIFI_ADAPTER_H
+#define __ARCH_RISCV_SRC_ESP32C3_ESP32C3_WIFI_ADAPTER_H
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <sys/types.h>
+
+#ifndef __ASSEMBLY__
+
+#undef EXTERN
+#if defined(__cplusplus)
+#define EXTERN extern "C"
+extern "C"
+{
+#else
+#define EXTERN extern
+#endif
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+/* WiFi event ID */
+
+enum wifi_adpt_evt_e
+{
+  WIFI_ADPT_EVT_STA_START = 0,
+  WIFI_ADPT_EVT_STA_CONNECT,
+  WIFI_ADPT_EVT_STA_DISCONNECT,
+  WIFI_ADPT_EVT_STA_AUTHMODE_CHANGE,
+  WIFI_ADPT_EVT_STA_STOP,
+  WIFI_ADPT_EVT_MAX,
+};
+
+/* WiFi event callback function */
+
+typedef void (*wifi_evt_cb_t)(void *p);
+
+typedef void (* wifi_tx_done_cb_t)(uint8_t ifidx, uint8_t *data,
+                                   uint16_t *len, bool txstatus);
+
+/****************************************************************************
+ * Public Function Prototypes
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: esp_wifi_adapter_init
+ *
+ * Description:
+ *   Initialize ESP32 WiFi adapter
+ *
+ * Input Parameters:
+ *   None
+ *
+ * Returned Value:
+ *   0 if success or -1 if fail
+ *
+ ****************************************************************************/
+
+int esp_wifi_adapter_init(void);
+
+/****************************************************************************
+ * Name: esp_wifi_notify_subscribe
+ *
+ * Description:
+ *   Enable event notification
+ *
+ * Input Parameters:
+ *   pid   - Task PID
+ *   event - Signal event data pointer
+ *
+ * Returned Value:
+ *   0 if success or -1 if fail
+ *
+ ****************************************************************************/
+
+int esp_wifi_notify_subscribe(pid_t pid, FAR struct sigevent *event);
+
+/****************************************************************************
+ * Name: esp_wifi_sta_send_data
+ *
+ * Description:
+ *   Use WiFi station interface to send 802.3 frame
+ *
+ * Input Parameters:
+ *   pbuf - Packet buffer pointer
+ *   len  - Packet length
+ *
+ * Returned Value:
+ *   0 if success or others if fail
+ *
+ ****************************************************************************/
+
+int esp_wifi_sta_send_data(void *pbuf, uint32_t len);
+
+/****************************************************************************
+ * Name: esp_wifi_sta_register_recv_cb
+ *
+ * Description:
+ *   Register WiFi receive packet callback function
+ *
+ * Input Parameters:
+ *   input_cb - Receive callback function
+ *
+ * Returned Value:
+ *   0 if success or others if fail
+ *
+ ****************************************************************************/
+
+int esp_wifi_sta_register_recv_cb(int (*recv_cb)(void *buffer,
+                                                 uint16_t len,
+                                                 void *eb));
+
+/****************************************************************************
+ * Name: esp_wifi_sta_read_mac
+ *
+ * Description:
+ *   Read station interface MAC address from efuse
+ *
+ * Input Parameters:
+ *   mac  - MAC address buffer pointer
+ *
+ * Returned Value:
+ *   0 if success or -1 if fail
+ *
+ ****************************************************************************/
+
+int esp_wifi_sta_read_mac(uint8_t *mac);
+
+/****************************************************************************
+ * Name: esp_wifi_free_eb
+ *
+ * Description:
+ *   Free WiFi receive callback input eb pointer
+ *
+ * Input Parameters:
+ *   eb - WiFi receive callback input eb pointer
+ *
+ * Returned Value:
+ *   None
+ *
+ ****************************************************************************/
+
+void esp_wifi_free_eb(void *eb);
+
+/****************************************************************************
+ * Name: esp_wifi_set_password
+ *
+ * Description:
+ *   Set WiFi password

Review comment:
       ```suggestion
    *   Set Wi-Fi password
   ```

##########
File path: arch/risc-v/src/esp32c3/esp32c3_wifi_adapter.h
##########
@@ -0,0 +1,242 @@
+/****************************************************************************
+ * arch/risc-v/src/esp32c3/esp32c3_wifi_adapter.h
+ *
+ * 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.
+ *
+ ****************************************************************************/
+
+#ifndef __ARCH_RISCV_SRC_ESP32C3_ESP32C3_WIFI_ADAPTER_H
+#define __ARCH_RISCV_SRC_ESP32C3_ESP32C3_WIFI_ADAPTER_H
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <sys/types.h>
+
+#ifndef __ASSEMBLY__
+
+#undef EXTERN
+#if defined(__cplusplus)
+#define EXTERN extern "C"
+extern "C"
+{
+#else
+#define EXTERN extern
+#endif
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+/* WiFi event ID */
+
+enum wifi_adpt_evt_e
+{
+  WIFI_ADPT_EVT_STA_START = 0,
+  WIFI_ADPT_EVT_STA_CONNECT,
+  WIFI_ADPT_EVT_STA_DISCONNECT,
+  WIFI_ADPT_EVT_STA_AUTHMODE_CHANGE,
+  WIFI_ADPT_EVT_STA_STOP,
+  WIFI_ADPT_EVT_MAX,
+};
+
+/* WiFi event callback function */
+
+typedef void (*wifi_evt_cb_t)(void *p);
+
+typedef void (* wifi_tx_done_cb_t)(uint8_t ifidx, uint8_t *data,
+                                   uint16_t *len, bool txstatus);
+
+/****************************************************************************
+ * Public Function Prototypes
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: esp_wifi_adapter_init
+ *
+ * Description:
+ *   Initialize ESP32 WiFi adapter
+ *
+ * Input Parameters:
+ *   None
+ *
+ * Returned Value:
+ *   0 if success or -1 if fail
+ *
+ ****************************************************************************/
+
+int esp_wifi_adapter_init(void);
+
+/****************************************************************************
+ * Name: esp_wifi_notify_subscribe
+ *
+ * Description:
+ *   Enable event notification
+ *
+ * Input Parameters:
+ *   pid   - Task PID
+ *   event - Signal event data pointer
+ *
+ * Returned Value:
+ *   0 if success or -1 if fail
+ *
+ ****************************************************************************/
+
+int esp_wifi_notify_subscribe(pid_t pid, FAR struct sigevent *event);
+
+/****************************************************************************
+ * Name: esp_wifi_sta_send_data
+ *
+ * Description:
+ *   Use WiFi station interface to send 802.3 frame
+ *
+ * Input Parameters:
+ *   pbuf - Packet buffer pointer
+ *   len  - Packet length
+ *
+ * Returned Value:
+ *   0 if success or others if fail
+ *
+ ****************************************************************************/
+
+int esp_wifi_sta_send_data(void *pbuf, uint32_t len);
+
+/****************************************************************************
+ * Name: esp_wifi_sta_register_recv_cb
+ *
+ * Description:
+ *   Register WiFi receive packet callback function
+ *
+ * Input Parameters:
+ *   input_cb - Receive callback function
+ *
+ * Returned Value:
+ *   0 if success or others if fail
+ *
+ ****************************************************************************/
+
+int esp_wifi_sta_register_recv_cb(int (*recv_cb)(void *buffer,
+                                                 uint16_t len,
+                                                 void *eb));
+
+/****************************************************************************
+ * Name: esp_wifi_sta_read_mac
+ *
+ * Description:
+ *   Read station interface MAC address from efuse
+ *
+ * Input Parameters:
+ *   mac  - MAC address buffer pointer
+ *
+ * Returned Value:
+ *   0 if success or -1 if fail
+ *
+ ****************************************************************************/
+
+int esp_wifi_sta_read_mac(uint8_t *mac);
+
+/****************************************************************************
+ * Name: esp_wifi_free_eb
+ *
+ * Description:
+ *   Free WiFi receive callback input eb pointer

Review comment:
       ```suggestion
    *   Free Wi-Fi receive callback input eb pointer
   ```

##########
File path: arch/risc-v/src/esp32c3/esp32c3_wifi_adapter.h
##########
@@ -0,0 +1,242 @@
+/****************************************************************************
+ * arch/risc-v/src/esp32c3/esp32c3_wifi_adapter.h
+ *
+ * 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.
+ *
+ ****************************************************************************/
+
+#ifndef __ARCH_RISCV_SRC_ESP32C3_ESP32C3_WIFI_ADAPTER_H
+#define __ARCH_RISCV_SRC_ESP32C3_ESP32C3_WIFI_ADAPTER_H
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <sys/types.h>
+
+#ifndef __ASSEMBLY__
+
+#undef EXTERN
+#if defined(__cplusplus)
+#define EXTERN extern "C"
+extern "C"
+{
+#else
+#define EXTERN extern
+#endif
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+/* WiFi event ID */
+
+enum wifi_adpt_evt_e
+{
+  WIFI_ADPT_EVT_STA_START = 0,
+  WIFI_ADPT_EVT_STA_CONNECT,
+  WIFI_ADPT_EVT_STA_DISCONNECT,
+  WIFI_ADPT_EVT_STA_AUTHMODE_CHANGE,
+  WIFI_ADPT_EVT_STA_STOP,
+  WIFI_ADPT_EVT_MAX,
+};
+
+/* WiFi event callback function */
+
+typedef void (*wifi_evt_cb_t)(void *p);
+
+typedef void (* wifi_tx_done_cb_t)(uint8_t ifidx, uint8_t *data,
+                                   uint16_t *len, bool txstatus);
+
+/****************************************************************************
+ * Public Function Prototypes
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: esp_wifi_adapter_init
+ *
+ * Description:
+ *   Initialize ESP32 WiFi adapter
+ *
+ * Input Parameters:
+ *   None
+ *
+ * Returned Value:
+ *   0 if success or -1 if fail
+ *
+ ****************************************************************************/
+
+int esp_wifi_adapter_init(void);
+
+/****************************************************************************
+ * Name: esp_wifi_notify_subscribe
+ *
+ * Description:
+ *   Enable event notification
+ *
+ * Input Parameters:
+ *   pid   - Task PID
+ *   event - Signal event data pointer
+ *
+ * Returned Value:
+ *   0 if success or -1 if fail
+ *
+ ****************************************************************************/
+
+int esp_wifi_notify_subscribe(pid_t pid, FAR struct sigevent *event);
+
+/****************************************************************************
+ * Name: esp_wifi_sta_send_data
+ *
+ * Description:
+ *   Use WiFi station interface to send 802.3 frame
+ *
+ * Input Parameters:
+ *   pbuf - Packet buffer pointer
+ *   len  - Packet length
+ *
+ * Returned Value:
+ *   0 if success or others if fail
+ *
+ ****************************************************************************/
+
+int esp_wifi_sta_send_data(void *pbuf, uint32_t len);
+
+/****************************************************************************
+ * Name: esp_wifi_sta_register_recv_cb
+ *
+ * Description:
+ *   Register WiFi receive packet callback function
+ *
+ * Input Parameters:
+ *   input_cb - Receive callback function
+ *
+ * Returned Value:
+ *   0 if success or others if fail
+ *
+ ****************************************************************************/
+
+int esp_wifi_sta_register_recv_cb(int (*recv_cb)(void *buffer,
+                                                 uint16_t len,
+                                                 void *eb));
+
+/****************************************************************************
+ * Name: esp_wifi_sta_read_mac
+ *
+ * Description:
+ *   Read station interface MAC address from efuse
+ *
+ * Input Parameters:
+ *   mac  - MAC address buffer pointer
+ *
+ * Returned Value:
+ *   0 if success or -1 if fail
+ *
+ ****************************************************************************/
+
+int esp_wifi_sta_read_mac(uint8_t *mac);
+
+/****************************************************************************
+ * Name: esp_wifi_free_eb
+ *
+ * Description:
+ *   Free WiFi receive callback input eb pointer
+ *
+ * Input Parameters:
+ *   eb - WiFi receive callback input eb pointer

Review comment:
       ```suggestion
    *   eb - Wi-Fi receive callback input eb pointer
   ```

##########
File path: arch/risc-v/src/esp32c3/esp32c3_wifi_adapter.h
##########
@@ -0,0 +1,242 @@
+/****************************************************************************
+ * arch/risc-v/src/esp32c3/esp32c3_wifi_adapter.h
+ *
+ * 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.
+ *
+ ****************************************************************************/
+
+#ifndef __ARCH_RISCV_SRC_ESP32C3_ESP32C3_WIFI_ADAPTER_H
+#define __ARCH_RISCV_SRC_ESP32C3_ESP32C3_WIFI_ADAPTER_H
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <sys/types.h>
+
+#ifndef __ASSEMBLY__
+
+#undef EXTERN
+#if defined(__cplusplus)
+#define EXTERN extern "C"
+extern "C"
+{
+#else
+#define EXTERN extern
+#endif
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+/* WiFi event ID */
+
+enum wifi_adpt_evt_e
+{
+  WIFI_ADPT_EVT_STA_START = 0,
+  WIFI_ADPT_EVT_STA_CONNECT,
+  WIFI_ADPT_EVT_STA_DISCONNECT,
+  WIFI_ADPT_EVT_STA_AUTHMODE_CHANGE,
+  WIFI_ADPT_EVT_STA_STOP,
+  WIFI_ADPT_EVT_MAX,
+};
+
+/* WiFi event callback function */
+
+typedef void (*wifi_evt_cb_t)(void *p);
+
+typedef void (* wifi_tx_done_cb_t)(uint8_t ifidx, uint8_t *data,
+                                   uint16_t *len, bool txstatus);
+
+/****************************************************************************
+ * Public Function Prototypes
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: esp_wifi_adapter_init
+ *
+ * Description:
+ *   Initialize ESP32 WiFi adapter
+ *
+ * Input Parameters:
+ *   None
+ *
+ * Returned Value:
+ *   0 if success or -1 if fail
+ *
+ ****************************************************************************/
+
+int esp_wifi_adapter_init(void);
+
+/****************************************************************************
+ * Name: esp_wifi_notify_subscribe
+ *
+ * Description:
+ *   Enable event notification
+ *
+ * Input Parameters:
+ *   pid   - Task PID
+ *   event - Signal event data pointer
+ *
+ * Returned Value:
+ *   0 if success or -1 if fail
+ *
+ ****************************************************************************/
+
+int esp_wifi_notify_subscribe(pid_t pid, FAR struct sigevent *event);
+
+/****************************************************************************
+ * Name: esp_wifi_sta_send_data
+ *
+ * Description:
+ *   Use WiFi station interface to send 802.3 frame
+ *
+ * Input Parameters:
+ *   pbuf - Packet buffer pointer
+ *   len  - Packet length
+ *
+ * Returned Value:
+ *   0 if success or others if fail
+ *
+ ****************************************************************************/
+
+int esp_wifi_sta_send_data(void *pbuf, uint32_t len);
+
+/****************************************************************************
+ * Name: esp_wifi_sta_register_recv_cb
+ *
+ * Description:
+ *   Register WiFi receive packet callback function

Review comment:
       ```suggestion
    *   Register Wi-Fi receive packet callback function
   ```

##########
File path: arch/risc-v/src/esp32c3/esp32c3_wifi_adapter.h
##########
@@ -0,0 +1,242 @@
+/****************************************************************************
+ * arch/risc-v/src/esp32c3/esp32c3_wifi_adapter.h
+ *
+ * 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.
+ *
+ ****************************************************************************/
+
+#ifndef __ARCH_RISCV_SRC_ESP32C3_ESP32C3_WIFI_ADAPTER_H
+#define __ARCH_RISCV_SRC_ESP32C3_ESP32C3_WIFI_ADAPTER_H
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <sys/types.h>
+
+#ifndef __ASSEMBLY__
+
+#undef EXTERN
+#if defined(__cplusplus)
+#define EXTERN extern "C"
+extern "C"
+{
+#else
+#define EXTERN extern
+#endif
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+/* WiFi event ID */
+
+enum wifi_adpt_evt_e
+{
+  WIFI_ADPT_EVT_STA_START = 0,
+  WIFI_ADPT_EVT_STA_CONNECT,
+  WIFI_ADPT_EVT_STA_DISCONNECT,
+  WIFI_ADPT_EVT_STA_AUTHMODE_CHANGE,
+  WIFI_ADPT_EVT_STA_STOP,
+  WIFI_ADPT_EVT_MAX,
+};
+
+/* WiFi event callback function */
+
+typedef void (*wifi_evt_cb_t)(void *p);
+
+typedef void (* wifi_tx_done_cb_t)(uint8_t ifidx, uint8_t *data,
+                                   uint16_t *len, bool txstatus);
+
+/****************************************************************************
+ * Public Function Prototypes
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: esp_wifi_adapter_init
+ *
+ * Description:
+ *   Initialize ESP32 WiFi adapter
+ *
+ * Input Parameters:
+ *   None
+ *
+ * Returned Value:
+ *   0 if success or -1 if fail
+ *
+ ****************************************************************************/
+
+int esp_wifi_adapter_init(void);
+
+/****************************************************************************
+ * Name: esp_wifi_notify_subscribe
+ *
+ * Description:
+ *   Enable event notification
+ *
+ * Input Parameters:
+ *   pid   - Task PID
+ *   event - Signal event data pointer
+ *
+ * Returned Value:
+ *   0 if success or -1 if fail
+ *
+ ****************************************************************************/
+
+int esp_wifi_notify_subscribe(pid_t pid, FAR struct sigevent *event);
+
+/****************************************************************************
+ * Name: esp_wifi_sta_send_data
+ *
+ * Description:
+ *   Use WiFi station interface to send 802.3 frame

Review comment:
       ```suggestion
    *   Use Wi-Fi station interface to send 802.3 frame
   ```




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



[GitHub] [incubator-nuttx] gustavonihei commented on a change in pull request #3040: riscv/esp32c3: Add ESP32-C3 WLAN netcard driver

Posted by GitBox <gi...@apache.org>.
gustavonihei commented on a change in pull request #3040:
URL: https://github.com/apache/incubator-nuttx/pull/3040#discussion_r594697180



##########
File path: arch/risc-v/Kconfig
##########
@@ -45,6 +45,12 @@ config ARCH_CHIP_ESP32C3
 	select RV32IM_HW_MULDIV
 	select ARCH_VECNOTIRQ
 	select ARCH_HAVE_RESET
+	select LIBC_ARCH_MEMCPY

Review comment:
       `CONFIG_RISCV_MEMCPY` already defines a RISC-V-specific memcpy version. This will probably end up in a double definition error.




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



[GitHub] [incubator-nuttx] gustavonihei commented on a change in pull request #3040: riscv/esp32c3: Add ESP32-C3 WLAN netcard driver

Posted by GitBox <gi...@apache.org>.
gustavonihei commented on a change in pull request #3040:
URL: https://github.com/apache/incubator-nuttx/pull/3040#discussion_r593122074



##########
File path: arch/risc-v/src/esp32c3/esp32c3_rt_timer.c
##########
@@ -0,0 +1,678 @@
+/****************************************************************************
+ * arch/risc-v/src/esp32c3/esp32c3_rt_timer.c
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this args 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 <stdbool.h>
+#include <string.h>
+#include <fcntl.h>
+#include <assert.h>
+#include <errno.h>
+#include <debug.h>
+
+#include <nuttx/irq.h>
+#include <nuttx/kthread.h>
+#include <nuttx/kmalloc.h>
+#include <nuttx/semaphore.h>
+
+#include "hardware/esp32c3_soc.h"
+#include "esp32c3_tim.h"
+#include "esp32c3_rt_timer.h"
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+#ifdef CONFIG_SCHED_HPWORKPRIORITY
+#  if CONFIG_ESP32C3_RT_TIMER_TASK_PRIORITY >= CONFIG_SCHED_HPWORKPRIORITY
+#    error "RT timer priority should be smaller that high-prio workqueue"
+#  endif
+#endif
+
+#define RT_TIMER_TASK_NAME        CONFIG_ESP32C3_RT_TIMER_TASK_NAME
+#define RT_TIMER_TASK_PRIORITY    CONFIG_ESP32C3_RT_TIMER_TASK_PRIORITY
+#define RT_TIMER_TASK_STACK_SIZE  CONFIG_ESP32C3_RT_TIMER_TASK_STACK_SIZE
+
+#define ESP32C3_TIMER_PRESCALER     (APB_CLK_FREQ / (1000 * 1000))
+
+/****************************************************************************
+ * Private Data
+ ****************************************************************************/
+
+static int s_pid;
+
+static sem_t s_toutsem;
+
+static struct list_node s_runlist;
+static struct list_node s_toutlist;
+
+static struct esp32c3_tim_dev_s *s_esp32c3_tim_dev;
+
+/****************************************************************************
+ * Private Function Prototypes
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: start_rt_timer
+ *
+ * Description:
+ *   Start timer by inserting it into running list and reset hardware timer
+ *   alarm value if this timer in head of list.
+ *
+ * Input Parameters:
+ *   timer - RT timer pointer
+ *   timeout - Timeout value
+ *   repeat  - If the timer run repeat
+ *
+ * Returned Value:
+ *   None.
+ *
+ ****************************************************************************/
+
+static void start_rt_timer(FAR struct rt_timer_s *timer,
+                           uint64_t timeout,
+                           bool repeat)
+{
+  irqstate_t flags;
+  struct rt_timer_s *p;
+  bool inserted = false;
+  uint64_t counter;
+  struct esp32c3_tim_dev_s *tim = s_esp32c3_tim_dev;
+
+  flags = enter_critical_section();
+
+  /* Only idle timer can be started */
+
+  if (timer->state == RT_TIMER_IDLE)
+    {
+      /* Calculate the timer's alarm value */
+
+      ESP32C3_TIM_GETCTR(tim, &counter);
+      timer->timeout = timeout;
+      timer->alarm = timer->timeout + counter;
+
+      if (repeat)
+        {
+          timer->flags |= RT_TIMER_REPEAT;
+        }
+      else
+        {
+          timer->flags &= ~RT_TIMER_REPEAT;
+        }
+
+      /** Scan timer list and insert the new timer into previous
+       *  node of timer whose alarm value is larger than new one
+       */
+
+      list_for_every_entry(&s_runlist, p, struct rt_timer_s, list)
+        {
+          if (p->alarm > timer->alarm)
+            {
+              list_add_before(&p->list, &timer->list);
+              inserted = true;
+              break;
+            }
+        }
+
+      /* If not find a larger one, insert new timer into tail of list */
+
+      if (!inserted)
+        {
+          list_add_tail(&s_runlist, &timer->list);
+        }
+
+      timer->state = RT_TIMER_READY;
+
+      /* If this timer is in head of list */
+
+      if (timer == container_of(s_runlist.next, struct rt_timer_s, list))
+        {
+          /* Reset hardware timer alarm */
+
+          ESP32C3_TIM_SETALRVL(tim, timer->alarm);
+          ESP32C3_TIM_SETALRM(tim, true);
+        }
+    }
+
+  leave_critical_section(flags);
+}
+
+/****************************************************************************
+ * Name: stop_rt_timer
+ *
+ * Description:
+ *   Stop timer by removing it from running list and reset hardware timer
+ *   alarm value if this timer is in head of list.
+ *
+ * Input Parameters:
+ *   timer - RT timer pointer
+ *
+ * Returned Value:
+ *   None.
+ *
+ ****************************************************************************/
+
+static void stop_rt_timer(FAR struct rt_timer_s *timer)
+{
+  irqstate_t flags;
+  bool ishead;
+  struct rt_timer_s *next_timer;
+  uint64_t alarm;
+  struct esp32c3_tim_dev_s *tim = s_esp32c3_tim_dev;
+
+  flags = enter_critical_section();
+
+  /**
+   * Function "start" can set timer to be repeat, and function "stop"
+   * should remove this feature although it is not in ready state.
+   */
+
+  timer->flags &= ~RT_TIMER_REPEAT;
+
+  /* Only ready timer can be stopped */
+
+  if (timer->state == RT_TIMER_READY)
+    {
+      /* Check if timer is in head of list */
+
+      if (timer == container_of(s_runlist.next, struct rt_timer_s, list))
+        {
+          ishead = true;
+        }
+      else
+        {
+          ishead = false;
+        }
+
+      list_delete(&timer->list);
+      timer->state = RT_TIMER_IDLE;
+
+      /* If timer is in in head of list */
+
+      if (ishead)
+        {
+          /* If list is not empty */
+
+          if (!list_is_empty(&s_runlist))
+            {
+              /* Reset hardware timer alarm value to be next timer's */
+
+              next_timer = container_of(s_runlist.next,
+                                        struct rt_timer_s,
+                                        list);
+              alarm = next_timer->alarm;
+
+              ESP32C3_TIM_SETALRVL(tim, alarm);
+              ESP32C3_TIM_SETALRM(tim, true);
+            }
+        }
+    }
+
+  leave_critical_section(flags);
+}
+
+/****************************************************************************
+ * Name: delete_rt_timer
+ *
+ * Description:
+ *   Delete timer by removing it from list, then set the timer's state
+ *   to be "RT_TIMER_DELETE", inserting into work list to let rt-timer
+ *   thread to delete it and free resource.
+ *
+ * Input Parameters:
+ *   timer - RT timer pointer
+ *
+ * Returned Value:
+ *   None.
+ *
+ ****************************************************************************/
+
+static void delete_rt_timer(FAR struct rt_timer_s *timer)
+{
+  irqstate_t flags;
+
+  flags = enter_critical_section();
+
+  if (timer->state == RT_TIMER_READY)
+    {
+      stop_rt_timer(timer);
+    }
+  else if (timer->state == RT_TIMER_TIMEOUT)
+    {
+      list_delete(&timer->list);
+    }
+  else if (timer->state == RT_TIMER_DELETE)
+    {
+      goto exit;
+    }
+
+  list_add_after(&s_toutlist, &timer->list);
+  timer->state = RT_TIMER_DELETE;
+
+exit:
+  leave_critical_section(flags);
+}
+
+/****************************************************************************
+ * Name: rt_timer_thread
+ *
+ * Description:
+ *   RT timer working thread, it wait for a timeout semaphore, scan
+ *   the timeout list and process all timers in this list.
+ *
+ * Input Parameters:
+ *   argc - Not used
+ *   argv - Not used
+ *
+ * Returned Value:
+ *   0.
+ *
+ ****************************************************************************/
+
+static int rt_timer_thread(int argc, FAR char *argv[])
+{
+  int ret;
+  irqstate_t flags;
+  struct rt_timer_s *timer;
+  enum rt_timer_state_e raw_state;
+
+  while (1)
+    {
+      /* Waiting for timers timeout */
+
+      ret = nxsem_wait(&s_toutsem);
+      if (ret)
+        {
+          tmrerr("ERROR: Wait s_toutsem error=%d\n", ret);
+          assert(0);
+        }
+
+      /* Enter critical to check global timer timeout list */
+
+      flags = enter_critical_section();
+
+      /* Process all timers in list */
+
+      while (!list_is_empty(&s_toutlist))
+        {
+          /* Get first timer in list */
+
+          timer = container_of(s_toutlist.next, struct rt_timer_s, list);
+
+          /* Cache the raw state to decide how to deal with this timer */
+
+          raw_state = timer->state;
+
+          /* Delete timer from list */
+
+          list_delete(&timer->list);
+
+          /* Set timer's state to be let it to able to restart by user */
+
+          timer->state = RT_TIMER_IDLE;
+
+          /* Leave from critical to start to call "callback" function */
+
+          leave_critical_section(flags);
+
+          if (raw_state == RT_TIMER_TIMEOUT)
+            {
+              timer->callback(timer->arg);
+            }
+          else if (raw_state == RT_TIMER_DELETE)
+            {
+              kmm_free(timer);
+            }
+
+          /* Enter critical for next scanning list */
+
+          flags = enter_critical_section();
+
+          if (raw_state == RT_TIMER_TIMEOUT)
+            {
+              /* Check if timer is repeat */
+
+              if (timer->flags & RT_TIMER_REPEAT)
+                {
+                  start_rt_timer(timer, timer->timeout, true);
+                }
+            }
+        }
+
+      leave_critical_section(flags);
+    }
+
+  return 0;
+}
+
+/****************************************************************************
+ * Name: rt_timer_isr
+ *
+ * Description:
+ *   Hardware timer interrupt service function.
+ *
+ * Input Parameters:
+ *   irq     - Not used
+ *   context - Not used
+ *   arg     - Not used
+ *
+ * Returned Value:
+ *   0.
+ *
+ ****************************************************************************/
+
+static int rt_timer_isr(int irq, void *context, void *arg)
+{
+  irqstate_t flags;
+  struct rt_timer_s *timer;
+  uint64_t alarm;
+  uint64_t counter;
+  struct esp32c3_tim_dev_s *tim = s_esp32c3_tim_dev;
+
+  /* Clear interrupt register status */
+
+  ESP32C3_TIM_ACKINT(tim);
+
+  /* Wake up thread to process timeout timers */
+
+  nxsem_post(&s_toutsem);
+
+  flags = enter_critical_section();
+
+  /* Check if there is timer running */
+
+  if (!list_is_empty(&s_runlist))
+    {
+      /**
+       * When stop/delete timer, in the same time the hardware timer
+       * interrupt triggers, function "stop/delete" remove the timer
+       * from running list, so the 1st timer is not which triggers.
+       */
+
+      timer = container_of(s_runlist.next, struct rt_timer_s, list);
+      ESP32C3_TIM_GETCTR(tim, &counter);
+      if (timer->alarm <= counter)
+        {
+          /**
+           * Remove first timer in running list and add it into
+           * timeout list.
+           *
+           * Set the timer's state to be RT_TIMER_TIMEOUT to avoid
+           * other operation.
+           */
+
+          list_delete(&timer->list);
+          timer->state = RT_TIMER_TIMEOUT;
+          list_add_after(&s_toutlist, &timer->list);
+
+          /* Check if thers is timer running */
+
+          if (!list_is_empty(&s_runlist))
+            {
+              /* Reset hardware timer alarm with next timer's alarm value */
+
+              timer = container_of(s_runlist.next, struct rt_timer_s, list);
+              alarm = timer->alarm;
+
+              ESP32C3_TIM_SETALRVL(tim, alarm);
+              ESP32C3_TIM_SETALRM(tim, true);
+            }
+        }
+    }
+
+  leave_critical_section(flags);
+
+  return 0;
+}
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: rt_timer_create
+ *
+ * Description:
+ *   Create RT timer by into timer creation arguments
+ *
+ * Input Parameters:
+ *   args         - Input RT timer creation arguments
+ *   timer_handle - Output RT timer handle pointer
+ *
+ * Returned Value:
+ *   0 is returned on success. Otherwise, a negated errno value is returned.
+ *
+ ****************************************************************************/
+
+int rt_timer_create(FAR const struct rt_timer_args_s *args,
+                    FAR struct rt_timer_s **timer_handle)
+{
+  struct rt_timer_s *timer;
+
+  timer = (struct rt_timer_s *)kmm_malloc(sizeof(*timer));
+  if (!timer)
+    {
+      tmrerr("ERROR: Failed to allocate %d bytes\n", sizeof(*timer));
+      return -ENOMEM;
+    }
+
+  timer->callback = args->callback;
+  timer->arg      = args->arg;
+  timer->flags    = RT_TIMER_NOFLAGS;
+  timer->state    = RT_TIMER_IDLE;
+  list_initialize(&timer->list);
+
+  *timer_handle = timer;
+
+  return 0;
+}
+
+/****************************************************************************
+ * Name: rt_timer_start
+ *
+ * Description:
+ *   Start RT timer.
+ *
+ * Input Parameters:
+ *   timer   - RT timer pointer
+ *   timeout - Timeout value
+ *   repeat  - If the timer run repeat
+ *
+ * Returned Value:
+ *   None
+ *
+ ****************************************************************************/
+
+void rt_timer_start(FAR struct rt_timer_s *timer,
+                    uint64_t timeout,
+                    bool repeat)
+{
+  stop_rt_timer(timer);
+
+  start_rt_timer(timer, timeout, repeat);
+}
+
+/****************************************************************************
+ * Name: rt_timer_stop
+ *
+ * Description:
+ *   Stop RT timer.
+ *
+ * Input Parameters:
+ *   timer - RT timer pointer
+ *
+ * Returned Value:
+ *   None
+ *
+ ****************************************************************************/
+
+void rt_timer_stop(FAR struct rt_timer_s *timer)
+{
+  stop_rt_timer(timer);
+}
+
+/****************************************************************************
+ * Name: rt_timer_delete
+ *
+ * Description:
+ *   Stop and deleta RT timer.

Review comment:
       ```suggestion
    *   Stop and delete RT timer.
   ```




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



[GitHub] [incubator-nuttx] donghengqaz commented on a change in pull request #3040: riscv/esp32c3: Add ESP32-C3 WLAN netcard driver

Posted by GitBox <gi...@apache.org>.
donghengqaz commented on a change in pull request #3040:
URL: https://github.com/apache/incubator-nuttx/pull/3040#discussion_r594079582



##########
File path: arch/risc-v/src/esp32c3/esp32c3_irq.c
##########
@@ -166,6 +189,52 @@ void up_disable_irq(int cpuint)
   leave_critical_section(irqstate);
 }
 
+/****************************************************************************
+ * Name: esp32c3_bind_irq
+ *
+ * Description:
+ *   Bind IRQ and resource with given parameters.
+ *
+ * Input Parameters:
+ *   cpuint    - CPU interrupt ID
+ *   periphid  - Peripheral ID
+ *   prio      - Interrupt priority
+ *   flags     - Interrupt flags
+ *
+ * Returned Value:
+ *   Allocated CPU interrupt on success, a negated error on failure.
+ *
+ ****************************************************************************/
+
+int esp32c3_bind_irq(uint8_t cpuint, uint8_t periphid, uint8_t prio,

Review comment:
       Yes, I will modify the `esp32c3_irq_request`, and let it call `esp32c3_bind_irq` with allocated CPU int ID.




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



[GitHub] [incubator-nuttx] acassis commented on a change in pull request #3040: riscv/esp32c3: Add ESP32-C3 WLAN netcard driver

Posted by GitBox <gi...@apache.org>.
acassis commented on a change in pull request #3040:
URL: https://github.com/apache/incubator-nuttx/pull/3040#discussion_r593115733



##########
File path: arch/risc-v/src/esp32c3/Kconfig
##########
@@ -283,4 +297,83 @@ endif # ESP32C3_UART1
 
 endmenu
 
+menu "Real-Time Timer"
+	depends on ESP32C3_RT_TIMER
+
+config ESP32C3_RT_TIMER_TASK_NAME
+	string "Timer task name"
+	default "rt_timer"
+
+config ESP32C3_RT_TIMER_TASK_PRIORITY
+	int "Timer task priority"
+	default 223 # Lower than high priority workqueue
+
+config ESP32C3_RT_TIMER_TASK_STACK_SIZE
+	int "Timer task stack size"
+	default 2048
+
+endmenu # Real-Time Timer
+
+menu "WiFi configuration"
+	depends on ESP32C3_WIRELESS
+
+config ESP32C3_WIFI_STATIC_RXBUF_NUM
+    int "WiFi static RX buffer number"
+	default 10
+
+config ESP32C3_WIFI_DYNAMIC_RXBUF_NUM
+    int "WiFi dynamic RX buffer number"
+	default 32
+
+config ESP32C3_WIFI_DYNAMIC_TXBUF_NUM
+    int "WiFi dynamic TX buffer number"
+	default 32
+
+config ESP32C3_WIFI_TX_AMPDU
+	bool "WiFi TX AMPDU"
+	default y
+
+config ESP32C3_WIFI_RX_AMPDU
+	bool "WiFi RX AMPDU"
+	default y
+
+config ESP32C3_WIFI_RXBA_AMPDU_WZ
+    int "WiFi RX BA AMPDU windown size"
+	default 6
+
+config ESP32C3_WLAN_RXBUF_NUM
+	int "WLAN netcard RX buffer number"
+	default 16
+
+config ESP32C3_WIFI_CONNECT_TIMEOUT
+	int "Connect timeout by second"
+	default 10
+	help
+		Max waiting time of connecting to AP.
+
+config ESP32C3_WIFI_SAVE_PARAM
+	bool "Save WiFi Parameters"

Review comment:
       @donghengqaz please fill all the field [here](https://github.com/apache/incubator-nuttx/pull/3040#issue-591426880)




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



[GitHub] [incubator-nuttx] gustavonihei commented on a change in pull request #3040: riscv/esp32c3: Add ESP32-C3 WLAN netcard driver

Posted by GitBox <gi...@apache.org>.
gustavonihei commented on a change in pull request #3040:
URL: https://github.com/apache/incubator-nuttx/pull/3040#discussion_r594700399



##########
File path: arch/risc-v/src/esp32c3/esp32c3_wifi_adapter.h
##########
@@ -0,0 +1,242 @@
+/****************************************************************************
+ * arch/risc-v/src/esp32c3/esp32c3_wifi_adapter.h
+ *
+ * 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.
+ *
+ ****************************************************************************/
+
+#ifndef __ARCH_RISCV_SRC_ESP32C3_ESP32C3_WIFI_ADAPTER_H
+#define __ARCH_RISCV_SRC_ESP32C3_ESP32C3_WIFI_ADAPTER_H
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <sys/types.h>
+
+#ifndef __ASSEMBLY__
+
+#undef EXTERN
+#if defined(__cplusplus)
+#define EXTERN extern "C"
+extern "C"
+{
+#else
+#define EXTERN extern
+#endif
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+/* WiFi event ID */
+
+enum wifi_adpt_evt_e
+{
+  WIFI_ADPT_EVT_STA_START = 0,
+  WIFI_ADPT_EVT_STA_CONNECT,
+  WIFI_ADPT_EVT_STA_DISCONNECT,
+  WIFI_ADPT_EVT_STA_AUTHMODE_CHANGE,
+  WIFI_ADPT_EVT_STA_STOP,
+  WIFI_ADPT_EVT_MAX,
+};
+
+/* WiFi event callback function */
+
+typedef void (*wifi_evt_cb_t)(void *p);
+
+typedef void (* wifi_tx_done_cb_t)(uint8_t ifidx, uint8_t *data,
+                                   uint16_t *len, bool txstatus);
+
+/****************************************************************************
+ * Public Function Prototypes
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: esp_wifi_adapter_init
+ *
+ * Description:
+ *   Initialize ESP32 WiFi adapter
+ *
+ * Input Parameters:
+ *   None
+ *
+ * Returned Value:
+ *   0 if success or -1 if fail
+ *
+ ****************************************************************************/
+
+int esp_wifi_adapter_init(void);
+
+/****************************************************************************
+ * Name: esp_wifi_notify_subscribe
+ *
+ * Description:
+ *   Enable event notification
+ *
+ * Input Parameters:
+ *   pid   - Task PID
+ *   event - Signal event data pointer
+ *
+ * Returned Value:
+ *   0 if success or -1 if fail
+ *
+ ****************************************************************************/
+
+int esp_wifi_notify_subscribe(pid_t pid, FAR struct sigevent *event);
+
+/****************************************************************************
+ * Name: esp_wifi_sta_send_data
+ *
+ * Description:
+ *   Use WiFi station interface to send 802.3 frame
+ *
+ * Input Parameters:
+ *   pbuf - Packet buffer pointer
+ *   len  - Packet length
+ *
+ * Returned Value:
+ *   0 if success or others if fail
+ *
+ ****************************************************************************/
+
+int esp_wifi_sta_send_data(void *pbuf, uint32_t len);
+
+/****************************************************************************
+ * Name: esp_wifi_sta_register_recv_cb
+ *
+ * Description:
+ *   Register WiFi receive packet callback function
+ *
+ * Input Parameters:
+ *   input_cb - Receive callback function
+ *
+ * Returned Value:
+ *   0 if success or others if fail
+ *
+ ****************************************************************************/
+
+int esp_wifi_sta_register_recv_cb(int (*recv_cb)(void *buffer,
+                                                 uint16_t len,
+                                                 void *eb));
+
+/****************************************************************************
+ * Name: esp_wifi_sta_read_mac
+ *
+ * Description:
+ *   Read station interface MAC address from efuse
+ *
+ * Input Parameters:
+ *   mac  - MAC address buffer pointer
+ *
+ * Returned Value:
+ *   0 if success or -1 if fail
+ *
+ ****************************************************************************/
+
+int esp_wifi_sta_read_mac(uint8_t *mac);
+
+/****************************************************************************
+ * Name: esp_wifi_free_eb
+ *
+ * Description:
+ *   Free WiFi receive callback input eb pointer
+ *
+ * Input Parameters:
+ *   eb - WiFi receive callback input eb pointer
+ *
+ * Returned Value:
+ *   None
+ *
+ ****************************************************************************/
+
+void esp_wifi_free_eb(void *eb);
+
+/****************************************************************************
+ * Name: esp_wifi_set_password
+ *
+ * Description:
+ *   Set WiFi password
+ *
+ * Input Parameters:
+ *   pdata - Password buffer pointer
+ *   len   - Password length
+ *
+ * Returned Value:
+ *   0 if success or -1 if fail
+ *
+ ****************************************************************************/
+
+int esp_wifi_set_password(const uint8_t *pdata, uint8_t len);
+
+/****************************************************************************
+ * Name: esp_wifi_set_ssid
+ *
+ * Description:
+ *   Set WiFi SSID

Review comment:
       ```suggestion
    *   Set Wi-Fi SSID
   ```




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



[GitHub] [incubator-nuttx] gustavonihei commented on a change in pull request #3040: riscv/esp32c3: Add ESP32-C3 WLAN netcard driver

Posted by GitBox <gi...@apache.org>.
gustavonihei commented on a change in pull request #3040:
URL: https://github.com/apache/incubator-nuttx/pull/3040#discussion_r594699749



##########
File path: arch/risc-v/src/esp32c3/Kconfig
##########
@@ -283,4 +297,84 @@ endif # ESP32C3_UART1
 
 endmenu
 
+menu "Real-Time Timer"
+	depends on ESP32C3_RT_TIMER
+
+config ESP32C3_RT_TIMER_TASK_NAME
+	string "Timer task name"
+	default "rt_timer"
+
+config ESP32C3_RT_TIMER_TASK_PRIORITY
+	int "Timer task priority"
+	default 223 # Lower than high priority workqueue
+
+config ESP32C3_RT_TIMER_TASK_STACK_SIZE
+	int "Timer task stack size"
+	default 2048
+
+endmenu # Real-Time Timer
+
+menu "WiFi configuration"
+	depends on ESP32C3_WIRELESS
+
+config ESP32C3_WIFI_STATIC_RXBUF_NUM
+    int "WiFi static RX buffer number"
+	default 10
+
+config ESP32C3_WIFI_DYNAMIC_RXBUF_NUM
+    int "WiFi dynamic RX buffer number"
+	default 32
+
+config ESP32C3_WIFI_DYNAMIC_TXBUF_NUM
+    int "WiFi dynamic TX buffer number"
+	default 32
+
+config ESP32C3_WIFI_TX_AMPDU
+	bool "WiFi TX AMPDU"
+	default y
+
+config ESP32C3_WIFI_RX_AMPDU
+	bool "WiFi RX AMPDU"
+	default y
+
+config ESP32C3_WIFI_RXBA_AMPDU_WZ
+    int "WiFi RX BA AMPDU windown size"
+	default 6
+
+config ESP32C3_WLAN_RXBUF_NUM
+	int "WLAN netcard RX buffer number"
+	default 16
+
+config ESP32C3_WIFI_CONNECT_TIMEOUT
+	int "Connect timeout by second"
+	default 10
+	help
+		Max waiting time of connecting to AP.
+
+config ESP32C3_WIFI_SAVE_PARAM
+	bool "Save WiFi Parameters"
+	default n
+	depends on !DISABLE_MOUNTPOINT
+	help
+		If you enable this option, WiFi adapter parameters will be saved
+		into the file system instead of computing them each time.
+
+		These parameters mainly contains:
+		  - SSID
+		  - Password
+		  - BSSID
+		  - PMK(compute when connecting)
+		  - Author mode
+		  - MAC address
+		  - WiFi hardware configuration parameters

Review comment:
       ```suggestion
   		  - Wi-Fi hardware configuration parameters
   ```




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



[GitHub] [incubator-nuttx] gustavonihei commented on a change in pull request #3040: riscv/esp32c3: Add ESP32-C3 WLAN netcard driver

Posted by GitBox <gi...@apache.org>.
gustavonihei commented on a change in pull request #3040:
URL: https://github.com/apache/incubator-nuttx/pull/3040#discussion_r594700324



##########
File path: arch/risc-v/src/esp32c3/esp32c3_wifi_adapter.h
##########
@@ -0,0 +1,242 @@
+/****************************************************************************
+ * arch/risc-v/src/esp32c3/esp32c3_wifi_adapter.h
+ *
+ * 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.
+ *
+ ****************************************************************************/
+
+#ifndef __ARCH_RISCV_SRC_ESP32C3_ESP32C3_WIFI_ADAPTER_H
+#define __ARCH_RISCV_SRC_ESP32C3_ESP32C3_WIFI_ADAPTER_H
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <sys/types.h>
+
+#ifndef __ASSEMBLY__
+
+#undef EXTERN
+#if defined(__cplusplus)
+#define EXTERN extern "C"
+extern "C"
+{
+#else
+#define EXTERN extern
+#endif
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+/* WiFi event ID */
+
+enum wifi_adpt_evt_e
+{
+  WIFI_ADPT_EVT_STA_START = 0,
+  WIFI_ADPT_EVT_STA_CONNECT,
+  WIFI_ADPT_EVT_STA_DISCONNECT,
+  WIFI_ADPT_EVT_STA_AUTHMODE_CHANGE,
+  WIFI_ADPT_EVT_STA_STOP,
+  WIFI_ADPT_EVT_MAX,
+};
+
+/* WiFi event callback function */
+
+typedef void (*wifi_evt_cb_t)(void *p);
+
+typedef void (* wifi_tx_done_cb_t)(uint8_t ifidx, uint8_t *data,
+                                   uint16_t *len, bool txstatus);
+
+/****************************************************************************
+ * Public Function Prototypes
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: esp_wifi_adapter_init
+ *
+ * Description:
+ *   Initialize ESP32 WiFi adapter
+ *
+ * Input Parameters:
+ *   None
+ *
+ * Returned Value:
+ *   0 if success or -1 if fail
+ *
+ ****************************************************************************/
+
+int esp_wifi_adapter_init(void);
+
+/****************************************************************************
+ * Name: esp_wifi_notify_subscribe
+ *
+ * Description:
+ *   Enable event notification
+ *
+ * Input Parameters:
+ *   pid   - Task PID
+ *   event - Signal event data pointer
+ *
+ * Returned Value:
+ *   0 if success or -1 if fail
+ *
+ ****************************************************************************/
+
+int esp_wifi_notify_subscribe(pid_t pid, FAR struct sigevent *event);
+
+/****************************************************************************
+ * Name: esp_wifi_sta_send_data
+ *
+ * Description:
+ *   Use WiFi station interface to send 802.3 frame
+ *
+ * Input Parameters:
+ *   pbuf - Packet buffer pointer
+ *   len  - Packet length
+ *
+ * Returned Value:
+ *   0 if success or others if fail
+ *
+ ****************************************************************************/
+
+int esp_wifi_sta_send_data(void *pbuf, uint32_t len);
+
+/****************************************************************************
+ * Name: esp_wifi_sta_register_recv_cb
+ *
+ * Description:
+ *   Register WiFi receive packet callback function
+ *
+ * Input Parameters:
+ *   input_cb - Receive callback function
+ *
+ * Returned Value:
+ *   0 if success or others if fail
+ *
+ ****************************************************************************/
+
+int esp_wifi_sta_register_recv_cb(int (*recv_cb)(void *buffer,
+                                                 uint16_t len,
+                                                 void *eb));
+
+/****************************************************************************
+ * Name: esp_wifi_sta_read_mac
+ *
+ * Description:
+ *   Read station interface MAC address from efuse
+ *
+ * Input Parameters:
+ *   mac  - MAC address buffer pointer
+ *
+ * Returned Value:
+ *   0 if success or -1 if fail
+ *
+ ****************************************************************************/
+
+int esp_wifi_sta_read_mac(uint8_t *mac);
+
+/****************************************************************************
+ * Name: esp_wifi_free_eb
+ *
+ * Description:
+ *   Free WiFi receive callback input eb pointer
+ *
+ * Input Parameters:
+ *   eb - WiFi receive callback input eb pointer
+ *
+ * Returned Value:
+ *   None
+ *
+ ****************************************************************************/
+
+void esp_wifi_free_eb(void *eb);
+
+/****************************************************************************
+ * Name: esp_wifi_set_password
+ *
+ * Description:
+ *   Set WiFi password
+ *
+ * Input Parameters:
+ *   pdata - Password buffer pointer
+ *   len   - Password length
+ *
+ * Returned Value:
+ *   0 if success or -1 if fail
+ *
+ ****************************************************************************/
+
+int esp_wifi_set_password(const uint8_t *pdata, uint8_t len);
+
+/****************************************************************************
+ * Name: esp_wifi_set_ssid
+ *
+ * Description:
+ *   Set WiFi SSID
+ *
+ * Input Parameters:
+ *   pdata - SSID buffer pointer
+ *   len   - SSID length
+ *
+ * Returned Value:
+ *   0 if success or -1 if fail
+ *
+ ****************************************************************************/
+
+int esp_wifi_set_ssid(const uint8_t *pdata, uint8_t len);
+
+/****************************************************************************
+ * Name: esp_wifi_connect_internal
+ *
+ * Description:
+ *   Trigger WiFi connection action

Review comment:
       ```suggestion
    *   Trigger Wi-Fi connection action
   ```




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



[GitHub] [incubator-nuttx] gustavonihei commented on a change in pull request #3040: riscv/esp32c3: Add ESP32-C3 WLAN netcard driver

Posted by GitBox <gi...@apache.org>.
gustavonihei commented on a change in pull request #3040:
URL: https://github.com/apache/incubator-nuttx/pull/3040#discussion_r594699190



##########
File path: arch/risc-v/src/esp32c3/Kconfig
##########
@@ -283,4 +297,84 @@ endif # ESP32C3_UART1
 
 endmenu
 
+menu "Real-Time Timer"
+	depends on ESP32C3_RT_TIMER
+
+config ESP32C3_RT_TIMER_TASK_NAME
+	string "Timer task name"
+	default "rt_timer"
+
+config ESP32C3_RT_TIMER_TASK_PRIORITY
+	int "Timer task priority"
+	default 223 # Lower than high priority workqueue
+
+config ESP32C3_RT_TIMER_TASK_STACK_SIZE
+	int "Timer task stack size"
+	default 2048
+
+endmenu # Real-Time Timer
+
+menu "WiFi configuration"
+	depends on ESP32C3_WIRELESS
+
+config ESP32C3_WIFI_STATIC_RXBUF_NUM
+    int "WiFi static RX buffer number"
+	default 10
+
+config ESP32C3_WIFI_DYNAMIC_RXBUF_NUM
+    int "WiFi dynamic RX buffer number"
+	default 32
+
+config ESP32C3_WIFI_DYNAMIC_TXBUF_NUM
+    int "WiFi dynamic TX buffer number"
+	default 32
+
+config ESP32C3_WIFI_TX_AMPDU
+	bool "WiFi TX AMPDU"
+	default y
+
+config ESP32C3_WIFI_RX_AMPDU
+	bool "WiFi RX AMPDU"
+	default y
+
+config ESP32C3_WIFI_RXBA_AMPDU_WZ
+    int "WiFi RX BA AMPDU windown size"
+	default 6
+
+config ESP32C3_WLAN_RXBUF_NUM
+	int "WLAN netcard RX buffer number"
+	default 16
+
+config ESP32C3_WIFI_CONNECT_TIMEOUT
+	int "Connect timeout by second"
+	default 10
+	help
+		Max waiting time of connecting to AP.
+
+config ESP32C3_WIFI_SAVE_PARAM
+	bool "Save WiFi Parameters"

Review comment:
       ```suggestion
   	bool "Save Wi-Fi Parameters"
   ```




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



[GitHub] [incubator-nuttx] gustavonihei commented on a change in pull request #3040: riscv/esp32c3: Add ESP32-C3 WLAN netcard driver

Posted by GitBox <gi...@apache.org>.
gustavonihei commented on a change in pull request #3040:
URL: https://github.com/apache/incubator-nuttx/pull/3040#discussion_r593125978



##########
File path: arch/risc-v/src/esp32c3/esp32c3_wifi_adapter.h
##########
@@ -0,0 +1,242 @@
+/****************************************************************************
+ * arch/risc-v/src/esp32c3/esp32c3_wifi_adapter.h
+ *
+ * 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.
+ *
+ ****************************************************************************/
+
+#ifndef __ARCH_RISCV_SRC_ESP32C3_ESP32C3_WIFI_ADAPTER_H
+#define __ARCH_RISCV_SRC_ESP32C3_ESP32C3_WIFI_ADAPTER_H
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <sys/types.h>
+
+#ifndef __ASSEMBLY__
+
+#undef EXTERN
+#if defined(__cplusplus)
+#define EXTERN extern "C"
+extern "C"
+{
+#else
+#define EXTERN extern
+#endif
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+/* WiFi event ID */
+
+enum wifi_adpt_evt_e
+{
+  WIFI_ADPT_EVT_STA_START = 0,
+  WIFI_ADPT_EVT_STA_CONNECT,
+  WIFI_ADPT_EVT_STA_DISCONNECT,
+  WIFI_ADPT_EVT_STA_AUTHMODE_CHANGE,
+  WIFI_ADPT_EVT_STA_STOP,
+  WIFI_ADPT_EVT_MAX,
+};
+
+/* WiFi event callback function */
+
+typedef void (*wifi_evt_cb_t)(void *p);
+
+typedef void (* wifi_tx_done_cb_t)(uint8_t ifidx, uint8_t *data,
+                                   uint16_t *len, bool txstatus);
+
+/****************************************************************************
+ * Public Function Prototypes
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: esp_wifi_adapter_init
+ *
+ * Description:
+ *   Initialize ESP32 WiFi adapter

Review comment:
       In documentation, we should write Wi-Fi, which is the correct spelling.
   Could you please fix every other occurrence?




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



[GitHub] [incubator-nuttx] gustavonihei commented on a change in pull request #3040: riscv/esp32c3: Add ESP32-C3 WLAN netcard driver

Posted by GitBox <gi...@apache.org>.
gustavonihei commented on a change in pull request #3040:
URL: https://github.com/apache/incubator-nuttx/pull/3040#discussion_r594698142



##########
File path: arch/risc-v/src/esp32c3/Kconfig
##########
@@ -283,4 +297,84 @@ endif # ESP32C3_UART1
 
 endmenu
 
+menu "Real-Time Timer"
+	depends on ESP32C3_RT_TIMER
+
+config ESP32C3_RT_TIMER_TASK_NAME
+	string "Timer task name"
+	default "rt_timer"
+
+config ESP32C3_RT_TIMER_TASK_PRIORITY
+	int "Timer task priority"
+	default 223 # Lower than high priority workqueue
+
+config ESP32C3_RT_TIMER_TASK_STACK_SIZE
+	int "Timer task stack size"
+	default 2048
+
+endmenu # Real-Time Timer
+
+menu "WiFi configuration"
+	depends on ESP32C3_WIRELESS
+
+config ESP32C3_WIFI_STATIC_RXBUF_NUM
+    int "WiFi static RX buffer number"

Review comment:
       ```suggestion
         int "Wi-Fi static RX buffer number"
   ```
   nit: Alignment issue and Wi-Fi spelling

##########
File path: arch/risc-v/src/esp32c3/Kconfig
##########
@@ -283,4 +297,84 @@ endif # ESP32C3_UART1
 
 endmenu
 
+menu "Real-Time Timer"
+	depends on ESP32C3_RT_TIMER
+
+config ESP32C3_RT_TIMER_TASK_NAME
+	string "Timer task name"
+	default "rt_timer"
+
+config ESP32C3_RT_TIMER_TASK_PRIORITY
+	int "Timer task priority"
+	default 223 # Lower than high priority workqueue
+
+config ESP32C3_RT_TIMER_TASK_STACK_SIZE
+	int "Timer task stack size"
+	default 2048
+
+endmenu # Real-Time Timer
+
+menu "WiFi configuration"
+	depends on ESP32C3_WIRELESS
+
+config ESP32C3_WIFI_STATIC_RXBUF_NUM
+    int "WiFi static RX buffer number"
+	default 10
+
+config ESP32C3_WIFI_DYNAMIC_RXBUF_NUM
+    int "WiFi dynamic RX buffer number"

Review comment:
       ```suggestion
         int "Wi-Fi dynamic RX buffer number"
   ```
   nit: Alignment issue and Wi-Fi spelling

##########
File path: arch/risc-v/src/esp32c3/Kconfig
##########
@@ -283,4 +297,84 @@ endif # ESP32C3_UART1
 
 endmenu
 
+menu "Real-Time Timer"
+	depends on ESP32C3_RT_TIMER
+
+config ESP32C3_RT_TIMER_TASK_NAME
+	string "Timer task name"
+	default "rt_timer"
+
+config ESP32C3_RT_TIMER_TASK_PRIORITY
+	int "Timer task priority"
+	default 223 # Lower than high priority workqueue
+
+config ESP32C3_RT_TIMER_TASK_STACK_SIZE
+	int "Timer task stack size"
+	default 2048
+
+endmenu # Real-Time Timer
+
+menu "WiFi configuration"
+	depends on ESP32C3_WIRELESS
+
+config ESP32C3_WIFI_STATIC_RXBUF_NUM
+    int "WiFi static RX buffer number"
+	default 10
+
+config ESP32C3_WIFI_DYNAMIC_RXBUF_NUM
+    int "WiFi dynamic RX buffer number"
+	default 32
+
+config ESP32C3_WIFI_DYNAMIC_TXBUF_NUM
+    int "WiFi dynamic TX buffer number"

Review comment:
       ```suggestion
         int "Wi-Fi dynamic TX buffer number"
   ```
   nit: Alignment issue and Wi-Fi spelling




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



[GitHub] [incubator-nuttx] gustavonihei commented on a change in pull request #3040: riscv/esp32c3: Add ESP32-C3 WLAN netcard driver

Posted by GitBox <gi...@apache.org>.
gustavonihei commented on a change in pull request #3040:
URL: https://github.com/apache/incubator-nuttx/pull/3040#discussion_r593126262



##########
File path: arch/risc-v/src/esp32c3/esp32c3_rt_timer.h
##########
@@ -0,0 +1,206 @@
+/****************************************************************************
+ * arch/risc-v/src/esp32c3/esp32c3_rt_timer.h
+ *
+ * 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.
+ *
+ ****************************************************************************/
+
+#ifndef __ARCH_RISCV_SRC_ESP32C3_ESP32C3_RT_TIMER_H
+#define __ARCH_RISCV_SRC_ESP32C3_ESP32C3_RT_TIMER_H
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <stdint.h>
+#include <sys/types.h>
+#include <nuttx/list.h>
+
+#define RT_TIMER_NOFLAGS    (0)         /* Timer support no feature */
+#define RT_TIMER_REPEAT     (1 << 0)    /* Timer is repeat */
+
+/**
+ * RT timer state
+ */
+
+enum rt_timer_state_e
+{
+  RT_TIMER_IDLE,            /* Timer is not counting */
+  RT_TIMER_READY,           /* Timer is counting */
+  RT_TIMER_TIMEOUT,         /* Timer is timeout */
+  RT_TIMER_DELETE           /* Timer is to be delete */
+};
+
+/**
+ * RT timer data structure
+ */
+
+struct rt_timer_s
+{
+  uint64_t timeout;             /* Timeout value */
+  uint64_t alarm;               /* Timeout period */
+  void (*callback)(void *arg);  /* Callback function */
+  void *arg;                    /* Private data */
+  uint16_t flags;               /* Support feature */
+  enum rt_timer_state_e state;  /* Mark if timer is started */
+  struct list_node list;        /* Working list */
+};
+
+/**
+ * RT timer creation arguments data structure
+ */
+
+struct rt_timer_args_s
+{
+  void (*callback)(void *arg);  /* Callback function */
+  void *arg;                    /* Private data */
+};
+
+#undef EXTERN
+#if defined(__cplusplus)
+#define EXTERN extern "C"
+extern "C"
+{
+#else
+#define EXTERN extern
+#endif
+
+/****************************************************************************
+ * Name: rt_timer_create
+ *
+ * Description:
+ *   Create RT timer by into timer creation arguments
+ *
+ * Input Parameters:
+ *   args         - Input RT timer creation arguments
+ *   timer_handle - Output RT timer handle pointer
+ *
+ * Returned Value:
+ *   0 is returned on success. Otherwise, a negated errno value is returned.
+ *
+ ****************************************************************************/
+
+int rt_timer_create(const struct rt_timer_args_s *args,
+                    struct rt_timer_s **timer_handle);
+
+/****************************************************************************
+ * Name: rt_timer_start
+ *
+ * Description:
+ *   Start RT timer.
+ *
+ * Input Parameters:
+ *   timer   - RT timer pointer
+ *   timeout - Timeout value
+ *   repeat  - If the timer run repeat
+ *
+ * Returned Value:
+ *   None
+ *
+ ****************************************************************************/
+
+void rt_timer_start(struct rt_timer_s *timer,
+                    uint64_t timeout,
+                    bool repeat);
+
+/****************************************************************************
+ * Name: rt_timer_stop
+ *
+ * Description:
+ *   Stop RT timer.
+ *
+ * Input Parameters:
+ *   timer - RT timer pointer
+ *
+ * Returned Value:
+ *   None
+ *
+ ****************************************************************************/
+
+void rt_timer_stop(struct rt_timer_s *timer);
+
+/****************************************************************************
+ * Name: rt_timer_delete
+ *
+ * Description:
+ *   Stop and deleta RT timer.

Review comment:
       ```suggestion
    *   Stop and delete RT timer.
   ```




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



[GitHub] [incubator-nuttx] gustavonihei commented on a change in pull request #3040: riscv/esp32c3: Add ESP32-C3 WLAN netcard driver

Posted by GitBox <gi...@apache.org>.
gustavonihei commented on a change in pull request #3040:
URL: https://github.com/apache/incubator-nuttx/pull/3040#discussion_r594697787



##########
File path: arch/risc-v/src/esp32c3/Kconfig
##########
@@ -283,4 +297,84 @@ endif # ESP32C3_UART1
 
 endmenu
 
+menu "Real-Time Timer"
+	depends on ESP32C3_RT_TIMER
+
+config ESP32C3_RT_TIMER_TASK_NAME
+	string "Timer task name"
+	default "rt_timer"
+
+config ESP32C3_RT_TIMER_TASK_PRIORITY
+	int "Timer task priority"
+	default 223 # Lower than high priority workqueue
+
+config ESP32C3_RT_TIMER_TASK_STACK_SIZE
+	int "Timer task stack size"
+	default 2048
+
+endmenu # Real-Time Timer
+
+menu "WiFi configuration"
+	depends on ESP32C3_WIRELESS
+
+config ESP32C3_WIFI_STATIC_RXBUF_NUM
+    int "WiFi static RX buffer number"
+	default 10
+
+config ESP32C3_WIFI_DYNAMIC_RXBUF_NUM
+    int "WiFi dynamic RX buffer number"
+	default 32
+
+config ESP32C3_WIFI_DYNAMIC_TXBUF_NUM
+    int "WiFi dynamic TX buffer number"
+	default 32
+
+config ESP32C3_WIFI_TX_AMPDU
+	bool "WiFi TX AMPDU"
+	default y
+
+config ESP32C3_WIFI_RX_AMPDU
+	bool "WiFi RX AMPDU"
+	default y
+
+config ESP32C3_WIFI_RXBA_AMPDU_WZ
+    int "WiFi RX BA AMPDU windown size"

Review comment:
       ```suggestion
         int "Wi-Fi RX BA AMPDU windown size"
   ```
   nit: Alignment issue and Wi-Fi spelling




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



[GitHub] [incubator-nuttx] acassis merged pull request #3040: riscv/esp32c3: Add ESP32-C3 WLAN netcard driver

Posted by GitBox <gi...@apache.org>.
acassis merged pull request #3040:
URL: https://github.com/apache/incubator-nuttx/pull/3040


   


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



[GitHub] [incubator-nuttx] gustavonihei commented on a change in pull request #3040: riscv/esp32c3: Add ESP32-C3 WLAN netcard driver

Posted by GitBox <gi...@apache.org>.
gustavonihei commented on a change in pull request #3040:
URL: https://github.com/apache/incubator-nuttx/pull/3040#discussion_r593126352



##########
File path: arch/risc-v/src/esp32c3/esp32c3_rt_timer.h
##########
@@ -0,0 +1,206 @@
+/****************************************************************************
+ * arch/risc-v/src/esp32c3/esp32c3_rt_timer.h
+ *
+ * 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.
+ *
+ ****************************************************************************/
+
+#ifndef __ARCH_RISCV_SRC_ESP32C3_ESP32C3_RT_TIMER_H
+#define __ARCH_RISCV_SRC_ESP32C3_ESP32C3_RT_TIMER_H
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <stdint.h>
+#include <sys/types.h>
+#include <nuttx/list.h>
+
+#define RT_TIMER_NOFLAGS    (0)         /* Timer support no feature */
+#define RT_TIMER_REPEAT     (1 << 0)    /* Timer is repeat */
+
+/**
+ * RT timer state
+ */
+
+enum rt_timer_state_e
+{
+  RT_TIMER_IDLE,            /* Timer is not counting */
+  RT_TIMER_READY,           /* Timer is counting */
+  RT_TIMER_TIMEOUT,         /* Timer is timeout */
+  RT_TIMER_DELETE           /* Timer is to be delete */
+};
+
+/**
+ * RT timer data structure
+ */
+
+struct rt_timer_s
+{
+  uint64_t timeout;             /* Timeout value */
+  uint64_t alarm;               /* Timeout period */
+  void (*callback)(void *arg);  /* Callback function */
+  void *arg;                    /* Private data */
+  uint16_t flags;               /* Support feature */
+  enum rt_timer_state_e state;  /* Mark if timer is started */
+  struct list_node list;        /* Working list */
+};
+
+/**
+ * RT timer creation arguments data structure
+ */
+
+struct rt_timer_args_s
+{
+  void (*callback)(void *arg);  /* Callback function */
+  void *arg;                    /* Private data */
+};
+
+#undef EXTERN
+#if defined(__cplusplus)
+#define EXTERN extern "C"
+extern "C"
+{
+#else
+#define EXTERN extern
+#endif
+
+/****************************************************************************
+ * Name: rt_timer_create
+ *
+ * Description:
+ *   Create RT timer by into timer creation arguments
+ *
+ * Input Parameters:
+ *   args         - Input RT timer creation arguments
+ *   timer_handle - Output RT timer handle pointer
+ *
+ * Returned Value:
+ *   0 is returned on success. Otherwise, a negated errno value is returned.
+ *
+ ****************************************************************************/
+
+int rt_timer_create(const struct rt_timer_args_s *args,
+                    struct rt_timer_s **timer_handle);
+
+/****************************************************************************
+ * Name: rt_timer_start
+ *
+ * Description:
+ *   Start RT timer.
+ *
+ * Input Parameters:
+ *   timer   - RT timer pointer
+ *   timeout - Timeout value
+ *   repeat  - If the timer run repeat
+ *
+ * Returned Value:
+ *   None
+ *
+ ****************************************************************************/
+
+void rt_timer_start(struct rt_timer_s *timer,
+                    uint64_t timeout,
+                    bool repeat);
+
+/****************************************************************************
+ * Name: rt_timer_stop
+ *
+ * Description:
+ *   Stop RT timer.
+ *
+ * Input Parameters:
+ *   timer - RT timer pointer
+ *
+ * Returned Value:
+ *   None
+ *
+ ****************************************************************************/
+
+void rt_timer_stop(struct rt_timer_s *timer);
+
+/****************************************************************************
+ * Name: rt_timer_delete
+ *
+ * Description:
+ *   Stop and deleta RT timer.
+ *
+ * Input Parameters:
+ *   timer - RT timer pointer
+ *
+ * Returned Value:
+ *   None
+ *
+ ****************************************************************************/
+
+void rt_timer_delete(struct rt_timer_s *timer);
+
+/****************************************************************************
+ * Name: rt_timer_time_us
+ *
+ * Description:
+ *   Get time of RT timer by micro second.

Review comment:
       ```suggestion
    *   Get time of RT timer by microsecond.
   ```




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



[GitHub] [incubator-nuttx] gustavonihei commented on a change in pull request #3040: riscv/esp32c3: Add ESP32-C3 WLAN netcard driver

Posted by GitBox <gi...@apache.org>.
gustavonihei commented on a change in pull request #3040:
URL: https://github.com/apache/incubator-nuttx/pull/3040#discussion_r594698797



##########
File path: arch/risc-v/src/esp32c3/Kconfig
##########
@@ -283,4 +297,84 @@ endif # ESP32C3_UART1
 
 endmenu
 
+menu "Real-Time Timer"
+	depends on ESP32C3_RT_TIMER
+
+config ESP32C3_RT_TIMER_TASK_NAME
+	string "Timer task name"
+	default "rt_timer"
+
+config ESP32C3_RT_TIMER_TASK_PRIORITY
+	int "Timer task priority"
+	default 223 # Lower than high priority workqueue
+
+config ESP32C3_RT_TIMER_TASK_STACK_SIZE
+	int "Timer task stack size"
+	default 2048
+
+endmenu # Real-Time Timer
+
+menu "WiFi configuration"
+	depends on ESP32C3_WIRELESS
+
+config ESP32C3_WIFI_STATIC_RXBUF_NUM
+    int "WiFi static RX buffer number"
+	default 10
+
+config ESP32C3_WIFI_DYNAMIC_RXBUF_NUM
+    int "WiFi dynamic RX buffer number"
+	default 32
+
+config ESP32C3_WIFI_DYNAMIC_TXBUF_NUM
+    int "WiFi dynamic TX buffer number"
+	default 32
+
+config ESP32C3_WIFI_TX_AMPDU
+	bool "WiFi TX AMPDU"

Review comment:
       ```suggestion
   	bool "WiiFi TX AMPDU"
   ```
   nit: Wi-Fi spelling




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



[GitHub] [incubator-nuttx] acassis commented on a change in pull request #3040: riscv/esp32c3: Add ESP32-C3 WLAN netcard driver

Posted by GitBox <gi...@apache.org>.
acassis commented on a change in pull request #3040:
URL: https://github.com/apache/incubator-nuttx/pull/3040#discussion_r593115273



##########
File path: arch/risc-v/src/esp32c3/Kconfig
##########
@@ -283,4 +297,83 @@ endif # ESP32C3_UART1
 
 endmenu
 
+menu "Real-Time Timer"
+	depends on ESP32C3_RT_TIMER
+
+config ESP32C3_RT_TIMER_TASK_NAME
+	string "Timer task name"
+	default "rt_timer"
+
+config ESP32C3_RT_TIMER_TASK_PRIORITY
+	int "Timer task priority"
+	default 223 # Lower than high priority workqueue
+
+config ESP32C3_RT_TIMER_TASK_STACK_SIZE
+	int "Timer task stack size"
+	default 2048
+
+endmenu # Real-Time Timer
+
+menu "WiFi configuration"
+	depends on ESP32C3_WIRELESS
+
+config ESP32C3_WIFI_STATIC_RXBUF_NUM
+    int "WiFi static RX buffer number"
+	default 10
+
+config ESP32C3_WIFI_DYNAMIC_RXBUF_NUM
+    int "WiFi dynamic RX buffer number"
+	default 32
+
+config ESP32C3_WIFI_DYNAMIC_TXBUF_NUM
+    int "WiFi dynamic TX buffer number"
+	default 32
+
+config ESP32C3_WIFI_TX_AMPDU
+	bool "WiFi TX AMPDU"
+	default y
+
+config ESP32C3_WIFI_RX_AMPDU
+	bool "WiFi RX AMPDU"
+	default y
+
+config ESP32C3_WIFI_RXBA_AMPDU_WZ
+    int "WiFi RX BA AMPDU windown size"
+	default 6
+
+config ESP32C3_WLAN_RXBUF_NUM
+	int "WLAN netcard RX buffer number"
+	default 16
+
+config ESP32C3_WIFI_CONNECT_TIMEOUT
+	int "Connect timeout by second"
+	default 10
+	help
+		Max waiting time of connecting to AP.
+
+config ESP32C3_WIFI_SAVE_PARAM
+	bool "Save WiFi Parameters"

Review comment:
       I think should include a "depends on !DISABLE_MOUNTPOINT"




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



[GitHub] [incubator-nuttx] gustavonihei commented on a change in pull request #3040: riscv/esp32c3: Add ESP32-C3 WLAN netcard driver

Posted by GitBox <gi...@apache.org>.
gustavonihei commented on a change in pull request #3040:
URL: https://github.com/apache/incubator-nuttx/pull/3040#discussion_r594700129



##########
File path: boards/risc-v/esp32c3/esp32c3-devkit/src/esp32c3_bringup.c
##########
@@ -143,6 +145,15 @@ int esp32c3_bringup(void)
     }
 #endif
 
+#ifdef CONFIG_ESP32C3_WIRELESS
+  ret = esp32c3_wlan_sta_initialize();
+  if (ret)
+    {
+      syslog(LOG_ERR, "ERROR: Failed to initialize WiFi\n");

Review comment:
       ```suggestion
         syslog(LOG_ERR, "ERROR: Failed to initialize Wi-Fi\n");
   ```




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



[GitHub] [incubator-nuttx] donghengqaz commented on a change in pull request #3040: riscv/esp32c3: Add ESP32-C3 WLAN netcard driver

Posted by GitBox <gi...@apache.org>.
donghengqaz commented on a change in pull request #3040:
URL: https://github.com/apache/incubator-nuttx/pull/3040#discussion_r594822921



##########
File path: arch/risc-v/Kconfig
##########
@@ -45,6 +45,12 @@ config ARCH_CHIP_ESP32C3
 	select RV32IM_HW_MULDIV
 	select ARCH_VECNOTIRQ
 	select ARCH_HAVE_RESET
+	select LIBC_ARCH_MEMCPY

Review comment:
       OK, I will remove it here. OK, I will remove it here. But I add this not for using RISC-V arch level `memcpy`, I mean to use `memcpy` of ESP32C3 ROM, so that the function is not linked to SPI Flash, we can use it without enable I-cache.




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



[GitHub] [incubator-nuttx] gustavonihei commented on a change in pull request #3040: riscv/esp32c3: Add ESP32-C3 WLAN netcard driver

Posted by GitBox <gi...@apache.org>.
gustavonihei commented on a change in pull request #3040:
URL: https://github.com/apache/incubator-nuttx/pull/3040#discussion_r594697787



##########
File path: arch/risc-v/src/esp32c3/Kconfig
##########
@@ -283,4 +297,84 @@ endif # ESP32C3_UART1
 
 endmenu
 
+menu "Real-Time Timer"
+	depends on ESP32C3_RT_TIMER
+
+config ESP32C3_RT_TIMER_TASK_NAME
+	string "Timer task name"
+	default "rt_timer"
+
+config ESP32C3_RT_TIMER_TASK_PRIORITY
+	int "Timer task priority"
+	default 223 # Lower than high priority workqueue
+
+config ESP32C3_RT_TIMER_TASK_STACK_SIZE
+	int "Timer task stack size"
+	default 2048
+
+endmenu # Real-Time Timer
+
+menu "WiFi configuration"
+	depends on ESP32C3_WIRELESS
+
+config ESP32C3_WIFI_STATIC_RXBUF_NUM
+    int "WiFi static RX buffer number"
+	default 10
+
+config ESP32C3_WIFI_DYNAMIC_RXBUF_NUM
+    int "WiFi dynamic RX buffer number"
+	default 32
+
+config ESP32C3_WIFI_DYNAMIC_TXBUF_NUM
+    int "WiFi dynamic TX buffer number"
+	default 32
+
+config ESP32C3_WIFI_TX_AMPDU
+	bool "WiFi TX AMPDU"
+	default y
+
+config ESP32C3_WIFI_RX_AMPDU
+	bool "WiFi RX AMPDU"
+	default y
+
+config ESP32C3_WIFI_RXBA_AMPDU_WZ
+    int "WiFi RX BA AMPDU windown size"

Review comment:
       ```suggestion
         int "WiFi RX BA AMPDU windown size"
   ```
   nit: Alignment issue




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



[GitHub] [incubator-nuttx] donghengqaz commented on a change in pull request #3040: riscv/esp32c3: Add ESP32-C3 WLAN netcard driver

Posted by GitBox <gi...@apache.org>.
donghengqaz commented on a change in pull request #3040:
URL: https://github.com/apache/incubator-nuttx/pull/3040#discussion_r593108929



##########
File path: arch/risc-v/src/esp32c3/esp32c3_irq.c
##########
@@ -166,6 +189,52 @@ void up_disable_irq(int cpuint)
   leave_critical_section(irqstate);
 }
 
+/****************************************************************************
+ * Name: esp32c3_bind_irq
+ *
+ * Description:
+ *   Bind IRQ and resource with given parameters.
+ *
+ * Input Parameters:
+ *   cpuint    - CPU interrupt ID
+ *   periphid  - Peripheral ID
+ *   prio      - Interrupt priority
+ *   flags     - Interrupt flags
+ *
+ * Returned Value:
+ *   Allocated CPU interrupt on success, a negated error on failure.
+ *
+ ****************************************************************************/
+
+int esp32c3_bind_irq(uint8_t cpuint, uint8_t periphid, uint8_t prio,

Review comment:
       The reason is WiFi use specific CPU interrupt ID, and WiFi will bind multi WiFi peripheral interrupt to this CPU interrupt. Maybe BT/BLE has same action.




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



[GitHub] [incubator-nuttx] gustavonihei commented on a change in pull request #3040: riscv/esp32c3: Add ESP32-C3 WLAN netcard driver

Posted by GitBox <gi...@apache.org>.
gustavonihei commented on a change in pull request #3040:
URL: https://github.com/apache/incubator-nuttx/pull/3040#discussion_r593122307



##########
File path: arch/risc-v/src/esp32c3/esp32c3_rt_timer.c
##########
@@ -0,0 +1,678 @@
+/****************************************************************************
+ * arch/risc-v/src/esp32c3/esp32c3_rt_timer.c
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this args 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 <stdbool.h>
+#include <string.h>
+#include <fcntl.h>
+#include <assert.h>
+#include <errno.h>
+#include <debug.h>
+
+#include <nuttx/irq.h>
+#include <nuttx/kthread.h>
+#include <nuttx/kmalloc.h>
+#include <nuttx/semaphore.h>
+
+#include "hardware/esp32c3_soc.h"
+#include "esp32c3_tim.h"
+#include "esp32c3_rt_timer.h"
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+#ifdef CONFIG_SCHED_HPWORKPRIORITY
+#  if CONFIG_ESP32C3_RT_TIMER_TASK_PRIORITY >= CONFIG_SCHED_HPWORKPRIORITY
+#    error "RT timer priority should be smaller that high-prio workqueue"
+#  endif
+#endif
+
+#define RT_TIMER_TASK_NAME        CONFIG_ESP32C3_RT_TIMER_TASK_NAME
+#define RT_TIMER_TASK_PRIORITY    CONFIG_ESP32C3_RT_TIMER_TASK_PRIORITY
+#define RT_TIMER_TASK_STACK_SIZE  CONFIG_ESP32C3_RT_TIMER_TASK_STACK_SIZE
+
+#define ESP32C3_TIMER_PRESCALER     (APB_CLK_FREQ / (1000 * 1000))
+
+/****************************************************************************
+ * Private Data
+ ****************************************************************************/
+
+static int s_pid;
+
+static sem_t s_toutsem;
+
+static struct list_node s_runlist;
+static struct list_node s_toutlist;
+
+static struct esp32c3_tim_dev_s *s_esp32c3_tim_dev;
+
+/****************************************************************************
+ * Private Function Prototypes
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: start_rt_timer
+ *
+ * Description:
+ *   Start timer by inserting it into running list and reset hardware timer
+ *   alarm value if this timer in head of list.
+ *
+ * Input Parameters:
+ *   timer - RT timer pointer
+ *   timeout - Timeout value
+ *   repeat  - If the timer run repeat
+ *
+ * Returned Value:
+ *   None.
+ *
+ ****************************************************************************/
+
+static void start_rt_timer(FAR struct rt_timer_s *timer,
+                           uint64_t timeout,
+                           bool repeat)
+{
+  irqstate_t flags;
+  struct rt_timer_s *p;
+  bool inserted = false;
+  uint64_t counter;
+  struct esp32c3_tim_dev_s *tim = s_esp32c3_tim_dev;
+
+  flags = enter_critical_section();
+
+  /* Only idle timer can be started */
+
+  if (timer->state == RT_TIMER_IDLE)
+    {
+      /* Calculate the timer's alarm value */
+
+      ESP32C3_TIM_GETCTR(tim, &counter);
+      timer->timeout = timeout;
+      timer->alarm = timer->timeout + counter;
+
+      if (repeat)
+        {
+          timer->flags |= RT_TIMER_REPEAT;
+        }
+      else
+        {
+          timer->flags &= ~RT_TIMER_REPEAT;
+        }
+
+      /** Scan timer list and insert the new timer into previous
+       *  node of timer whose alarm value is larger than new one
+       */
+
+      list_for_every_entry(&s_runlist, p, struct rt_timer_s, list)
+        {
+          if (p->alarm > timer->alarm)
+            {
+              list_add_before(&p->list, &timer->list);
+              inserted = true;
+              break;
+            }
+        }
+
+      /* If not find a larger one, insert new timer into tail of list */
+
+      if (!inserted)
+        {
+          list_add_tail(&s_runlist, &timer->list);
+        }
+
+      timer->state = RT_TIMER_READY;
+
+      /* If this timer is in head of list */
+
+      if (timer == container_of(s_runlist.next, struct rt_timer_s, list))
+        {
+          /* Reset hardware timer alarm */
+
+          ESP32C3_TIM_SETALRVL(tim, timer->alarm);
+          ESP32C3_TIM_SETALRM(tim, true);
+        }
+    }
+
+  leave_critical_section(flags);
+}
+
+/****************************************************************************
+ * Name: stop_rt_timer
+ *
+ * Description:
+ *   Stop timer by removing it from running list and reset hardware timer
+ *   alarm value if this timer is in head of list.
+ *
+ * Input Parameters:
+ *   timer - RT timer pointer
+ *
+ * Returned Value:
+ *   None.
+ *
+ ****************************************************************************/
+
+static void stop_rt_timer(FAR struct rt_timer_s *timer)
+{
+  irqstate_t flags;
+  bool ishead;
+  struct rt_timer_s *next_timer;
+  uint64_t alarm;
+  struct esp32c3_tim_dev_s *tim = s_esp32c3_tim_dev;
+
+  flags = enter_critical_section();
+
+  /**
+   * Function "start" can set timer to be repeat, and function "stop"
+   * should remove this feature although it is not in ready state.
+   */
+
+  timer->flags &= ~RT_TIMER_REPEAT;
+
+  /* Only ready timer can be stopped */
+
+  if (timer->state == RT_TIMER_READY)
+    {
+      /* Check if timer is in head of list */
+
+      if (timer == container_of(s_runlist.next, struct rt_timer_s, list))
+        {
+          ishead = true;
+        }
+      else
+        {
+          ishead = false;
+        }
+
+      list_delete(&timer->list);
+      timer->state = RT_TIMER_IDLE;
+
+      /* If timer is in in head of list */
+
+      if (ishead)
+        {
+          /* If list is not empty */
+
+          if (!list_is_empty(&s_runlist))
+            {
+              /* Reset hardware timer alarm value to be next timer's */
+
+              next_timer = container_of(s_runlist.next,
+                                        struct rt_timer_s,
+                                        list);
+              alarm = next_timer->alarm;
+
+              ESP32C3_TIM_SETALRVL(tim, alarm);
+              ESP32C3_TIM_SETALRM(tim, true);
+            }
+        }
+    }
+
+  leave_critical_section(flags);
+}
+
+/****************************************************************************
+ * Name: delete_rt_timer
+ *
+ * Description:
+ *   Delete timer by removing it from list, then set the timer's state
+ *   to be "RT_TIMER_DELETE", inserting into work list to let rt-timer
+ *   thread to delete it and free resource.
+ *
+ * Input Parameters:
+ *   timer - RT timer pointer
+ *
+ * Returned Value:
+ *   None.
+ *
+ ****************************************************************************/
+
+static void delete_rt_timer(FAR struct rt_timer_s *timer)
+{
+  irqstate_t flags;
+
+  flags = enter_critical_section();
+
+  if (timer->state == RT_TIMER_READY)
+    {
+      stop_rt_timer(timer);
+    }
+  else if (timer->state == RT_TIMER_TIMEOUT)
+    {
+      list_delete(&timer->list);
+    }
+  else if (timer->state == RT_TIMER_DELETE)
+    {
+      goto exit;
+    }
+
+  list_add_after(&s_toutlist, &timer->list);
+  timer->state = RT_TIMER_DELETE;
+
+exit:
+  leave_critical_section(flags);
+}
+
+/****************************************************************************
+ * Name: rt_timer_thread
+ *
+ * Description:
+ *   RT timer working thread, it wait for a timeout semaphore, scan
+ *   the timeout list and process all timers in this list.
+ *
+ * Input Parameters:
+ *   argc - Not used
+ *   argv - Not used
+ *
+ * Returned Value:
+ *   0.
+ *
+ ****************************************************************************/
+
+static int rt_timer_thread(int argc, FAR char *argv[])
+{
+  int ret;
+  irqstate_t flags;
+  struct rt_timer_s *timer;
+  enum rt_timer_state_e raw_state;
+
+  while (1)
+    {
+      /* Waiting for timers timeout */
+
+      ret = nxsem_wait(&s_toutsem);
+      if (ret)
+        {
+          tmrerr("ERROR: Wait s_toutsem error=%d\n", ret);
+          assert(0);
+        }
+
+      /* Enter critical to check global timer timeout list */
+
+      flags = enter_critical_section();
+
+      /* Process all timers in list */
+
+      while (!list_is_empty(&s_toutlist))
+        {
+          /* Get first timer in list */
+
+          timer = container_of(s_toutlist.next, struct rt_timer_s, list);
+
+          /* Cache the raw state to decide how to deal with this timer */
+
+          raw_state = timer->state;
+
+          /* Delete timer from list */
+
+          list_delete(&timer->list);
+
+          /* Set timer's state to be let it to able to restart by user */
+
+          timer->state = RT_TIMER_IDLE;
+
+          /* Leave from critical to start to call "callback" function */
+
+          leave_critical_section(flags);
+
+          if (raw_state == RT_TIMER_TIMEOUT)
+            {
+              timer->callback(timer->arg);
+            }
+          else if (raw_state == RT_TIMER_DELETE)
+            {
+              kmm_free(timer);
+            }
+
+          /* Enter critical for next scanning list */
+
+          flags = enter_critical_section();
+
+          if (raw_state == RT_TIMER_TIMEOUT)
+            {
+              /* Check if timer is repeat */
+
+              if (timer->flags & RT_TIMER_REPEAT)
+                {
+                  start_rt_timer(timer, timer->timeout, true);
+                }
+            }
+        }
+
+      leave_critical_section(flags);
+    }
+
+  return 0;
+}
+
+/****************************************************************************
+ * Name: rt_timer_isr
+ *
+ * Description:
+ *   Hardware timer interrupt service function.
+ *
+ * Input Parameters:
+ *   irq     - Not used
+ *   context - Not used
+ *   arg     - Not used
+ *
+ * Returned Value:
+ *   0.
+ *
+ ****************************************************************************/
+
+static int rt_timer_isr(int irq, void *context, void *arg)
+{
+  irqstate_t flags;
+  struct rt_timer_s *timer;
+  uint64_t alarm;
+  uint64_t counter;
+  struct esp32c3_tim_dev_s *tim = s_esp32c3_tim_dev;
+
+  /* Clear interrupt register status */
+
+  ESP32C3_TIM_ACKINT(tim);
+
+  /* Wake up thread to process timeout timers */
+
+  nxsem_post(&s_toutsem);
+
+  flags = enter_critical_section();
+
+  /* Check if there is timer running */
+
+  if (!list_is_empty(&s_runlist))
+    {
+      /**
+       * When stop/delete timer, in the same time the hardware timer
+       * interrupt triggers, function "stop/delete" remove the timer
+       * from running list, so the 1st timer is not which triggers.
+       */
+
+      timer = container_of(s_runlist.next, struct rt_timer_s, list);
+      ESP32C3_TIM_GETCTR(tim, &counter);
+      if (timer->alarm <= counter)
+        {
+          /**
+           * Remove first timer in running list and add it into
+           * timeout list.
+           *
+           * Set the timer's state to be RT_TIMER_TIMEOUT to avoid
+           * other operation.
+           */
+
+          list_delete(&timer->list);
+          timer->state = RT_TIMER_TIMEOUT;
+          list_add_after(&s_toutlist, &timer->list);
+
+          /* Check if thers is timer running */
+
+          if (!list_is_empty(&s_runlist))
+            {
+              /* Reset hardware timer alarm with next timer's alarm value */
+
+              timer = container_of(s_runlist.next, struct rt_timer_s, list);
+              alarm = timer->alarm;
+
+              ESP32C3_TIM_SETALRVL(tim, alarm);
+              ESP32C3_TIM_SETALRM(tim, true);
+            }
+        }
+    }
+
+  leave_critical_section(flags);
+
+  return 0;
+}
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: rt_timer_create
+ *
+ * Description:
+ *   Create RT timer by into timer creation arguments
+ *
+ * Input Parameters:
+ *   args         - Input RT timer creation arguments
+ *   timer_handle - Output RT timer handle pointer
+ *
+ * Returned Value:
+ *   0 is returned on success. Otherwise, a negated errno value is returned.
+ *
+ ****************************************************************************/
+
+int rt_timer_create(FAR const struct rt_timer_args_s *args,
+                    FAR struct rt_timer_s **timer_handle)
+{
+  struct rt_timer_s *timer;
+
+  timer = (struct rt_timer_s *)kmm_malloc(sizeof(*timer));
+  if (!timer)
+    {
+      tmrerr("ERROR: Failed to allocate %d bytes\n", sizeof(*timer));
+      return -ENOMEM;
+    }
+
+  timer->callback = args->callback;
+  timer->arg      = args->arg;
+  timer->flags    = RT_TIMER_NOFLAGS;
+  timer->state    = RT_TIMER_IDLE;
+  list_initialize(&timer->list);
+
+  *timer_handle = timer;
+
+  return 0;
+}
+
+/****************************************************************************
+ * Name: rt_timer_start
+ *
+ * Description:
+ *   Start RT timer.
+ *
+ * Input Parameters:
+ *   timer   - RT timer pointer
+ *   timeout - Timeout value
+ *   repeat  - If the timer run repeat
+ *
+ * Returned Value:
+ *   None
+ *
+ ****************************************************************************/
+
+void rt_timer_start(FAR struct rt_timer_s *timer,
+                    uint64_t timeout,
+                    bool repeat)
+{
+  stop_rt_timer(timer);
+
+  start_rt_timer(timer, timeout, repeat);
+}
+
+/****************************************************************************
+ * Name: rt_timer_stop
+ *
+ * Description:
+ *   Stop RT timer.
+ *
+ * Input Parameters:
+ *   timer - RT timer pointer
+ *
+ * Returned Value:
+ *   None
+ *
+ ****************************************************************************/
+
+void rt_timer_stop(FAR struct rt_timer_s *timer)
+{
+  stop_rt_timer(timer);
+}
+
+/****************************************************************************
+ * Name: rt_timer_delete
+ *
+ * Description:
+ *   Stop and deleta RT timer.
+ *
+ * Input Parameters:
+ *   timer - RT timer pointer
+ *
+ * Returned Value:
+ *   None
+ *
+ ****************************************************************************/
+
+void rt_timer_delete(FAR struct rt_timer_s *timer)
+{
+  delete_rt_timer(timer);
+}
+
+/****************************************************************************
+ * Name: rt_timer_time_us
+ *
+ * Description:
+ *   Get time of RT timer by micro second.

Review comment:
       ```suggestion
    *   Get time of RT timer by microsecond.
   ```

##########
File path: arch/risc-v/src/esp32c3/esp32c3_rt_timer.c
##########
@@ -0,0 +1,678 @@
+/****************************************************************************
+ * arch/risc-v/src/esp32c3/esp32c3_rt_timer.c
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this args 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 <stdbool.h>
+#include <string.h>
+#include <fcntl.h>
+#include <assert.h>
+#include <errno.h>
+#include <debug.h>
+
+#include <nuttx/irq.h>
+#include <nuttx/kthread.h>
+#include <nuttx/kmalloc.h>
+#include <nuttx/semaphore.h>
+
+#include "hardware/esp32c3_soc.h"
+#include "esp32c3_tim.h"
+#include "esp32c3_rt_timer.h"
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+#ifdef CONFIG_SCHED_HPWORKPRIORITY
+#  if CONFIG_ESP32C3_RT_TIMER_TASK_PRIORITY >= CONFIG_SCHED_HPWORKPRIORITY
+#    error "RT timer priority should be smaller that high-prio workqueue"
+#  endif
+#endif
+
+#define RT_TIMER_TASK_NAME        CONFIG_ESP32C3_RT_TIMER_TASK_NAME
+#define RT_TIMER_TASK_PRIORITY    CONFIG_ESP32C3_RT_TIMER_TASK_PRIORITY
+#define RT_TIMER_TASK_STACK_SIZE  CONFIG_ESP32C3_RT_TIMER_TASK_STACK_SIZE
+
+#define ESP32C3_TIMER_PRESCALER     (APB_CLK_FREQ / (1000 * 1000))
+
+/****************************************************************************
+ * Private Data
+ ****************************************************************************/
+
+static int s_pid;
+
+static sem_t s_toutsem;
+
+static struct list_node s_runlist;
+static struct list_node s_toutlist;
+
+static struct esp32c3_tim_dev_s *s_esp32c3_tim_dev;
+
+/****************************************************************************
+ * Private Function Prototypes
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: start_rt_timer
+ *
+ * Description:
+ *   Start timer by inserting it into running list and reset hardware timer
+ *   alarm value if this timer in head of list.
+ *
+ * Input Parameters:
+ *   timer - RT timer pointer
+ *   timeout - Timeout value
+ *   repeat  - If the timer run repeat
+ *
+ * Returned Value:
+ *   None.
+ *
+ ****************************************************************************/
+
+static void start_rt_timer(FAR struct rt_timer_s *timer,
+                           uint64_t timeout,
+                           bool repeat)
+{
+  irqstate_t flags;
+  struct rt_timer_s *p;
+  bool inserted = false;
+  uint64_t counter;
+  struct esp32c3_tim_dev_s *tim = s_esp32c3_tim_dev;
+
+  flags = enter_critical_section();
+
+  /* Only idle timer can be started */
+
+  if (timer->state == RT_TIMER_IDLE)
+    {
+      /* Calculate the timer's alarm value */
+
+      ESP32C3_TIM_GETCTR(tim, &counter);
+      timer->timeout = timeout;
+      timer->alarm = timer->timeout + counter;
+
+      if (repeat)
+        {
+          timer->flags |= RT_TIMER_REPEAT;
+        }
+      else
+        {
+          timer->flags &= ~RT_TIMER_REPEAT;
+        }
+
+      /** Scan timer list and insert the new timer into previous
+       *  node of timer whose alarm value is larger than new one
+       */
+
+      list_for_every_entry(&s_runlist, p, struct rt_timer_s, list)
+        {
+          if (p->alarm > timer->alarm)
+            {
+              list_add_before(&p->list, &timer->list);
+              inserted = true;
+              break;
+            }
+        }
+
+      /* If not find a larger one, insert new timer into tail of list */
+
+      if (!inserted)
+        {
+          list_add_tail(&s_runlist, &timer->list);
+        }
+
+      timer->state = RT_TIMER_READY;
+
+      /* If this timer is in head of list */
+
+      if (timer == container_of(s_runlist.next, struct rt_timer_s, list))
+        {
+          /* Reset hardware timer alarm */
+
+          ESP32C3_TIM_SETALRVL(tim, timer->alarm);
+          ESP32C3_TIM_SETALRM(tim, true);
+        }
+    }
+
+  leave_critical_section(flags);
+}
+
+/****************************************************************************
+ * Name: stop_rt_timer
+ *
+ * Description:
+ *   Stop timer by removing it from running list and reset hardware timer
+ *   alarm value if this timer is in head of list.
+ *
+ * Input Parameters:
+ *   timer - RT timer pointer
+ *
+ * Returned Value:
+ *   None.
+ *
+ ****************************************************************************/
+
+static void stop_rt_timer(FAR struct rt_timer_s *timer)
+{
+  irqstate_t flags;
+  bool ishead;
+  struct rt_timer_s *next_timer;
+  uint64_t alarm;
+  struct esp32c3_tim_dev_s *tim = s_esp32c3_tim_dev;
+
+  flags = enter_critical_section();
+
+  /**
+   * Function "start" can set timer to be repeat, and function "stop"
+   * should remove this feature although it is not in ready state.
+   */
+
+  timer->flags &= ~RT_TIMER_REPEAT;
+
+  /* Only ready timer can be stopped */
+
+  if (timer->state == RT_TIMER_READY)
+    {
+      /* Check if timer is in head of list */
+
+      if (timer == container_of(s_runlist.next, struct rt_timer_s, list))
+        {
+          ishead = true;
+        }
+      else
+        {
+          ishead = false;
+        }
+
+      list_delete(&timer->list);
+      timer->state = RT_TIMER_IDLE;
+
+      /* If timer is in in head of list */
+
+      if (ishead)
+        {
+          /* If list is not empty */
+
+          if (!list_is_empty(&s_runlist))
+            {
+              /* Reset hardware timer alarm value to be next timer's */
+
+              next_timer = container_of(s_runlist.next,
+                                        struct rt_timer_s,
+                                        list);
+              alarm = next_timer->alarm;
+
+              ESP32C3_TIM_SETALRVL(tim, alarm);
+              ESP32C3_TIM_SETALRM(tim, true);
+            }
+        }
+    }
+
+  leave_critical_section(flags);
+}
+
+/****************************************************************************
+ * Name: delete_rt_timer
+ *
+ * Description:
+ *   Delete timer by removing it from list, then set the timer's state
+ *   to be "RT_TIMER_DELETE", inserting into work list to let rt-timer
+ *   thread to delete it and free resource.
+ *
+ * Input Parameters:
+ *   timer - RT timer pointer
+ *
+ * Returned Value:
+ *   None.
+ *
+ ****************************************************************************/
+
+static void delete_rt_timer(FAR struct rt_timer_s *timer)
+{
+  irqstate_t flags;
+
+  flags = enter_critical_section();
+
+  if (timer->state == RT_TIMER_READY)
+    {
+      stop_rt_timer(timer);
+    }
+  else if (timer->state == RT_TIMER_TIMEOUT)
+    {
+      list_delete(&timer->list);
+    }
+  else if (timer->state == RT_TIMER_DELETE)
+    {
+      goto exit;
+    }
+
+  list_add_after(&s_toutlist, &timer->list);
+  timer->state = RT_TIMER_DELETE;
+
+exit:
+  leave_critical_section(flags);
+}
+
+/****************************************************************************
+ * Name: rt_timer_thread
+ *
+ * Description:
+ *   RT timer working thread, it wait for a timeout semaphore, scan
+ *   the timeout list and process all timers in this list.
+ *
+ * Input Parameters:
+ *   argc - Not used
+ *   argv - Not used
+ *
+ * Returned Value:
+ *   0.
+ *
+ ****************************************************************************/
+
+static int rt_timer_thread(int argc, FAR char *argv[])
+{
+  int ret;
+  irqstate_t flags;
+  struct rt_timer_s *timer;
+  enum rt_timer_state_e raw_state;
+
+  while (1)
+    {
+      /* Waiting for timers timeout */
+
+      ret = nxsem_wait(&s_toutsem);
+      if (ret)
+        {
+          tmrerr("ERROR: Wait s_toutsem error=%d\n", ret);
+          assert(0);
+        }
+
+      /* Enter critical to check global timer timeout list */
+
+      flags = enter_critical_section();
+
+      /* Process all timers in list */
+
+      while (!list_is_empty(&s_toutlist))
+        {
+          /* Get first timer in list */
+
+          timer = container_of(s_toutlist.next, struct rt_timer_s, list);
+
+          /* Cache the raw state to decide how to deal with this timer */
+
+          raw_state = timer->state;
+
+          /* Delete timer from list */
+
+          list_delete(&timer->list);
+
+          /* Set timer's state to be let it to able to restart by user */
+
+          timer->state = RT_TIMER_IDLE;
+
+          /* Leave from critical to start to call "callback" function */
+
+          leave_critical_section(flags);
+
+          if (raw_state == RT_TIMER_TIMEOUT)
+            {
+              timer->callback(timer->arg);
+            }
+          else if (raw_state == RT_TIMER_DELETE)
+            {
+              kmm_free(timer);
+            }
+
+          /* Enter critical for next scanning list */
+
+          flags = enter_critical_section();
+
+          if (raw_state == RT_TIMER_TIMEOUT)
+            {
+              /* Check if timer is repeat */
+
+              if (timer->flags & RT_TIMER_REPEAT)
+                {
+                  start_rt_timer(timer, timer->timeout, true);
+                }
+            }
+        }
+
+      leave_critical_section(flags);
+    }
+
+  return 0;
+}
+
+/****************************************************************************
+ * Name: rt_timer_isr
+ *
+ * Description:
+ *   Hardware timer interrupt service function.
+ *
+ * Input Parameters:
+ *   irq     - Not used
+ *   context - Not used
+ *   arg     - Not used
+ *
+ * Returned Value:
+ *   0.
+ *
+ ****************************************************************************/
+
+static int rt_timer_isr(int irq, void *context, void *arg)
+{
+  irqstate_t flags;
+  struct rt_timer_s *timer;
+  uint64_t alarm;
+  uint64_t counter;
+  struct esp32c3_tim_dev_s *tim = s_esp32c3_tim_dev;
+
+  /* Clear interrupt register status */
+
+  ESP32C3_TIM_ACKINT(tim);
+
+  /* Wake up thread to process timeout timers */
+
+  nxsem_post(&s_toutsem);
+
+  flags = enter_critical_section();
+
+  /* Check if there is timer running */
+
+  if (!list_is_empty(&s_runlist))
+    {
+      /**
+       * When stop/delete timer, in the same time the hardware timer
+       * interrupt triggers, function "stop/delete" remove the timer
+       * from running list, so the 1st timer is not which triggers.
+       */
+
+      timer = container_of(s_runlist.next, struct rt_timer_s, list);
+      ESP32C3_TIM_GETCTR(tim, &counter);
+      if (timer->alarm <= counter)
+        {
+          /**
+           * Remove first timer in running list and add it into
+           * timeout list.
+           *
+           * Set the timer's state to be RT_TIMER_TIMEOUT to avoid
+           * other operation.
+           */
+
+          list_delete(&timer->list);
+          timer->state = RT_TIMER_TIMEOUT;
+          list_add_after(&s_toutlist, &timer->list);
+
+          /* Check if thers is timer running */
+
+          if (!list_is_empty(&s_runlist))
+            {
+              /* Reset hardware timer alarm with next timer's alarm value */
+
+              timer = container_of(s_runlist.next, struct rt_timer_s, list);
+              alarm = timer->alarm;
+
+              ESP32C3_TIM_SETALRVL(tim, alarm);
+              ESP32C3_TIM_SETALRM(tim, true);
+            }
+        }
+    }
+
+  leave_critical_section(flags);
+
+  return 0;
+}
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: rt_timer_create
+ *
+ * Description:
+ *   Create RT timer by into timer creation arguments
+ *
+ * Input Parameters:
+ *   args         - Input RT timer creation arguments
+ *   timer_handle - Output RT timer handle pointer
+ *
+ * Returned Value:
+ *   0 is returned on success. Otherwise, a negated errno value is returned.
+ *
+ ****************************************************************************/
+
+int rt_timer_create(FAR const struct rt_timer_args_s *args,
+                    FAR struct rt_timer_s **timer_handle)
+{
+  struct rt_timer_s *timer;
+
+  timer = (struct rt_timer_s *)kmm_malloc(sizeof(*timer));
+  if (!timer)
+    {
+      tmrerr("ERROR: Failed to allocate %d bytes\n", sizeof(*timer));
+      return -ENOMEM;
+    }
+
+  timer->callback = args->callback;
+  timer->arg      = args->arg;
+  timer->flags    = RT_TIMER_NOFLAGS;
+  timer->state    = RT_TIMER_IDLE;
+  list_initialize(&timer->list);
+
+  *timer_handle = timer;
+
+  return 0;
+}
+
+/****************************************************************************
+ * Name: rt_timer_start
+ *
+ * Description:
+ *   Start RT timer.
+ *
+ * Input Parameters:
+ *   timer   - RT timer pointer
+ *   timeout - Timeout value
+ *   repeat  - If the timer run repeat
+ *
+ * Returned Value:
+ *   None
+ *
+ ****************************************************************************/
+
+void rt_timer_start(FAR struct rt_timer_s *timer,
+                    uint64_t timeout,
+                    bool repeat)
+{
+  stop_rt_timer(timer);
+
+  start_rt_timer(timer, timeout, repeat);
+}
+
+/****************************************************************************
+ * Name: rt_timer_stop
+ *
+ * Description:
+ *   Stop RT timer.
+ *
+ * Input Parameters:
+ *   timer - RT timer pointer
+ *
+ * Returned Value:
+ *   None
+ *
+ ****************************************************************************/
+
+void rt_timer_stop(FAR struct rt_timer_s *timer)
+{
+  stop_rt_timer(timer);
+}
+
+/****************************************************************************
+ * Name: rt_timer_delete
+ *
+ * Description:
+ *   Stop and deleta RT timer.
+ *
+ * Input Parameters:
+ *   timer - RT timer pointer
+ *
+ * Returned Value:
+ *   None
+ *
+ ****************************************************************************/
+
+void rt_timer_delete(FAR struct rt_timer_s *timer)
+{
+  delete_rt_timer(timer);
+}
+
+/****************************************************************************
+ * Name: rt_timer_time_us
+ *
+ * Description:
+ *   Get time of RT timer by micro second.
+ *
+ * Input Parameters:
+ *   None
+ *
+ * Returned Value:
+ *   Time of RT timer by micro second.

Review comment:
       ```suggestion
    *   Time of RT timer by microsecond.
   ```




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



[GitHub] [incubator-nuttx] gustavonihei commented on a change in pull request #3040: riscv/esp32c3: Add ESP32-C3 WLAN netcard driver

Posted by GitBox <gi...@apache.org>.
gustavonihei commented on a change in pull request #3040:
URL: https://github.com/apache/incubator-nuttx/pull/3040#discussion_r594699355



##########
File path: arch/risc-v/src/esp32c3/Kconfig
##########
@@ -283,4 +297,84 @@ endif # ESP32C3_UART1
 
 endmenu
 
+menu "Real-Time Timer"
+	depends on ESP32C3_RT_TIMER
+
+config ESP32C3_RT_TIMER_TASK_NAME
+	string "Timer task name"
+	default "rt_timer"
+
+config ESP32C3_RT_TIMER_TASK_PRIORITY
+	int "Timer task priority"
+	default 223 # Lower than high priority workqueue
+
+config ESP32C3_RT_TIMER_TASK_STACK_SIZE
+	int "Timer task stack size"
+	default 2048
+
+endmenu # Real-Time Timer
+
+menu "WiFi configuration"
+	depends on ESP32C3_WIRELESS
+
+config ESP32C3_WIFI_STATIC_RXBUF_NUM
+    int "WiFi static RX buffer number"
+	default 10
+
+config ESP32C3_WIFI_DYNAMIC_RXBUF_NUM
+    int "WiFi dynamic RX buffer number"
+	default 32
+
+config ESP32C3_WIFI_DYNAMIC_TXBUF_NUM
+    int "WiFi dynamic TX buffer number"
+	default 32
+
+config ESP32C3_WIFI_TX_AMPDU
+	bool "WiFi TX AMPDU"
+	default y
+
+config ESP32C3_WIFI_RX_AMPDU
+	bool "WiFi RX AMPDU"
+	default y
+
+config ESP32C3_WIFI_RXBA_AMPDU_WZ
+    int "WiFi RX BA AMPDU windown size"
+	default 6
+
+config ESP32C3_WLAN_RXBUF_NUM
+	int "WLAN netcard RX buffer number"
+	default 16
+
+config ESP32C3_WIFI_CONNECT_TIMEOUT
+	int "Connect timeout by second"
+	default 10
+	help
+		Max waiting time of connecting to AP.
+
+config ESP32C3_WIFI_SAVE_PARAM
+	bool "Save WiFi Parameters"
+	default n
+	depends on !DISABLE_MOUNTPOINT
+	help
+		If you enable this option, WiFi adapter parameters will be saved
+		into the file system instead of computing them each time.
+
+		These parameters mainly contains:
+		  - SSID
+		  - Password
+		  - BSSID
+		  - PMK(compute when connecting)
+		  - Author mode
+		  - MAC address
+		  - WiFi hardware configuration parameters
+
+config ESP32C3_WIFI_FS_MOUNTPT
+	string "Save WiFi Parameters"
+	default "/mnt/esp/wifi"
+	depends on ESP32C3_WIFI_SAVE_PARAM
+	help
+		Mount point of WiFi storage file system.

Review comment:
       ```suggestion
   		Mount point of Wi-Fi storage file system.
   ```

##########
File path: arch/risc-v/src/esp32c3/Kconfig
##########
@@ -283,4 +297,84 @@ endif # ESP32C3_UART1
 
 endmenu
 
+menu "Real-Time Timer"
+	depends on ESP32C3_RT_TIMER
+
+config ESP32C3_RT_TIMER_TASK_NAME
+	string "Timer task name"
+	default "rt_timer"
+
+config ESP32C3_RT_TIMER_TASK_PRIORITY
+	int "Timer task priority"
+	default 223 # Lower than high priority workqueue
+
+config ESP32C3_RT_TIMER_TASK_STACK_SIZE
+	int "Timer task stack size"
+	default 2048
+
+endmenu # Real-Time Timer
+
+menu "WiFi configuration"
+	depends on ESP32C3_WIRELESS
+
+config ESP32C3_WIFI_STATIC_RXBUF_NUM
+    int "WiFi static RX buffer number"
+	default 10
+
+config ESP32C3_WIFI_DYNAMIC_RXBUF_NUM
+    int "WiFi dynamic RX buffer number"
+	default 32
+
+config ESP32C3_WIFI_DYNAMIC_TXBUF_NUM
+    int "WiFi dynamic TX buffer number"
+	default 32
+
+config ESP32C3_WIFI_TX_AMPDU
+	bool "WiFi TX AMPDU"
+	default y
+
+config ESP32C3_WIFI_RX_AMPDU
+	bool "WiFi RX AMPDU"
+	default y
+
+config ESP32C3_WIFI_RXBA_AMPDU_WZ
+    int "WiFi RX BA AMPDU windown size"
+	default 6
+
+config ESP32C3_WLAN_RXBUF_NUM
+	int "WLAN netcard RX buffer number"
+	default 16
+
+config ESP32C3_WIFI_CONNECT_TIMEOUT
+	int "Connect timeout by second"
+	default 10
+	help
+		Max waiting time of connecting to AP.
+
+config ESP32C3_WIFI_SAVE_PARAM
+	bool "Save WiFi Parameters"
+	default n
+	depends on !DISABLE_MOUNTPOINT
+	help
+		If you enable this option, WiFi adapter parameters will be saved
+		into the file system instead of computing them each time.
+
+		These parameters mainly contains:
+		  - SSID
+		  - Password
+		  - BSSID
+		  - PMK(compute when connecting)
+		  - Author mode
+		  - MAC address
+		  - WiFi hardware configuration parameters
+
+config ESP32C3_WIFI_FS_MOUNTPT
+	string "Save WiFi Parameters"

Review comment:
       ```suggestion
   	string "Save Wi-Fi Parameters"
   ```




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



[GitHub] [incubator-nuttx] gustavonihei commented on a change in pull request #3040: riscv/esp32c3: Add ESP32-C3 WLAN netcard driver

Posted by GitBox <gi...@apache.org>.
gustavonihei commented on a change in pull request #3040:
URL: https://github.com/apache/incubator-nuttx/pull/3040#discussion_r594698142



##########
File path: arch/risc-v/src/esp32c3/Kconfig
##########
@@ -283,4 +297,84 @@ endif # ESP32C3_UART1
 
 endmenu
 
+menu "Real-Time Timer"
+	depends on ESP32C3_RT_TIMER
+
+config ESP32C3_RT_TIMER_TASK_NAME
+	string "Timer task name"
+	default "rt_timer"
+
+config ESP32C3_RT_TIMER_TASK_PRIORITY
+	int "Timer task priority"
+	default 223 # Lower than high priority workqueue
+
+config ESP32C3_RT_TIMER_TASK_STACK_SIZE
+	int "Timer task stack size"
+	default 2048
+
+endmenu # Real-Time Timer
+
+menu "WiFi configuration"
+	depends on ESP32C3_WIRELESS
+
+config ESP32C3_WIFI_STATIC_RXBUF_NUM
+    int "WiFi static RX buffer number"

Review comment:
       ```suggestion
         int "WiFi static RX buffer number"
   ```
   nit: Alignment issue

##########
File path: arch/risc-v/src/esp32c3/Kconfig
##########
@@ -283,4 +297,84 @@ endif # ESP32C3_UART1
 
 endmenu
 
+menu "Real-Time Timer"
+	depends on ESP32C3_RT_TIMER
+
+config ESP32C3_RT_TIMER_TASK_NAME
+	string "Timer task name"
+	default "rt_timer"
+
+config ESP32C3_RT_TIMER_TASK_PRIORITY
+	int "Timer task priority"
+	default 223 # Lower than high priority workqueue
+
+config ESP32C3_RT_TIMER_TASK_STACK_SIZE
+	int "Timer task stack size"
+	default 2048
+
+endmenu # Real-Time Timer
+
+menu "WiFi configuration"
+	depends on ESP32C3_WIRELESS
+
+config ESP32C3_WIFI_STATIC_RXBUF_NUM
+    int "WiFi static RX buffer number"
+	default 10
+
+config ESP32C3_WIFI_DYNAMIC_RXBUF_NUM
+    int "WiFi dynamic RX buffer number"

Review comment:
       ```suggestion
         int "WiFi dynamic RX buffer number"
   ```
   nit: Alignment issue




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



[GitHub] [incubator-nuttx] gustavonihei commented on a change in pull request #3040: riscv/esp32c3: Add ESP32-C3 WLAN netcard driver

Posted by GitBox <gi...@apache.org>.
gustavonihei commented on a change in pull request #3040:
URL: https://github.com/apache/incubator-nuttx/pull/3040#discussion_r594697787



##########
File path: arch/risc-v/src/esp32c3/Kconfig
##########
@@ -283,4 +297,84 @@ endif # ESP32C3_UART1
 
 endmenu
 
+menu "Real-Time Timer"
+	depends on ESP32C3_RT_TIMER
+
+config ESP32C3_RT_TIMER_TASK_NAME
+	string "Timer task name"
+	default "rt_timer"
+
+config ESP32C3_RT_TIMER_TASK_PRIORITY
+	int "Timer task priority"
+	default 223 # Lower than high priority workqueue
+
+config ESP32C3_RT_TIMER_TASK_STACK_SIZE
+	int "Timer task stack size"
+	default 2048
+
+endmenu # Real-Time Timer
+
+menu "WiFi configuration"
+	depends on ESP32C3_WIRELESS
+
+config ESP32C3_WIFI_STATIC_RXBUF_NUM
+    int "WiFi static RX buffer number"
+	default 10
+
+config ESP32C3_WIFI_DYNAMIC_RXBUF_NUM
+    int "WiFi dynamic RX buffer number"
+	default 32
+
+config ESP32C3_WIFI_DYNAMIC_TXBUF_NUM
+    int "WiFi dynamic TX buffer number"
+	default 32
+
+config ESP32C3_WIFI_TX_AMPDU
+	bool "WiFi TX AMPDU"
+	default y
+
+config ESP32C3_WIFI_RX_AMPDU
+	bool "WiFi RX AMPDU"
+	default y
+
+config ESP32C3_WIFI_RXBA_AMPDU_WZ
+    int "WiFi RX BA AMPDU windown size"

Review comment:
       ```suggestion
         int "WiFi RX BA AMPDU windown size"
   ```




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



[GitHub] [incubator-nuttx] donghengqaz commented on a change in pull request #3040: riscv/esp32c3: Add ESP32-C3 WLAN netcard driver

Posted by GitBox <gi...@apache.org>.
donghengqaz commented on a change in pull request #3040:
URL: https://github.com/apache/incubator-nuttx/pull/3040#discussion_r593118241



##########
File path: arch/risc-v/src/esp32c3/Kconfig
##########
@@ -283,4 +297,83 @@ endif # ESP32C3_UART1
 
 endmenu
 
+menu "Real-Time Timer"
+	depends on ESP32C3_RT_TIMER
+
+config ESP32C3_RT_TIMER_TASK_NAME
+	string "Timer task name"
+	default "rt_timer"
+
+config ESP32C3_RT_TIMER_TASK_PRIORITY
+	int "Timer task priority"
+	default 223 # Lower than high priority workqueue
+
+config ESP32C3_RT_TIMER_TASK_STACK_SIZE
+	int "Timer task stack size"
+	default 2048
+
+endmenu # Real-Time Timer
+
+menu "WiFi configuration"
+	depends on ESP32C3_WIRELESS
+
+config ESP32C3_WIFI_STATIC_RXBUF_NUM
+    int "WiFi static RX buffer number"
+	default 10
+
+config ESP32C3_WIFI_DYNAMIC_RXBUF_NUM
+    int "WiFi dynamic RX buffer number"
+	default 32
+
+config ESP32C3_WIFI_DYNAMIC_TXBUF_NUM
+    int "WiFi dynamic TX buffer number"
+	default 32
+
+config ESP32C3_WIFI_TX_AMPDU
+	bool "WiFi TX AMPDU"
+	default y
+
+config ESP32C3_WIFI_RX_AMPDU
+	bool "WiFi RX AMPDU"
+	default y
+
+config ESP32C3_WIFI_RXBA_AMPDU_WZ
+    int "WiFi RX BA AMPDU windown size"
+	default 6
+
+config ESP32C3_WLAN_RXBUF_NUM
+	int "WLAN netcard RX buffer number"
+	default 16
+
+config ESP32C3_WIFI_CONNECT_TIMEOUT
+	int "Connect timeout by second"
+	default 10
+	help
+		Max waiting time of connecting to AP.
+
+config ESP32C3_WIFI_SAVE_PARAM
+	bool "Save WiFi Parameters"

Review comment:
       Yes, I will add this.




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



[GitHub] [incubator-nuttx] gustavonihei commented on a change in pull request #3040: riscv/esp32c3: Add ESP32-C3 WLAN netcard driver

Posted by GitBox <gi...@apache.org>.
gustavonihei commented on a change in pull request #3040:
URL: https://github.com/apache/incubator-nuttx/pull/3040#discussion_r594698888



##########
File path: arch/risc-v/src/esp32c3/Kconfig
##########
@@ -283,4 +297,84 @@ endif # ESP32C3_UART1
 
 endmenu
 
+menu "Real-Time Timer"
+	depends on ESP32C3_RT_TIMER
+
+config ESP32C3_RT_TIMER_TASK_NAME
+	string "Timer task name"
+	default "rt_timer"
+
+config ESP32C3_RT_TIMER_TASK_PRIORITY
+	int "Timer task priority"
+	default 223 # Lower than high priority workqueue
+
+config ESP32C3_RT_TIMER_TASK_STACK_SIZE
+	int "Timer task stack size"
+	default 2048
+
+endmenu # Real-Time Timer
+
+menu "WiFi configuration"
+	depends on ESP32C3_WIRELESS
+
+config ESP32C3_WIFI_STATIC_RXBUF_NUM
+    int "WiFi static RX buffer number"
+	default 10
+
+config ESP32C3_WIFI_DYNAMIC_RXBUF_NUM
+    int "WiFi dynamic RX buffer number"
+	default 32
+
+config ESP32C3_WIFI_DYNAMIC_TXBUF_NUM
+    int "WiFi dynamic TX buffer number"
+	default 32
+
+config ESP32C3_WIFI_TX_AMPDU
+	bool "WiFi TX AMPDU"
+	default y
+
+config ESP32C3_WIFI_RX_AMPDU
+	bool "WiFi RX AMPDU"

Review comment:
       ```suggestion
   	bool "Wi-Fi RX AMPDU"
   ```
   nit: Wi-Fi spelling

##########
File path: arch/risc-v/src/esp32c3/Kconfig
##########
@@ -283,4 +297,84 @@ endif # ESP32C3_UART1
 
 endmenu
 
+menu "Real-Time Timer"
+	depends on ESP32C3_RT_TIMER
+
+config ESP32C3_RT_TIMER_TASK_NAME
+	string "Timer task name"
+	default "rt_timer"
+
+config ESP32C3_RT_TIMER_TASK_PRIORITY
+	int "Timer task priority"
+	default 223 # Lower than high priority workqueue
+
+config ESP32C3_RT_TIMER_TASK_STACK_SIZE
+	int "Timer task stack size"
+	default 2048
+
+endmenu # Real-Time Timer
+
+menu "WiFi configuration"
+	depends on ESP32C3_WIRELESS
+
+config ESP32C3_WIFI_STATIC_RXBUF_NUM
+    int "WiFi static RX buffer number"
+	default 10
+
+config ESP32C3_WIFI_DYNAMIC_RXBUF_NUM
+    int "WiFi dynamic RX buffer number"
+	default 32
+
+config ESP32C3_WIFI_DYNAMIC_TXBUF_NUM
+    int "WiFi dynamic TX buffer number"
+	default 32
+
+config ESP32C3_WIFI_TX_AMPDU
+	bool "WiFi TX AMPDU"

Review comment:
       ```suggestion
   	bool "Wi-Fi TX AMPDU"
   ```
   nit: Wi-Fi spelling




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



[GitHub] [incubator-nuttx] acassis commented on a change in pull request #3040: riscv/esp32c3: Add ESP32-C3 WLAN netcard driver

Posted by GitBox <gi...@apache.org>.
acassis commented on a change in pull request #3040:
URL: https://github.com/apache/incubator-nuttx/pull/3040#discussion_r593115733



##########
File path: arch/risc-v/src/esp32c3/Kconfig
##########
@@ -283,4 +297,83 @@ endif # ESP32C3_UART1
 
 endmenu
 
+menu "Real-Time Timer"
+	depends on ESP32C3_RT_TIMER
+
+config ESP32C3_RT_TIMER_TASK_NAME
+	string "Timer task name"
+	default "rt_timer"
+
+config ESP32C3_RT_TIMER_TASK_PRIORITY
+	int "Timer task priority"
+	default 223 # Lower than high priority workqueue
+
+config ESP32C3_RT_TIMER_TASK_STACK_SIZE
+	int "Timer task stack size"
+	default 2048
+
+endmenu # Real-Time Timer
+
+menu "WiFi configuration"
+	depends on ESP32C3_WIRELESS
+
+config ESP32C3_WIFI_STATIC_RXBUF_NUM
+    int "WiFi static RX buffer number"
+	default 10
+
+config ESP32C3_WIFI_DYNAMIC_RXBUF_NUM
+    int "WiFi dynamic RX buffer number"
+	default 32
+
+config ESP32C3_WIFI_DYNAMIC_TXBUF_NUM
+    int "WiFi dynamic TX buffer number"
+	default 32
+
+config ESP32C3_WIFI_TX_AMPDU
+	bool "WiFi TX AMPDU"
+	default y
+
+config ESP32C3_WIFI_RX_AMPDU
+	bool "WiFi RX AMPDU"
+	default y
+
+config ESP32C3_WIFI_RXBA_AMPDU_WZ
+    int "WiFi RX BA AMPDU windown size"
+	default 6
+
+config ESP32C3_WLAN_RXBUF_NUM
+	int "WLAN netcard RX buffer number"
+	default 16
+
+config ESP32C3_WIFI_CONNECT_TIMEOUT
+	int "Connect timeout by second"
+	default 10
+	help
+		Max waiting time of connecting to AP.
+
+config ESP32C3_WIFI_SAVE_PARAM
+	bool "Save WiFi Parameters"

Review comment:
       @donghengqaz please fill all the fields [here](https://github.com/apache/incubator-nuttx/pull/3040#issue-591426880)




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



[GitHub] [incubator-nuttx] gustavonihei commented on a change in pull request #3040: riscv/esp32c3: Add ESP32-C3 WLAN netcard driver

Posted by GitBox <gi...@apache.org>.
gustavonihei commented on a change in pull request #3040:
URL: https://github.com/apache/incubator-nuttx/pull/3040#discussion_r593126415



##########
File path: arch/risc-v/src/esp32c3/esp32c3_rt_timer.h
##########
@@ -0,0 +1,206 @@
+/****************************************************************************
+ * arch/risc-v/src/esp32c3/esp32c3_rt_timer.h
+ *
+ * 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.
+ *
+ ****************************************************************************/
+
+#ifndef __ARCH_RISCV_SRC_ESP32C3_ESP32C3_RT_TIMER_H
+#define __ARCH_RISCV_SRC_ESP32C3_ESP32C3_RT_TIMER_H
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <stdint.h>
+#include <sys/types.h>
+#include <nuttx/list.h>
+
+#define RT_TIMER_NOFLAGS    (0)         /* Timer support no feature */
+#define RT_TIMER_REPEAT     (1 << 0)    /* Timer is repeat */
+
+/**
+ * RT timer state
+ */
+
+enum rt_timer_state_e
+{
+  RT_TIMER_IDLE,            /* Timer is not counting */
+  RT_TIMER_READY,           /* Timer is counting */
+  RT_TIMER_TIMEOUT,         /* Timer is timeout */
+  RT_TIMER_DELETE           /* Timer is to be delete */
+};
+
+/**
+ * RT timer data structure
+ */
+
+struct rt_timer_s
+{
+  uint64_t timeout;             /* Timeout value */
+  uint64_t alarm;               /* Timeout period */
+  void (*callback)(void *arg);  /* Callback function */
+  void *arg;                    /* Private data */
+  uint16_t flags;               /* Support feature */
+  enum rt_timer_state_e state;  /* Mark if timer is started */
+  struct list_node list;        /* Working list */
+};
+
+/**
+ * RT timer creation arguments data structure
+ */
+
+struct rt_timer_args_s
+{
+  void (*callback)(void *arg);  /* Callback function */
+  void *arg;                    /* Private data */
+};
+
+#undef EXTERN
+#if defined(__cplusplus)
+#define EXTERN extern "C"
+extern "C"
+{
+#else
+#define EXTERN extern
+#endif
+
+/****************************************************************************
+ * Name: rt_timer_create
+ *
+ * Description:
+ *   Create RT timer by into timer creation arguments
+ *
+ * Input Parameters:
+ *   args         - Input RT timer creation arguments
+ *   timer_handle - Output RT timer handle pointer
+ *
+ * Returned Value:
+ *   0 is returned on success. Otherwise, a negated errno value is returned.
+ *
+ ****************************************************************************/
+
+int rt_timer_create(const struct rt_timer_args_s *args,
+                    struct rt_timer_s **timer_handle);
+
+/****************************************************************************
+ * Name: rt_timer_start
+ *
+ * Description:
+ *   Start RT timer.
+ *
+ * Input Parameters:
+ *   timer   - RT timer pointer
+ *   timeout - Timeout value
+ *   repeat  - If the timer run repeat
+ *
+ * Returned Value:
+ *   None
+ *
+ ****************************************************************************/
+
+void rt_timer_start(struct rt_timer_s *timer,
+                    uint64_t timeout,
+                    bool repeat);
+
+/****************************************************************************
+ * Name: rt_timer_stop
+ *
+ * Description:
+ *   Stop RT timer.
+ *
+ * Input Parameters:
+ *   timer - RT timer pointer
+ *
+ * Returned Value:
+ *   None
+ *
+ ****************************************************************************/
+
+void rt_timer_stop(struct rt_timer_s *timer);
+
+/****************************************************************************
+ * Name: rt_timer_delete
+ *
+ * Description:
+ *   Stop and deleta RT timer.
+ *
+ * Input Parameters:
+ *   timer - RT timer pointer
+ *
+ * Returned Value:
+ *   None
+ *
+ ****************************************************************************/
+
+void rt_timer_delete(struct rt_timer_s *timer);
+
+/****************************************************************************
+ * Name: rt_timer_time_us
+ *
+ * Description:
+ *   Get time of RT timer by micro second.
+ *
+ * Input Parameters:
+ *   None
+ *
+ * Returned Value:
+ *   Time of RT timer by micro second.

Review comment:
       ```suggestion
    *   Time of RT timer by microsecond.
   ```




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



[GitHub] [incubator-nuttx] gustavonihei commented on a change in pull request #3040: riscv/esp32c3: Add ESP32-C3 WLAN netcard driver

Posted by GitBox <gi...@apache.org>.
gustavonihei commented on a change in pull request #3040:
URL: https://github.com/apache/incubator-nuttx/pull/3040#discussion_r594700037



##########
File path: arch/risc-v/src/esp32c3/Kconfig
##########
@@ -283,4 +297,84 @@ endif # ESP32C3_UART1
 
 endmenu
 
+menu "Real-Time Timer"
+	depends on ESP32C3_RT_TIMER
+
+config ESP32C3_RT_TIMER_TASK_NAME
+	string "Timer task name"
+	default "rt_timer"
+
+config ESP32C3_RT_TIMER_TASK_PRIORITY
+	int "Timer task priority"
+	default 223 # Lower than high priority workqueue
+
+config ESP32C3_RT_TIMER_TASK_STACK_SIZE
+	int "Timer task stack size"
+	default 2048
+
+endmenu # Real-Time Timer
+
+menu "WiFi configuration"

Review comment:
       ```suggestion
   menu "Wi-Fi configuration"
   ```




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



[GitHub] [incubator-nuttx] gustavonihei commented on a change in pull request #3040: riscv/esp32c3: Add ESP32-C3 WLAN netcard driver

Posted by GitBox <gi...@apache.org>.
gustavonihei commented on a change in pull request #3040:
URL: https://github.com/apache/incubator-nuttx/pull/3040#discussion_r594698354



##########
File path: arch/risc-v/src/esp32c3/Kconfig
##########
@@ -283,4 +297,84 @@ endif # ESP32C3_UART1
 
 endmenu
 
+menu "Real-Time Timer"
+	depends on ESP32C3_RT_TIMER
+
+config ESP32C3_RT_TIMER_TASK_NAME
+	string "Timer task name"
+	default "rt_timer"
+
+config ESP32C3_RT_TIMER_TASK_PRIORITY
+	int "Timer task priority"
+	default 223 # Lower than high priority workqueue
+
+config ESP32C3_RT_TIMER_TASK_STACK_SIZE
+	int "Timer task stack size"
+	default 2048
+
+endmenu # Real-Time Timer
+
+menu "WiFi configuration"
+	depends on ESP32C3_WIRELESS
+
+config ESP32C3_WIFI_STATIC_RXBUF_NUM
+    int "WiFi static RX buffer number"
+	default 10
+
+config ESP32C3_WIFI_DYNAMIC_RXBUF_NUM
+    int "WiFi dynamic RX buffer number"
+	default 32
+
+config ESP32C3_WIFI_DYNAMIC_TXBUF_NUM
+    int "WiFi dynamic TX buffer number"

Review comment:
       ```suggestion
         int "WiFi dynamic TX buffer number"
   ```
   nit: Alignment issue




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



[GitHub] [incubator-nuttx] gustavonihei commented on a change in pull request #3040: riscv/esp32c3: Add ESP32-C3 WLAN netcard driver

Posted by GitBox <gi...@apache.org>.
gustavonihei commented on a change in pull request #3040:
URL: https://github.com/apache/incubator-nuttx/pull/3040#discussion_r593123955



##########
File path: arch/risc-v/src/esp32c3/esp32c3_wifi_adapter.h
##########
@@ -0,0 +1,242 @@
+/****************************************************************************
+ * arch/risc-v/src/esp32c3/esp32c3_wifi_adapter.h
+ *
+ * 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.
+ *
+ ****************************************************************************/
+
+#ifndef __ARCH_RISCV_SRC_ESP32C3_ESP32C3_WIFI_ADAPTER_H
+#define __ARCH_RISCV_SRC_ESP32C3_ESP32C3_WIFI_ADAPTER_H
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <sys/types.h>
+
+#ifndef __ASSEMBLY__
+
+#undef EXTERN
+#if defined(__cplusplus)
+#define EXTERN extern "C"
+extern "C"
+{
+#else
+#define EXTERN extern
+#endif
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+/* WiFi event ID */
+
+enum wifi_adpt_evt_e
+{
+  WIFI_ADPT_EVT_STA_START = 0,
+  WIFI_ADPT_EVT_STA_CONNECT,
+  WIFI_ADPT_EVT_STA_DISCONNECT,
+  WIFI_ADPT_EVT_STA_AUTHMODE_CHANGE,
+  WIFI_ADPT_EVT_STA_STOP,
+  WIFI_ADPT_EVT_MAX,
+};
+
+/* WiFi event callback function */
+
+typedef void (*wifi_evt_cb_t)(void *p);
+
+typedef void (* wifi_tx_done_cb_t)(uint8_t ifidx, uint8_t *data,
+                                   uint16_t *len, bool txstatus);
+
+/****************************************************************************
+ * Public Function Prototypes
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: esp_wifi_adapter_init
+ *
+ * Description:
+ *   Initialize ESP32 WiFi adapter
+ *
+ * Input Parameters:
+ *   None
+ *
+ * Returned Value:
+ *   0 if success or -1 if fail
+ *
+ ****************************************************************************/
+
+int esp_wifi_adapter_init(void);
+
+/****************************************************************************
+ * Name: esp_wifi_notify_subscribe
+ *
+ * Description:
+ *   Enable event notification
+ *
+ * Input Parameters:
+ *   pid   - Task PID
+ *   event - Signal event data pointer
+ *
+ * Returned Value:
+ *   0 if success or -1 if fail
+ *
+ ****************************************************************************/
+
+int esp_wifi_notify_subscribe(pid_t pid, FAR struct sigevent *event);
+
+/****************************************************************************
+ * Name: esp_wifi_sta_send_data
+ *
+ * Description:
+ *   Use WiFi station interface to send 802.3 frame
+ *
+ * Input Parameters:
+ *   pbuf - Packet buffer pointer
+ *   len  - Packet length
+ *
+ * Returned Value:
+ *   0 if success or others if fail
+ *
+ ****************************************************************************/
+
+int esp_wifi_sta_send_data(void *pbuf, uint32_t len);
+
+/****************************************************************************
+ * Name: esp_wifi_sta_register_recv_cb
+ *
+ * Description:
+ *   Regitser WiFi receive packet callback function

Review comment:
       ```suggestion
    *   Register WiFi receive packet callback function
   ```




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



[GitHub] [incubator-nuttx] Ouss4 commented on a change in pull request #3040: riscv/esp32c3: Add ESP32-C3 WLAN netcard driver

Posted by GitBox <gi...@apache.org>.
Ouss4 commented on a change in pull request #3040:
URL: https://github.com/apache/incubator-nuttx/pull/3040#discussion_r593116852



##########
File path: arch/risc-v/src/esp32c3/esp32c3_irq.c
##########
@@ -166,6 +189,52 @@ void up_disable_irq(int cpuint)
   leave_critical_section(irqstate);
 }
 
+/****************************************************************************
+ * Name: esp32c3_bind_irq
+ *
+ * Description:
+ *   Bind IRQ and resource with given parameters.
+ *
+ * Input Parameters:
+ *   cpuint    - CPU interrupt ID
+ *   periphid  - Peripheral ID
+ *   prio      - Interrupt priority
+ *   flags     - Interrupt flags
+ *
+ * Returned Value:
+ *   Allocated CPU interrupt on success, a negated error on failure.
+ *
+ ****************************************************************************/
+
+int esp32c3_bind_irq(uint8_t cpuint, uint8_t periphid, uint8_t prio,

Review comment:
       My issue is this function is almost exactly the same as `esp32c3_irq_request`.  It just bypasses the interrupt to peripheral map.




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



[GitHub] [incubator-nuttx] donghengqaz commented on a change in pull request #3040: riscv/esp32c3: Add ESP32-C3 WLAN netcard driver

Posted by GitBox <gi...@apache.org>.
donghengqaz commented on a change in pull request #3040:
URL: https://github.com/apache/incubator-nuttx/pull/3040#discussion_r593110165



##########
File path: arch/risc-v/src/esp32c3/esp32c3_irq.c
##########
@@ -166,6 +189,52 @@ void up_disable_irq(int cpuint)
   leave_critical_section(irqstate);
 }
 
+/****************************************************************************
+ * Name: esp32c3_bind_irq
+ *
+ * Description:
+ *   Bind IRQ and resource with given parameters.
+ *
+ * Input Parameters:
+ *   cpuint    - CPU interrupt ID
+ *   periphid  - Peripheral ID
+ *   prio      - Interrupt priority
+ *   flags     - Interrupt flags
+ *
+ * Returned Value:
+ *   Allocated CPU interrupt on success, a negated error on failure.
+ *
+ ****************************************************************************/
+
+int esp32c3_bind_irq(uint8_t cpuint, uint8_t periphid, uint8_t prio,

Review comment:
       I add reserved CPU interrupt for WiFi: https://github.com/apache/incubator-nuttx/pull/3040/files#diff-0c00cebfe74b712116ea0e572904991de5f9c97c89273e53e282fa799506d048R104, later will also reserve for BT.




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



[GitHub] [incubator-nuttx] Ouss4 commented on a change in pull request #3040: riscv/esp32c3: Add ESP32-C3 WLAN netcard driver

Posted by GitBox <gi...@apache.org>.
Ouss4 commented on a change in pull request #3040:
URL: https://github.com/apache/incubator-nuttx/pull/3040#discussion_r593012573



##########
File path: arch/risc-v/src/esp32c3/esp32c3_irq.c
##########
@@ -166,6 +189,52 @@ void up_disable_irq(int cpuint)
   leave_critical_section(irqstate);
 }
 
+/****************************************************************************
+ * Name: esp32c3_bind_irq
+ *
+ * Description:
+ *   Bind IRQ and resource with given parameters.
+ *
+ * Input Parameters:
+ *   cpuint    - CPU interrupt ID
+ *   periphid  - Peripheral ID
+ *   prio      - Interrupt priority
+ *   flags     - Interrupt flags
+ *
+ * Returned Value:
+ *   Allocated CPU interrupt on success, a negated error on failure.
+ *
+ ****************************************************************************/
+
+int esp32c3_bind_irq(uint8_t cpuint, uint8_t periphid, uint8_t prio,

Review comment:
       Why was this function created? Isn't doing the same thing as `esp32_request_irq`?




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