riscv/esp32c3: Add ESP32-C3 WLAN netcard driver

This commit is contained in:
Dong Heng
2021-03-08 18:00:09 +08:00
committed by Alan Carvalho de Assis
parent b2f5031e96
commit 458caf2732
22 changed files with 8365 additions and 27 deletions
+5
View File
@@ -45,6 +45,11 @@ config ARCH_CHIP_ESP32C3
select RV32IM_HW_MULDIV
select ARCH_VECNOTIRQ
select ARCH_HAVE_RESET
select LIBC_ARCH_MEMCHR
select LIBC_ARCH_MEMCMP
select LIBC_ARCH_MEMCCMP
select LIBC_ARCH_MEMMOVE
select LIBC_ARCH_MEMSET
---help---
Espressif ESP32-C3 (RV32IMC).
+4
View File
@@ -127,6 +127,10 @@
#define ESP32C3_CPUINT_MIN 1
#define ESP32C3_CPUINT_MAX 31
/* Reserved CPU interrupt for specific drivers */
#define ESP32C3_CPUINT_WMAC 1 /* Wi-Fi MAC */
/* IRQ numbers. */
/* ecall is dispatched like normal interrupts. It occupies an IRQ number. */
+2
View File
@@ -0,0 +1,2 @@
/esp-wireless-drivers-3rdparty
/*.zip
+94
View File
@@ -152,6 +152,10 @@ config ESP32C3_CPU_FREQ_MHZ
default 80 if ESP32C3_CPU_FREQ_80
default 160 if ESP32C3_CPU_FREQ_160
config ESP32C3_RT_TIMER
bool "Real-time Timer"
default n
menu "ESP32-C3 Peripheral Support"
config ESP32C3_UART
@@ -235,6 +239,16 @@ config ESP32C3_RWDT
to have the RTC module reset, please, use the Timers' Module WDTs.
They will only reset Main System.
config ESP32C3_WIRELESS
bool "Wireless"
default n
select NET
select ARCH_PHY_INTERRUPT
select ESP32C3_RT_TIMER
select ESP32C3_TIMER0
---help---
Enable Wireless support
endmenu # ESP32-C3 Peripheral Support
menu "I2C Configuration"
@@ -285,4 +299,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 "Wi-Fi configuration"
depends on ESP32C3_WIRELESS
config ESP32C3_WIFI_STATIC_RXBUF_NUM
int "Wi-Fi static RX buffer number"
default 10
config ESP32C3_WIFI_DYNAMIC_RXBUF_NUM
int "Wi-Fi dynamic RX buffer number"
default 32
config ESP32C3_WIFI_DYNAMIC_TXBUF_NUM
int "Wi-Fi dynamic TX buffer number"
default 32
config ESP32C3_WIFI_TX_AMPDU
bool "Wi-Fi TX AMPDU"
default y
config ESP32C3_WIFI_RX_AMPDU
bool "Wi-Fi RX AMPDU"
default y
config ESP32C3_WIFI_RXBA_AMPDU_WZ
int "Wi-Fi 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 Wi-Fi Parameters"
default n
depends on !DISABLE_MOUNTPOINT
help
If you enable this option, Wi-Fi 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
- Wi-Fi hardware configuration parameters
config ESP32C3_WIFI_FS_MOUNTPT
string "Save Wi-Fi Parameters"
default "/mnt/esp/wifi"
depends on ESP32C3_WIFI_SAVE_PARAM
help
Mount point of Wi-Fi storage file system.
endmenu # ESP32C3_WIRELESS
endif # ARCH_CHIP_ESP32C3
+40 -1
View File
@@ -75,4 +75,43 @@ CHIP_CSRCS += esp32c3_tim.c
ifeq ($(CONFIG_TIMER),y)
CHIP_CSRCS += esp32c3_tim_lowerhalf.c
endif
endif
endif
ifeq ($(CONFIG_ESP32C3_RT_TIMER),y)
CHIP_CSRCS += esp32c3_rt_timer.c
endif
ifeq ($(CONFIG_ESP32C3_WIRELESS),y)
WIRELESS_DRV_UNPACK = esp-wireless-drivers-3rdparty
WIRELESS_DRV_ID = 3cc7f67
WIRELESS_DRV_ZIP = $(WIRELESS_DRV_ID).zip
WIRELESS_DRV_URL = https://github.com/espressif/esp-wireless-drivers-3rdparty/archive
$(WIRELESS_DRV_ZIP):
$(Q) echo "Downloading: ESP Wireless Drivers"
$(Q) curl -L $(WIRELESS_DRV_URL)/$(WIRELESS_DRV_ZIP) -o chip/$(WIRELESS_DRV_ZIP)
chip/$(WIRELESS_DRV_UNPACK): $(WIRELESS_DRV_ZIP)
$(Q) echo "Unpacking: ESP Wireless Drivers"
$(Q) unzip -oqq chip/$(WIRELESS_DRV_ZIP) -d chip/
$(Q) mv chip/$(WIRELESS_DRV_UNPACK)-$(WIRELESS_DRV_ID)* chip/$(WIRELESS_DRV_UNPACK)
$(Q) touch chip/$(WIRELESS_DRV_UNPACK)
context:: chip/$(WIRELESS_DRV_UNPACK)
clean_context::
$(call DELFILE, chip/$(WIRELESS_DRV_ZIP))
$(call DELDIR, chip/$(WIRELESS_DRV_UNPACK))
INCLUDES += $(shell $(INCDIR) "$(CC)" $(ARCH_SRCDIR)$(DELIM)chip$(DELIM)esp-wireless-drivers-3rdparty$(DELIM)include)
INCLUDES += $(shell $(INCDIR) "$(CC)" $(ARCH_SRCDIR)$(DELIM)chip$(DELIM)esp-wireless-drivers-3rdparty$(DELIM)include$(DELIM)esp32c3)
CHIP_CSRCS += esp32c3_wlan.c esp32c3_wifi_adapter.c
EXTRA_LIBPATHS += -L $(ARCH_SRCDIR)$(DELIM)chip$(DELIM)esp-wireless-drivers-3rdparty$(DELIM)libs$(DELIM)esp32c3
EXTRA_LIBS += -lcore -lnet80211 -lpp -lsmartconfig -lcoexist -lespnow -lphy -lwpa_supplicant -lwapi
# Due to some Wi-Fi related libraries, the option is need to avoid linking too much
# unused functions.
LDFLAGS += --gc-sections
endif
+74 -21
View File
@@ -54,6 +54,18 @@
#define CPUINT_UNASSIGNED 0xff
/* Wi-Fi reserved CPU interrupt bit */
#ifdef CONFIG_ESP32C3_WIRELESS
# define CPUINT_WMAC_MAP (1 << ESP32C3_CPUINT_WMAC)
#else
# define CPUINT_WMAC_MAP 0
#endif
/* Reserved CPU interrupt bits */
#define CPUINT_RESERVED_MAPS (CPUINT_WMAC_MAP)
/****************************************************************************
* Public Data
****************************************************************************/
@@ -82,6 +94,17 @@ void up_irqinitialize(void)
memset(g_cpuint_map, CPUINT_UNASSIGNED, ESP32C3_CPUINT_MAX);
/**
* Initialize specific driver's CPU interrupt ID:
* Object | CPU INT | Pheripheral
* | |
* Wi-Fi | 1 | 1
*/
#ifdef CONFIG_ESP32C3_WIRELESS
g_cpuint_map[ESP32C3_CPUINT_WMAC] = ESP32C3_PERIPH_WIFI_MAC_NMI;
#endif
/* Clear all peripheral interrupts from "bootloader" */
for (periphid = 0; periphid < ESP32C3_NPERIPHERALS; periphid++)
@@ -166,6 +189,50 @@ 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:
* None.
*
****************************************************************************/
void esp32c3_bind_irq(uint8_t cpuint, uint8_t periphid, uint8_t prio,
uint32_t flags)
{
/* Disable the CPU interrupt. */
resetbits(1 << cpuint, INTERRUPT_CPU_INT_ENABLE_REG);
/* Set the interrupt priority. */
putreg32(prio, INTERRUPT_CPU_INT_PRI_0_REG + cpuint * 4);
/* Set the interrupt type (Edge or Level). */
if (flags & ESP32C3_INT_EDGE)
{
setbits(1 << cpuint, INTERRUPT_CPU_INT_TYPE_REG);
}
else
{
resetbits(1 << cpuint, INTERRUPT_CPU_INT_TYPE_REG);
}
/* Map the CPU interrupt ID to the peripheral. */
putreg32(cpuint, DR_REG_INTERRUPT_BASE + periphid * 4);
}
/****************************************************************************
* Name: esp32c3_request_irq
*
@@ -198,6 +265,11 @@ int esp32c3_request_irq(uint8_t periphid, uint8_t prio, uint32_t flags)
/* Skip over enabled interrupts. NOTE: bit 0 is reserved. */
regval = getreg32(INTERRUPT_CPU_INT_ENABLE_REG);
/* Skip over reserved CPU interrupts */
regval |= CPUINT_RESERVED_MAPS;
for (cpuint = 1; cpuint <= ESP32C3_CPUINT_MAX; cpuint++)
{
if (!(regval & (1 << cpuint)))
@@ -224,28 +296,9 @@ int esp32c3_request_irq(uint8_t periphid, uint8_t prio, uint32_t flags)
g_cpuint_map[cpuint] = periphid;
/* Set the interrupt priority. */
/* Configure IRQ */
putreg32(prio, INTERRUPT_CPU_INT_PRI_0_REG + cpuint * 4);
/* Set the interrupt type (Edge or Level). */
if (flags & ESP32C3_INT_EDGE)
{
setbits(1 << cpuint, INTERRUPT_CPU_INT_TYPE_REG);
}
else
{
resetbits(1 << cpuint, INTERRUPT_CPU_INT_TYPE_REG);
}
/* Map the CPU interrupt ID to the peripheral. */
putreg32(cpuint, DR_REG_INTERRUPT_BASE + periphid * 4);
/* Disable the CPU interrupt. */
resetbits(1 << cpuint, INTERRUPT_CPU_INT_ENABLE_REG);
esp32c3_bind_irq(cpuint, periphid, prio, flags);
}
else
{
+20
View File
@@ -47,6 +47,26 @@
void up_irqinitialize(void);
/****************************************************************************
* 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:
* None.
*
****************************************************************************/
void esp32c3_bind_irq(uint8_t cpuint, uint8_t periphid, uint8_t prio,
uint32_t flags);
/****************************************************************************
* Name: esp32c3_request_irq
*
File diff suppressed because it is too large Load Diff
+206
View File
@@ -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 delete 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 microsecond.
*
* Input Parameters:
* None
*
* Returned Value:
* Time of RT timer by microsecond.
*
****************************************************************************/
uint64_t rt_timer_time_us(void);
/****************************************************************************
* Name: esp32c3_rt_timer_init
*
* Description:
* Initialize ESP32-C3 RT timer.
*
* Input Parameters:
* None
*
* Returned Value:
* 0 is returned on success. Otherwise, a negated errno value is returned.
*
****************************************************************************/
int esp32c3_rt_timer_init(void);
/****************************************************************************
* Name: esp32c3_rt_timer_deinit
*
* Description:
* Deinitialize ESP32-C3 RT timer.
*
* Input Parameters:
* None
*
* Returned Value:
* None.
*
****************************************************************************/
void esp32c3_rt_timer_deinit(void);
#ifdef __cplusplus
}
#endif
#undef EXTERN
#endif /* __ARCH_RISCV_SRC_ESP32C3_ESP32C3_RT_TIMER_H */
+35 -1
View File
@@ -685,7 +685,7 @@ FAR struct esp32c3_tim_dev_s *esp32c3_tim_init(int timer)
switch (timer)
{
#if defined(CONFIG_ESP32C3_TIMER0)
#if defined(CONFIG_ESP32C3_TIMER0) && !defined(CONFIG_ESP32C3_RT_TIMER)
case 0:
{
tim = &g_esp32c3_tim0_priv;
@@ -738,3 +738,37 @@ void esp32c3_tim_deinit(FAR struct esp32c3_tim_dev_s *dev)
tim = (FAR struct esp32c3_tim_priv_s *)dev;
tim->inuse = false;
}
/****************************************************************************
* Name: esp32c3_tim0_init
*
* Description:
* Initialize TIMER0 device, if software real-time timer
* (CONFIG_ESP32C3_RT_TIMER) is enabled.
*
* Parameters:
* None
*
* Returned Values:
* If the initialization is successful, return a pointer to the timer
* driver struct associated to that timer instance.
* In case it fails, return NULL.
*
****************************************************************************/
#ifdef CONFIG_ESP32C3_RT_TIMER
FAR struct esp32c3_tim_dev_s *esp32c3_tim0_init(void)
{
FAR struct esp32c3_tim_priv_s *tim = &g_esp32c3_tim0_priv;
if (tim->inuse == true)
{
tmrerr("ERROR: TIMER0 is already in use\n");
tim = NULL;
}
return (FAR struct esp32c3_tim_dev_s *)tim;
}
#endif
+8
View File
@@ -135,4 +135,12 @@ struct esp32c3_tim_ops_s
FAR struct esp32c3_tim_dev_s *esp32c3_tim_init(int timer);
void esp32c3_tim_deinit(FAR struct esp32c3_tim_dev_s *dev);
/****************************************************************************
* The Timer0 is used by RT-Timer of wireless driver, so please don't use it
* in any other components.
****************************************************************************/
#ifdef CONFIG_ESP32C3_RT_TIMER
FAR struct esp32c3_tim_dev_s *esp32c3_tim0_init(void);
#endif
#endif /* __ARCH_RISCV_SRC_ESP32C3_ESP32C3_TIM_H */
@@ -97,7 +97,7 @@ static const struct timer_ops_s g_esp32c3_timer_ops =
.ioctl = NULL,
};
#ifdef CONFIG_ESP32C3_TIMER0
#if defined(CONFIG_ESP32C3_TIMER0) && !defined(CONFIG_ESP32C3_RT_TIMER)
/* TIMER0 lower-half */
static struct esp32c3_timer_lowerhalf_s g_esp32c3_timer0_lowerhalf =
@@ -500,7 +500,7 @@ int esp32c3_timer_initialize(FAR const char *devpath, uint8_t timer)
switch (timer)
{
#ifdef CONFIG_ESP32C3_TIMER0
#if defined(CONFIG_ESP32C3_TIMER0) && !defined(CONFIG_ESP32C3_RT_TIMER)
case 0:
{
lower = &g_esp32c3_timer0_lowerhalf;
File diff suppressed because it is too large Load Diff
@@ -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
****************************************************************************/
/* Wi-Fi 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,
};
/* Wi-Fi 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 Wi-Fi 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 Wi-Fi 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 Wi-Fi 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 Wi-Fi receive callback input eb pointer
*
* Input Parameters:
* eb - Wi-Fi receive callback input eb pointer
*
* Returned Value:
* None
*
****************************************************************************/
void esp_wifi_free_eb(void *eb);
/****************************************************************************
* Name: esp_wifi_set_password
*
* Description:
* Set Wi-Fi 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 Wi-Fi 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 Wi-Fi connection action
*
* Input Parameters:
* None
*
* Returned Value:
* 0 if success or -1 if fail
*
****************************************************************************/
int esp_wifi_connect_internal(void);
/****************************************************************************
* Name: esp_wifi_sta_register_txdone_cb
*
* Description:
* Register the txDone callback function of type wifi_tx_done_cb_t
*
* Input Parameters:
* callback - The callback function
*
* Returned Value:
* 0 if success or -1 if fail
*
****************************************************************************/
int esp_wifi_sta_register_txdone_cb(void *callback);
#ifdef __cplusplus
}
#endif
#undef EXTERN
#endif /* __ASSEMBLY__ */
#endif /* __ARCH_RISCV_SRC_ESP32C3_ESP32C3_WIFI_ADAPTER_H */
File diff suppressed because it is too large Load Diff
+67
View File
@@ -0,0 +1,67 @@
/****************************************************************************
* arch/risc-v/src/esp32c3/esp32c3_wlan.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_WLAN_H
#define __ARCH_RISCV_SRC_ESP32C3_ESP32C3_WLAN_H
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#ifndef __ASSEMBLY__
#undef EXTERN
#if defined(__cplusplus)
#define EXTERN extern "C"
extern "C"
{
#else
#define EXTERN extern
#endif
/****************************************************************************
* Public Function Prototypes
****************************************************************************/
/****************************************************************************
* Name: esp32c3_wlan_sta_initialize
*
* Description:
* Initialize the ESP32-C3 WLAN station netcard driver
*
* Input Parameters:
* None
*
* Returned Value:
* OK on success; Negated errno on failure.
*
****************************************************************************/
int esp32c3_wlan_sta_initialize(void);
#ifdef __cplusplus
}
#endif
#undef EXTERN
#endif /* __ASSEMBLY__ */
#endif /* __ARCH_RISCV_SRC_ESP32C3_ESP32C3_WLAN_H */
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,66 @@
#
# This file is autogenerated: PLEASE DO NOT EDIT IT.
#
# You can use "make menuconfig" to make any modifications to the installed .config file.
# You can then do "make savedefconfig" to generate a new defconfig file that includes your
# modifications.
#
# CONFIG_NSH_ARGCAT is not set
# CONFIG_NSH_CMDOPT_HEXDUMP is not set
# CONFIG_NSH_CMDPARMS is not set
CONFIG_ARCH="risc-v"
CONFIG_ARCH_BOARD="esp32c3-devkit"
CONFIG_ARCH_BOARD_ESP32C3_DEVKIT=y
CONFIG_ARCH_CHIP="esp32c3"
CONFIG_ARCH_CHIP_ESP32C3=y
CONFIG_ARCH_CHIP_ESP32C3WROOM02=y
CONFIG_ARCH_INTERRUPTSTACK=1536
CONFIG_ARCH_RISCV=y
CONFIG_ARCH_STACKDUMP=y
CONFIG_BOARD_LOOPSPERMSEC=16717
CONFIG_BUILTIN=y
CONFIG_DRIVERS_IEEE80211=y
CONFIG_DRIVERS_WIRELESS=y
CONFIG_ESP32C3_WIRELESS=y
CONFIG_FS_PROCFS=y
CONFIG_HAVE_CXX=y
CONFIG_HAVE_CXXINITIALIZE=y
CONFIG_IDLETHREAD_STACKSIZE=3072
CONFIG_INTELHEX_BINARY=y
CONFIG_NAME_MAX=48
CONFIG_NETDB_DNSCLIENT=y
CONFIG_NETDEV_LATEINIT=y
CONFIG_NETDEV_PHY_IOCTL=y
CONFIG_NETDEV_WIRELESS_IOCTL=y
CONFIG_NET_BROADCAST=y
CONFIG_NET_ETH_PKTSIZE=1514
CONFIG_NET_ICMP=y
CONFIG_NET_ICMP_SOCKET=y
CONFIG_NET_SOCKOPTS=y
CONFIG_NET_TCP=y
CONFIG_NET_UDP=y
CONFIG_NFILE_DESCRIPTORS=8
CONFIG_NSH_ARCHINIT=y
CONFIG_NSH_BUILTIN_APPS=y
CONFIG_NSH_FILEIOSIZE=512
CONFIG_NSH_LINELEN=64
CONFIG_NSH_READLINE=y
CONFIG_PREALLOC_TIMERS=4
CONFIG_PTHREAD_MUTEX_TYPES=y
CONFIG_RAW_BINARY=y
CONFIG_RR_INTERVAL=200
CONFIG_SCHED_LPWORK=y
CONFIG_SCHED_WAITPID=y
CONFIG_SIG_DEFAULT=y
CONFIG_START_DAY=6
CONFIG_START_MONTH=12
CONFIG_START_YEAR=2011
CONFIG_SYSTEM_DHCPC_RENEW=y
CONFIG_SYSTEM_NSH=y
CONFIG_SYSTEM_PING=y
CONFIG_UART0_SERIAL_CONSOLE=y
CONFIG_USER_ENTRYPOINT="nsh_main"
CONFIG_WIRELESS=y
CONFIG_WIRELESS_WAPI=y
CONFIG_WIRELESS_WAPI_CMDTOOL=y
CONFIG_WIRELESS_WAPI_STACKSIZE=4096
@@ -36,6 +36,11 @@ SECTIONS
*(.iram1)
*(.iram1.*)
*(.wifi0iram .wifi0iram.*)
*(.wifirxiram .wifirxiram.*)
*(.wifislpiram .wifislpiram.*)
*(.wifislprxiram .wifislprxiram.*)
} >iram0_0_seg
/* This section is required to skip .iram0.text area because iram0_0_seg
@@ -134,6 +139,9 @@ SECTIONS
*(.rodata)
*(.rodata.*)
*(.srodata.*)
*(.irom1.text) /* catch stray ICACHE_RODATA_ATTR */
*(.gnu.linkonce.r.*)
*(.rodata1)
@@ -1527,7 +1527,6 @@ lmacReachShortLimit = 0x4000161c;
lmacRecycleMPDU = 0x40001620;
lmacRxDone = 0x40001624;
lmacSetTxFrame = 0x40001628;
lmacTxDone = 0x4000162c;
lmacTxFrame = 0x40001630;
mac_tx_set_duration = 0x40001634;
mac_tx_set_htsig = 0x40001638;
@@ -1933,3 +1932,28 @@ rom_pll_correct_dcap = 0x40001b1c;
rom_phy_en_hw_set_freq = 0x40001b20;
rom_phy_dis_hw_set_freq = 0x40001b24;
rom_pll_vol_cal = 0x40001b28;
/***************************************
Group memory and string
***************************************/
memset = 0x40000354;
memcpy = 0x40000358;
memmove = 0x4000035c;
memcmp = 0x40000360;
memccpy = 0x400003c4;
memchr = 0x400003c8;
memrchr = 0x400003cc;
strcpy = 0x40000364;
strncpy = 0x40000368;
strcmp = 0x4000036c;
strncmp = 0x40000370;
strlen = 0x40000374;
strstr = 0x40000378;
bzero = 0x4000037c;
/***************************************
Redefine functions
***************************************/
PROVIDE ( esp_rom_delay_us = ets_delay_us );
@@ -37,6 +37,8 @@
#include <nuttx/fs/fs.h>
#include "esp32c3_wlan.h"
#include "esp32c3-devkit.h"
/****************************************************************************
@@ -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 Wi-Fi\n");
return ret;
}
#endif
/* If we got here then perhaps not all initialization was successful, but
* at least enough succeeded to bring-up NSH with perhaps reduced
* capabilities.
@@ -56,7 +56,7 @@ int board_tim_init(void)
{
int ret = OK;
#ifdef CONFIG_ESP32C3_TIMER0
#if defined(CONFIG_ESP32C3_TIMER0) && !defined(CONFIG_ESP32C3_RT_TIMER)
ret = esp32c3_timer_initialize("/dev/timer0", ESP32C3_TIMER0);
if (ret < 0)
{