mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-10 04:43:33 +00:00
Merge wifi branch commit '588d384393536a040f899b382890316c56061b6a' into feature/wifi-stage-one
This commit is contained in:
@@ -206,15 +206,7 @@ void user_start_cpu0(void) {
|
||||
ets_setup_syscalls();
|
||||
do_global_ctors();
|
||||
|
||||
// TODO: consider ethernet interface
|
||||
|
||||
#if CONFIG_WIFI_ENABLED
|
||||
#if 1 //workaround
|
||||
for (uint8_t i = 5; i < 8; i++) {
|
||||
ets_printf("erase sector %d\n", i);
|
||||
spi_flash_erase_sector(i);
|
||||
}
|
||||
#endif
|
||||
ets_printf("nvs_flash_init\n");
|
||||
esp_err_t ret = nvs_flash_init(5, 3);
|
||||
if (ret != ESP_OK) {
|
||||
@@ -225,6 +217,7 @@ void user_start_cpu0(void) {
|
||||
|
||||
esp_event_init(NULL);
|
||||
|
||||
// TODO: consider ethernet interface
|
||||
tcpip_adapter_init();
|
||||
|
||||
#endif
|
||||
|
@@ -28,26 +28,10 @@
|
||||
#define ESP32_WORKAROUND 1
|
||||
|
||||
#if CONFIG_WIFI_ENABLED
|
||||
|
||||
#ifdef ESP32_WORKAROUND
|
||||
|
||||
extern SemaphoreHandle_t stdio_mutex_tx;
|
||||
#define os_printf(fmt, ...) do {\
|
||||
if (!stdio_mutex_tx) {\
|
||||
stdio_mutex_tx = xSemaphoreCreateMutex();\
|
||||
}\
|
||||
\
|
||||
xSemaphoreTake(stdio_mutex_tx, portMAX_DELAY);\
|
||||
ets_printf(fmt, ##__VA_ARGS__);\
|
||||
xSemaphoreGive(stdio_mutex_tx);\
|
||||
} while (0)
|
||||
|
||||
#endif
|
||||
|
||||
static xQueueHandle g_event_handler = NULL;
|
||||
static system_event_cb_t g_event_handler_cb;
|
||||
|
||||
#define WIFI_DEBUG os_printf
|
||||
#define WIFI_DEBUG printf
|
||||
#define WIFI_API_CALL_CHECK(info, api_call, ret) \
|
||||
do{\
|
||||
esp_err_t __err = (api_call);\
|
||||
@@ -79,6 +63,7 @@ static system_event_handle_t g_system_event_handle_table[] = {
|
||||
{SYSTEM_EVENT_STA_CONNECTED, system_event_sta_connected_handle_default},
|
||||
{SYSTEM_EVENT_STA_DISCONNECTED, system_event_sta_disconnected_handle_default},
|
||||
{SYSTEM_EVENT_STA_AUTHMODE_CHANGE, NULL},
|
||||
{SYSTEM_EVENT_STA_GOTIP, NULL},
|
||||
{SYSTEM_EVENT_AP_START, system_event_ap_start_handle_default},
|
||||
{SYSTEM_EVENT_AP_STOP, system_event_ap_stop_handle_default},
|
||||
{SYSTEM_EVENT_AP_STACONNECTED, NULL},
|
||||
@@ -131,10 +116,17 @@ esp_err_t system_event_sta_stop_handle_default(system_event_t *event)
|
||||
|
||||
esp_err_t system_event_sta_connected_handle_default(system_event_t *event)
|
||||
{
|
||||
tcpip_adapter_dhcp_status_t status;
|
||||
|
||||
WIFI_API_CALL_CHECK("esp_wifi_reg_rxcb", esp_wifi_reg_rxcb(WIFI_IF_STA, (wifi_rxcb_t)tcpip_adapter_sta_input), ESP_OK);
|
||||
|
||||
tcpip_adapter_up(TCPIP_ADAPTER_IF_STA);
|
||||
tcpip_adapter_dhcpc_start(TCPIP_ADAPTER_IF_STA);
|
||||
|
||||
tcpip_adapter_dhcpc_get_status(TCPIP_ADAPTER_IF_STA, &status);
|
||||
|
||||
if (status == TCPIP_ADAPTER_DHCP_INIT) {
|
||||
tcpip_adapter_dhcpc_start(TCPIP_ADAPTER_IF_STA);
|
||||
}
|
||||
|
||||
return ESP_OK;
|
||||
}
|
||||
@@ -157,78 +149,110 @@ static esp_err_t esp_wifi_post_event_to_user(system_event_t *event)
|
||||
|
||||
static esp_err_t esp_system_event_debug(system_event_t *event)
|
||||
{
|
||||
system_event_sta_scan_done_t *scan_done;
|
||||
system_event_sta_connected_t *connected;
|
||||
system_event_sta_disconnected_t *disconnected;
|
||||
system_event_sta_authmode_change_t *auth_change;
|
||||
system_event_ap_staconnected_t *staconnected;
|
||||
system_event_ap_stadisconnected_t *stadisconnected;
|
||||
system_event_ap_probe_req_rx_t *ap_probereqrecved;
|
||||
|
||||
if (event == NULL) {
|
||||
os_printf("Error: event is null!\n");
|
||||
printf("Error: event is null!\n");
|
||||
return ESP_FAIL;
|
||||
}
|
||||
|
||||
os_printf("received event: ");
|
||||
printf("received event: ");
|
||||
switch (event->event_id) {
|
||||
case SYSTEM_EVENT_WIFI_READY:
|
||||
os_printf("SYSTEM_EVENT_WIFI_READY\n");
|
||||
{
|
||||
printf("SYSTEM_EVENT_WIFI_READY\n");
|
||||
break;
|
||||
}
|
||||
case SYSTEM_EVENT_SCAN_DONE:
|
||||
{
|
||||
system_event_sta_scan_done_t *scan_done;
|
||||
scan_done = &event->event_info.scan_done;
|
||||
os_printf("SYSTEM_EVENT_SCAN_DONE\nstatus:%d, number:%d\n", \
|
||||
printf("SYSTEM_EVENT_SCAN_DONE\nstatus:%d, number:%d\n", \
|
||||
scan_done->status, scan_done->number);
|
||||
break;
|
||||
}
|
||||
case SYSTEM_EVENT_STA_START:
|
||||
os_printf("SYSTEM_EVENT_STA_START\n");
|
||||
{
|
||||
printf("SYSTEM_EVENT_STA_START\n");
|
||||
break;
|
||||
}
|
||||
case SYSTEM_EVENT_STA_STOP:
|
||||
os_printf("SYSTEM_EVENT_STA_STOP\n");
|
||||
{
|
||||
printf("SYSTEM_EVENT_STA_STOP\n");
|
||||
break;
|
||||
}
|
||||
case SYSTEM_EVENT_STA_CONNECTED:
|
||||
{
|
||||
system_event_sta_connected_t *connected;
|
||||
connected = &event->event_info.connected;
|
||||
os_printf("SYSTEM_EVENT_STA_CONNECTED\nssid:%s, ssid_len:%d, bssid:%02x:%02x:%02x:%02x:%02x:%02x, channel:%d\n", \
|
||||
printf("SYSTEM_EVENT_STA_CONNECTED\nssid:%s, ssid_len:%d, bssid:%02x:%02x:%02x:%02x:%02x:%02x, channel:%d\n", \
|
||||
connected->ssid, connected->ssid_len, connected->bssid[0], connected->bssid[0], connected->bssid[1], \
|
||||
connected->bssid[3], connected->bssid[4], connected->bssid[5], connected->channel);
|
||||
break;
|
||||
}
|
||||
case SYSTEM_EVENT_STA_DISCONNECTED:
|
||||
{
|
||||
system_event_sta_disconnected_t *disconnected;
|
||||
disconnected = &event->event_info.disconnected;
|
||||
os_printf("SYSTEM_EVENT_STA_DISCONNECTED\nssid:%s, ssid_len:%d, bssid:%02x:%02x:%02x:%02x:%02x:%02x, reason:%d\n", \
|
||||
printf("SYSTEM_EVENT_STA_DISCONNECTED\nssid:%s, ssid_len:%d, bssid:%02x:%02x:%02x:%02x:%02x:%02x, reason:%d\n", \
|
||||
disconnected->ssid, disconnected->ssid_len, disconnected->bssid[0], disconnected->bssid[0], disconnected->bssid[1], \
|
||||
disconnected->bssid[3], disconnected->bssid[4], disconnected->bssid[5], disconnected->reason);
|
||||
break;
|
||||
}
|
||||
case SYSTEM_EVENT_STA_AUTHMODE_CHANGE:
|
||||
{
|
||||
system_event_sta_authmode_change_t *auth_change;
|
||||
auth_change = &event->event_info.auth_change;
|
||||
os_printf("SYSTEM_EVENT_STA_AUTHMODE_CHNAGE\nold_mode:%d, new_mode:%d\n", auth_change->old_mode, auth_change->new_mode);
|
||||
printf("SYSTEM_EVENT_STA_AUTHMODE_CHNAGE\nold_mode:%d, new_mode:%d\n", auth_change->old_mode, auth_change->new_mode);
|
||||
break;
|
||||
}
|
||||
case SYSTEM_EVENT_STA_GOTIP:
|
||||
{
|
||||
system_event_sta_gotip_t *got_ip;
|
||||
got_ip = &event->event_info.got_ip;
|
||||
printf("SYSTEM_EVENT_STA_GOTIP\n");
|
||||
break;
|
||||
}
|
||||
case SYSTEM_EVENT_AP_START:
|
||||
os_printf("SYSTEM_EVENT_AP_START\n");
|
||||
{
|
||||
printf("SYSTEM_EVENT_AP_START\n");
|
||||
break;
|
||||
}
|
||||
case SYSTEM_EVENT_AP_STOP:
|
||||
os_printf("SYSTEM_EVENT_AP_STOP\n");
|
||||
{
|
||||
printf("SYSTEM_EVENT_AP_STOP\n");
|
||||
break;
|
||||
}
|
||||
case SYSTEM_EVENT_AP_STACONNECTED:
|
||||
{
|
||||
system_event_ap_staconnected_t *staconnected;
|
||||
staconnected = &event->event_info.sta_connected;
|
||||
os_printf("SYSTEM_EVENT_AP_STACONNECTED\nmac:%02x:%02x:%02x:%02x:%02x:%02x, aid:%d\n", \
|
||||
printf("SYSTEM_EVENT_AP_STACONNECTED\nmac:%02x:%02x:%02x:%02x:%02x:%02x, aid:%d\n", \
|
||||
staconnected->mac[0], staconnected->mac[0], staconnected->mac[1], \
|
||||
staconnected->mac[3], staconnected->mac[4], staconnected->mac[5], staconnected->aid);
|
||||
break;
|
||||
}
|
||||
case SYSTEM_EVENT_AP_STADISCONNECTED:
|
||||
{
|
||||
system_event_ap_stadisconnected_t *stadisconnected;
|
||||
stadisconnected = &event->event_info.sta_disconnected;
|
||||
os_printf("SYSTEM_EVENT_AP_STADISCONNECTED\nmac:%02x:%02x:%02x:%02x:%02x:%02x, aid:%d\n", \
|
||||
printf("SYSTEM_EVENT_AP_STADISCONNECTED\nmac:%02x:%02x:%02x:%02x:%02x:%02x, aid:%d\n", \
|
||||
stadisconnected->mac[0], stadisconnected->mac[0], stadisconnected->mac[1], \
|
||||
stadisconnected->mac[3], stadisconnected->mac[4], stadisconnected->mac[5], stadisconnected->aid);
|
||||
break;
|
||||
}
|
||||
case SYSTEM_EVENT_AP_PROBEREQRECVED:
|
||||
{
|
||||
system_event_ap_probe_req_rx_t *ap_probereqrecved;
|
||||
ap_probereqrecved = &event->event_info.ap_probereqrecved;
|
||||
os_printf("SYSTEM_EVENT_AP_PROBEREQRECVED\nrssi:%d, mac:%02x:%02x:%02x:%02x:%02x:%02x\n", \
|
||||
printf("SYSTEM_EVENT_AP_PROBEREQRECVED\nrssi:%d, mac:%02x:%02x:%02x:%02x:%02x:%02x\n", \
|
||||
ap_probereqrecved->rssi, ap_probereqrecved->mac[0], ap_probereqrecved->mac[0], ap_probereqrecved->mac[1], \
|
||||
ap_probereqrecved->mac[3], ap_probereqrecved->mac[4], ap_probereqrecved->mac[5]);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
os_printf("Error: no such kind of event!\n");
|
||||
{
|
||||
printf("Error: no such kind of event!\n");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return ESP_OK;
|
||||
@@ -237,19 +261,19 @@ static esp_err_t esp_system_event_debug(system_event_t *event)
|
||||
static esp_err_t esp_system_event_handler(system_event_t *event)
|
||||
{
|
||||
if (event == NULL) {
|
||||
os_printf("Error: event is null!\n");
|
||||
printf("Error: event is null!\n");
|
||||
return ESP_FAIL;
|
||||
}
|
||||
|
||||
esp_system_event_debug(event);
|
||||
if ((event->event_id < SYSTEM_EVENT_MAX) && (event->event_id == g_system_event_handle_table[event->event_id].event_id)){
|
||||
if (g_system_event_handle_table[event->event_id].event_handle){
|
||||
os_printf("enter default callback\n");
|
||||
printf("enter default callback\n");
|
||||
g_system_event_handle_table[event->event_id].event_handle(event);
|
||||
os_printf("exit default callback\n");
|
||||
printf("exit default callback\n");
|
||||
}
|
||||
} else {
|
||||
os_printf("mismatch or invalid event, id=%d\n", event->event_id);
|
||||
printf("mismatch or invalid event, id=%d\n", event->event_id);
|
||||
}
|
||||
|
||||
return esp_wifi_post_event_to_user(event);
|
||||
@@ -264,7 +288,7 @@ static void esp_system_event_task(void *pvParameters)
|
||||
if (xQueueReceive(g_event_handler, &evt, portMAX_DELAY) == pdPASS) {
|
||||
ret = esp_system_event_handler(&evt);
|
||||
if (ret == ESP_FAIL)
|
||||
os_printf("esp wifi post event to user fail!\n");
|
||||
printf("esp wifi post event to user fail!\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -32,6 +32,7 @@ typedef enum {
|
||||
SYSTEM_EVENT_STA_CONNECTED, /**< ESP32 station connected to AP */
|
||||
SYSTEM_EVENT_STA_DISCONNECTED, /**< ESP32 station disconnected to AP */
|
||||
SYSTEM_EVENT_STA_AUTHMODE_CHANGE, /**< the auth mode of AP connected by ESP32 station changed */
|
||||
SYSTEM_EVENT_STA_GOTIP,
|
||||
SYSTEM_EVENT_AP_START, /**< ESP32 softap start */
|
||||
SYSTEM_EVENT_AP_STOP, /**< ESP32 softap start */
|
||||
SYSTEM_EVENT_AP_STACONNECTED, /**< a station connected to ESP32 soft-AP */
|
||||
@@ -40,6 +41,10 @@ typedef enum {
|
||||
SYSTEM_EVENT_MAX
|
||||
} system_event_id_t;
|
||||
|
||||
typedef struct {
|
||||
uint32_t addr;
|
||||
} esp_ip_addr_t;
|
||||
|
||||
typedef struct {
|
||||
uint32_t status; /**< status of scanning APs*/
|
||||
uint8_t number;
|
||||
@@ -64,6 +69,12 @@ typedef struct {
|
||||
uint8_t new_mode; /**< the new auth mode of AP */
|
||||
} system_event_sta_authmode_change_t;
|
||||
|
||||
typedef struct {
|
||||
esp_ip_addr_t ip;
|
||||
esp_ip_addr_t netmask;
|
||||
esp_ip_addr_t gw;
|
||||
} system_event_sta_gotip_t;
|
||||
|
||||
typedef struct {
|
||||
uint8_t mac[6]; /**< MAC address of the station connected to ESP32 soft-AP */
|
||||
uint8_t aid; /**< the aid that ESP32 soft-AP gives to the station connected to */
|
||||
@@ -84,6 +95,7 @@ typedef union {
|
||||
system_event_sta_disconnected_t disconnected; /**< ESP32 station disconnected to AP */
|
||||
system_event_sta_scan_done_t scan_done; /**< ESP32 station scan (APs) done */
|
||||
system_event_sta_authmode_change_t auth_change; /**< the auth mode of AP ESP32 station connected to changed */
|
||||
system_event_sta_gotip_t got_ip;
|
||||
system_event_ap_staconnected_t sta_connected; /**< a station connected to ESP32 soft-AP */
|
||||
system_event_ap_stadisconnected_t sta_disconnected; /**< a station disconnected to ESP32 soft-AP */
|
||||
system_event_ap_probe_req_rx_t ap_probereqrecved; /**< ESP32 softAP receive probe request packet */
|
||||
|
209
components/esp32/include/esp_intr.h
Normal file
209
components/esp32/include/esp_intr.h
Normal file
@@ -0,0 +1,209 @@
|
||||
// Copyright 2010-2016 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed 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 __ESP_INTR_H__
|
||||
#define __ESP_INTR_H__
|
||||
|
||||
#include "rom/ets_sys.h"
|
||||
#include "freertos/xtensa_api.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define ESP_CCOMPARE_INTR_ATTACH(func, arg) \
|
||||
xt_set_interrupt_handler(ETS_CCOMPARE_INUM, (func), (void *)(arg))
|
||||
|
||||
#define ESP_EPWM_INTR_ATTACH(func, arg) \
|
||||
xt_set_interrupt_handler(ETS_EPWM_INUM, (func), (void *)(arg))
|
||||
|
||||
#define ESP_MPWM_INTR_ATTACH(func, arg) \
|
||||
xt_set_interrupt_handler(ETS_MPWM_INUM, (func), (void *)(arg))
|
||||
|
||||
#define ESP_SPI1_INTR_ATTACH(func, arg) \
|
||||
xt_set_interrupt_handler(ETS_SPI1_INUM, (func), (void *)(arg))
|
||||
|
||||
#define ESP_SPI2_INTR_ATTACH(func, arg) \
|
||||
xt_set_interrupt_handler(ETS_SPI2_INUM, (func), (void *)(arg))
|
||||
|
||||
#define ESP_SPI3_INTR_ATTACH(func, arg) \
|
||||
xt_set_interrupt_handler(ETS_SPI3_INUM, (func), (void *)(arg))
|
||||
|
||||
#define ESP_I2S0_INTR_ATTACH(func, arg) \
|
||||
xt_set_interrupt_handler(ETS_I2S0_INUM, (func), (void *)(arg))
|
||||
|
||||
#define ESP_PCNT_INTR_ATTACH(func, arg) \
|
||||
xt_set_interrupt_handler(ETS_PCNT_INUM, (func), (void *)(arg))
|
||||
|
||||
#define ESP_LEDC_INTR_ATTACH(func, arg) \
|
||||
xt_set_interrupt_handler(ETS_LEDC_INUM, (func), (void *)(arg))
|
||||
|
||||
#define ESP_WMAC_INTR_ATTACH(func, arg) \
|
||||
xt_set_interrupt_handler(ETS_WMAC_INUM, (func), (void *)(arg))
|
||||
|
||||
#define ESP_FRC_TIMER1_INTR_ATTACH(func, arg) \
|
||||
xt_set_interrupt_handler(ETS_FRC_TIMER1_INUM, (func), (void *)(arg))
|
||||
|
||||
#define ESP_FRC_TIMER2_INTR_ATTACH(func, arg) \
|
||||
xt_set_interrupt_handler(ETS_FRC_TIMER2_INUM, (func), (void *)(arg))
|
||||
|
||||
#define ESP_GPIO_INTR_ATTACH(func, arg) \
|
||||
xt_set_interrupt_handler(ETS_GPIO_INUM, (func), (void *)(arg))
|
||||
|
||||
#define ESP_UART_INTR_ATTACH(func, arg) \
|
||||
xt_set_interrupt_handler(ETS_UART_INUM, (func), (void *)(arg))
|
||||
|
||||
#define ESP_WDT_INTR_ATTACH(func, arg) \
|
||||
xt_set_interrupt_handler(ETS_WDT_INUM, (func), (void *)(arg))
|
||||
|
||||
#define ESP_RTC_INTR_ATTACH(func, arg) \
|
||||
xt_set_interrupt_handler(ETS_RTC_INUM, (func), (void *)(arg))
|
||||
|
||||
#define ESP_SLC_INTR_ATTACH(func, arg) \
|
||||
xt_set_interrupt_handler(ETS_SLC_INUM, (func), (void *)(arg))
|
||||
|
||||
#define ESP_RMT_CTRL_INTRL(func,arg)\
|
||||
xt_set_interrupt_handler(ETS_RMT_CTRL_INUM, (func), (void *)(arg))
|
||||
|
||||
#define ESP_INTR_ENABLE(inum) \
|
||||
xt_ints_on((1<<inum))
|
||||
|
||||
#define ESP_INTR_DISABLE(inum) \
|
||||
xt_ints_off((1<<inum))
|
||||
|
||||
#define ESP_CCOMPARE_INTR_ENBALE() \
|
||||
ESP_INTR_ENABLE(ETS_CCOMPARE_INUM)
|
||||
|
||||
#define ESP_CCOMPARE_INTR_DISBALE() \
|
||||
ESP_INTR_DISABLE(ETS_CCOMPARE_INUM)
|
||||
|
||||
#define ESP_SPI1_INTR_ENABLE() \
|
||||
ESP_INTR_ENABLE(ETS_SPI1_INUM)
|
||||
|
||||
#define ESP_SPI1_INTR_DISABLE() \
|
||||
ESP_INTR_DISABLE(ETS_SPI1_INUM)
|
||||
|
||||
#define ESP_SPI2_INTR_ENABLE() \
|
||||
ESP_INTR_ENABLE(ETS_SPI2_INUM)
|
||||
|
||||
#define ESP_PWM_INTR_ENABLE() \
|
||||
ESP_INTR_ENABLE(ETS_PWM_INUM)
|
||||
|
||||
#define ESP_PWM_INTR_DISABLE() \
|
||||
ESP_INTR_DISABLE(ETS_PWM_INUM)
|
||||
|
||||
#define ESP_SPI2_INTR_DISABLE() \
|
||||
ESP_INTR_DISABLE(ETS_SPI2_INUM)
|
||||
|
||||
#define ESP_SPI3_INTR_ENABLE() \
|
||||
ESP_INTR_ENABLE(ETS_SPI3_INUM)
|
||||
|
||||
#define ESP_SPI3_INTR_DISABLE() \
|
||||
ESP_INTR_DISABLE(ETS_SPI3_INUM)
|
||||
|
||||
#define ESP_I2S0_INTR_ENABLE() \
|
||||
ESP_INTR_ENABLE(ETS_I2S0_INUM)
|
||||
|
||||
#define ESP_I2S0_INTR_DISABLE() \
|
||||
ESP_INTR_DISABLE(ETS_I2S0_INUM)
|
||||
|
||||
#define ESP_I2S1_INTR_ENABLE() \
|
||||
ESP_INTR_ENABLE(ETS_I2S1_INUM)
|
||||
|
||||
#define ESP_I2S1_INTR_DISABLE() \
|
||||
ESP_INTR_DISABLE(ETS_I2S1_INUM)
|
||||
|
||||
#define ESP_MPWM_INTR_ENABLE() \
|
||||
ESP_INTR_ENABLE(ETS_MPWM_INUM)
|
||||
|
||||
#define ESP_EPWM_INTR_ENABLE() \
|
||||
ESP_INTR_ENABLE(ETS_EPWM_INUM)
|
||||
|
||||
#define ESP_MPWM_INTR_DISABLE() \
|
||||
ESP_INTR_DISABLE(ETS_MPWM_INUM)
|
||||
|
||||
#define ESP_EPWM_INTR_DISABLE() \
|
||||
ESP_INTR_DISABLE(ETS_EPWM_INUM)
|
||||
|
||||
#define ESP_BB_INTR_ENABLE() \
|
||||
ESP_INTR_ENABLE(ETS_BB_INUM)
|
||||
|
||||
#define ESP_BB_INTR_DISABLE() \
|
||||
ESP_INTR_DISABLE(ETS_BB_INUM)
|
||||
|
||||
#define ESP_UART_INTR_ENABLE() \
|
||||
ESP_INTR_ENABLE(ETS_UART_INUM)
|
||||
|
||||
#define ESP_UART_INTR_DISABLE() \
|
||||
ESP_INTR_DISABLE(ETS_UART_INUM)
|
||||
|
||||
#define ESP_LEDC_INTR_ENABLE() \
|
||||
ESP_INTR_ENABLE(ETS_LEDC_INUM)
|
||||
|
||||
#define ESP_LEDC_INTR_DISABLE() \
|
||||
ESP_INTR_DISABLE(ETS_LEDC_INUM)
|
||||
|
||||
#define ESP_GPIO_INTR_ENABLE() \
|
||||
ESP_INTR_ENABLE(ETS_GPIO_INUM)
|
||||
|
||||
#define ESP_GPIO_INTR_DISABLE() \
|
||||
ESP_INTR_DISABLE(ETS_GPIO_INUM)
|
||||
|
||||
#define ESP_WDT_INTR_ENABLE() \
|
||||
ESP_INTR_ENABLE(ETS_WDT_INUM)
|
||||
|
||||
#define ESP_WDT_INTR_DISABLE() \
|
||||
ESP_INTR_DISABLE(ETS_WDT_INUM)
|
||||
|
||||
#define ESP_FRC1_INTR_ENABLE() \
|
||||
ESP_INTR_ENABLE(ETS_FRC_TIMER1_INUM)
|
||||
|
||||
#define ESP_FRC1_INTR_DISABLE() \
|
||||
ESP_INTR_DISABLE(ETS_FRC_TIMER1_INUM)
|
||||
|
||||
#define ESP_FRC2_INTR_ENABLE() \
|
||||
ESP_INTR_ENABLE(ETS_FRC_TIMER2_INUM)
|
||||
|
||||
#define ESP_FRC2_INTR_DISABLE() \
|
||||
ESP_INTR_DISABLE(ETS_FRC_TIMER2_INUM)
|
||||
|
||||
#define ESP_RTC_INTR_ENABLE() \
|
||||
ESP_INTR_ENABLE(ETS_RTC_INUM)
|
||||
|
||||
#define ESP_RTC_INTR_DISABLE() \
|
||||
ESP_INTR_DISABLE(ETS_RTC_INUM)
|
||||
|
||||
#define ESP_SLC_INTR_ENABLE() \
|
||||
ESP_INTR_ENABLE(ETS_SLC_INUM)
|
||||
|
||||
#define ESP_SLC_INTR_DISABLE() \
|
||||
ESP_INTR_DISABLE(ETS_SLC_INUM)
|
||||
|
||||
#define ESP_PCNT_INTR_ENABLE() \
|
||||
ESP_INTR_ENABLE(ETS_PCNT_INUM)
|
||||
|
||||
#define ESP_PCNT_INTR_DISABLE() \
|
||||
ESP_INTR_DISABLE(ETS_PCNT_INUM)
|
||||
|
||||
#define ESP_RMT_CTRL_ENABLE() \
|
||||
ESP_INTR_ENABLE(ETS_RMT_CTRL_INUM)
|
||||
|
||||
#define ESP_RMT_CTRL_DIABLE() \
|
||||
ESP_INTR_DISABLE(ETS_RMT_CTRL_INUM)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __ESP_INTR_H__ */
|
@@ -17,6 +17,8 @@
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "esp_err.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
@@ -84,15 +86,6 @@ void system_deep_sleep(uint64_t time_in_us);
|
||||
*/
|
||||
uint32_t system_get_time(void);
|
||||
|
||||
/**
|
||||
* @brief Print the system memory distribution, including data/rodata/bss/heap.
|
||||
*
|
||||
* @param null
|
||||
*
|
||||
* @return null
|
||||
*/
|
||||
void system_print_meminfo(void);
|
||||
|
||||
/**
|
||||
* @brief Get the size of available heap.
|
||||
*
|
||||
@@ -102,22 +95,6 @@ void system_print_meminfo(void);
|
||||
*/
|
||||
uint32_t system_get_free_heap_size(void);
|
||||
|
||||
/**
|
||||
* @brief Get the chip ID.
|
||||
*
|
||||
* Example:
|
||||
* <pre>
|
||||
* uint8 chip_id[6];
|
||||
* system_get_chip_id(chip_id);
|
||||
* </pre>
|
||||
*
|
||||
* @param uint8 *chip_id : the chip ID
|
||||
*
|
||||
* @return true : succeed
|
||||
* @return false : fail
|
||||
*/
|
||||
bool system_get_chip_id(uint8_t *chip_id);
|
||||
|
||||
/**
|
||||
* @brief Get RTC time, unit: RTC clock cycle.
|
||||
*
|
||||
@@ -171,98 +148,6 @@ bool system_rtc_mem_read(uint16_t src, void *dst, uint16_t n);
|
||||
*/
|
||||
bool system_rtc_mem_write(uint16_t dst, const void *src, uint16_t n);
|
||||
|
||||
typedef enum {
|
||||
ADC1_PAD_GPIO36 = 0,
|
||||
ADC1_PAD_GPIO37,
|
||||
ADC1_PAD_GPIO38,
|
||||
ADC1_PAD_GPIO39,
|
||||
ADC1_PAD_GPIO32,
|
||||
ADC1_PAD_GPIO33,
|
||||
ADC1_PAD_GPIO34,
|
||||
ADC1_PAD_GPIO35
|
||||
} adc1_read_pad_t;
|
||||
|
||||
typedef enum {
|
||||
ADC1_ATTEN_0DB = 0,
|
||||
ADC1_ATTEN_3DB,
|
||||
ADC1_ATTEN_6DB,
|
||||
ADC1_ATTEN_12DB
|
||||
} adc1_read_atten_t;
|
||||
|
||||
/**
|
||||
* @brief Read ADC1.
|
||||
*
|
||||
* @param adc1_read_pad pad : the corresponding GPIO
|
||||
* @param adc1_read_atten atten : value of attenuation
|
||||
*
|
||||
* @return range of the return value is [0, 4096].
|
||||
* - If atten == 0, the range of voltage can be measured is [0, 1] V.
|
||||
* - If atten == 1, the range of voltage can be measured is [0, 1.4] V.
|
||||
* - If atten == 2, the range of voltage can be measured is [0, 2] V.
|
||||
* - If atten == 3, the range of voltage can be measured is [0, 4] V.
|
||||
*/
|
||||
uint16_t system_adc1_read(adc1_read_pad_t pad, adc1_read_atten_t atten);
|
||||
|
||||
/**
|
||||
* @brief Measure the power voltage of VDD3P3 pin 3 and 4, unit : 1/1024 V.
|
||||
*
|
||||
* @attention system_get_vdd33 depends on RF, please do not use it if RF is disabled.
|
||||
*
|
||||
* @param null
|
||||
*
|
||||
* @return Power voltage of VDD33, unit : 1/1024 V
|
||||
*/
|
||||
uint16_t system_get_vdd33(void);
|
||||
|
||||
/**
|
||||
* @brief Write data into flash with protection.
|
||||
*
|
||||
* Flash read/write has to be 4-bytes aligned.
|
||||
*
|
||||
* Protection of flash read/write :
|
||||
* use 3 sectors (4KBytes per sector) to save 4KB data with protect,
|
||||
* sector 0 and sector 1 are data sectors, back up each other,
|
||||
* save data alternately, sector 2 is flag sector, point out which sector
|
||||
* is keeping the latest data, sector 0 or sector 1.
|
||||
*
|
||||
* @param uint16 start_sec : start sector (sector 0) of the 3 sectors which are
|
||||
* used for flash read/write protection.
|
||||
* - For example, in IOT_Demo we can use the 3 sectors (3 * 4KB) starting from flash
|
||||
* 0x3D000 for flash read/write protection, so the parameter start_sec should be 0x3D
|
||||
* @param void *param : pointer of the data to be written
|
||||
* @param uint16 len : data length, should be less than a sector, which is 4 * 1024
|
||||
*
|
||||
* @return true : succeed
|
||||
* @return false : fail
|
||||
*/
|
||||
bool system_param_save_with_protect(uint16_t start_sec, void *param, uint16_t len);
|
||||
|
||||
/**
|
||||
* @brief Read the data saved into flash with the read/write protection.
|
||||
*
|
||||
* Flash read/write has to be 4-bytes aligned.
|
||||
*
|
||||
* Read/write protection of flash:
|
||||
* use 3 sectors (4KB per sector) to save 4KB data with protect, sector
|
||||
* 0 and sector 1 are data sectors, back up each other, save data alternately,
|
||||
* sector 2 is flag sector, point out which sector is keeping the latest data,
|
||||
* sector 0 or sector 1.
|
||||
*
|
||||
* @param uint16 start_sec : start sector (sector 0) of the 3 sectors used for
|
||||
* flash read/write protection. It cannot be sector 1 or sector 2.
|
||||
* - For example, in IOT_Demo, the 3 sectors (3 * 4KB) starting from flash 0x3D000
|
||||
* can be used for flash read/write protection.
|
||||
* The parameter start_sec is 0x3D, and it cannot be 0x3E or 0x3F.
|
||||
* @param uint16 offset : offset of data saved in sector
|
||||
* @param void *param : data pointer
|
||||
* @param uint16 len : data length, offset + len =< 4 * 1024
|
||||
*
|
||||
* @return true : succeed
|
||||
* @return false : fail
|
||||
*/
|
||||
bool system_param_load(uint16_t start_sec, uint16_t offset, void *param, uint16_t len);
|
||||
|
||||
|
||||
/** \defgroup System_boot_APIs Boot APIs
|
||||
* @brief boot APIs
|
||||
*/
|
||||
@@ -288,63 +173,15 @@ bool system_param_load(uint16_t start_sec, uint16_t offset, void *param, uint16_
|
||||
* @{
|
||||
*/
|
||||
|
||||
typedef enum {
|
||||
DEFAULT_MAC = 0, /**< Default hardware MAC provided by Espressif Systems */
|
||||
USER_MAC, /**< User-define hardware MAC */
|
||||
} mac_group_t;
|
||||
|
||||
typedef enum {
|
||||
WIFI_MAC = 0, /**< Hardware MAC address of ESP32 WiFi */
|
||||
BT_MAC, /**< Hardware MAC address of ESP32 bluetooth */
|
||||
} mac_type_t;
|
||||
|
||||
/**
|
||||
* @brief Set user-define hardware MAC address.
|
||||
*
|
||||
* @attention Hardware MAC address can only be set ONCE for each ESP32 chip.
|
||||
*
|
||||
* @param mac_type type : type of hardware MAC address.
|
||||
* @param uint8 *mac : user-define hardware MAC address, length: 6 bytes.
|
||||
*
|
||||
* @return 0 : succeed to set.
|
||||
* @return 1 : the hardware MAC has been set once, users can not set it any more.
|
||||
* @return 2 : fail to set.
|
||||
* @return 3 : invalid parameter.
|
||||
*/
|
||||
int system_efuse_program_user_mac(mac_type_t type, uint8_t *mac);
|
||||
|
||||
/**
|
||||
* @brief Read hardware MAC address.
|
||||
*
|
||||
* @param mac_group group : default MAC or user-defined MAC.
|
||||
* @param mac_type type : type of hardware MAC address.
|
||||
* @param uint8 *mac : the hardware MAC address, length: 6 bytes.
|
||||
* @param uint8 mac[6] : the hardware MAC address, length: 6 bytes.
|
||||
*
|
||||
* @return true : succeed
|
||||
* @return false : fail
|
||||
* @return esp_err_t
|
||||
*/
|
||||
bool system_efuse_read_mac(mac_group_t group, mac_type_t type, uint8_t *mac);
|
||||
esp_err_t system_efuse_read_mac(uint8_t mac[6]);
|
||||
|
||||
/**
|
||||
* @brief Set hardware MAC group, default MAC or user-defined MAC.
|
||||
*
|
||||
* @attention This API needs system_restart to take effect.
|
||||
*
|
||||
* @param mac_group group : default MAC or user-defined MAC.
|
||||
*
|
||||
* @return true : succeed
|
||||
* @return false : fail
|
||||
*/
|
||||
bool system_efuse_set_mac_group(mac_group_t group);
|
||||
|
||||
/**
|
||||
* @brief Get hardware MAC group, default MAC or user-defined MAC.
|
||||
*
|
||||
* @param null
|
||||
*
|
||||
* @return mac_group, the hardware MAC group.
|
||||
*/
|
||||
mac_group_t system_efuse_get_mac_group(void);
|
||||
|
||||
void system_init(void);
|
||||
|
||||
|
@@ -19,6 +19,7 @@
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "esp_err.h"
|
||||
#include "rom/queue.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@@ -220,6 +221,15 @@ esp_err_t esp_wifi_set_config(wifi_interface_t ifx, wifi_config_t *conf);
|
||||
|
||||
esp_err_t esp_wifi_get_config(wifi_interface_t ifx, wifi_config_t *conf);
|
||||
|
||||
struct station_info {
|
||||
STAILQ_ENTRY(station_info) next;
|
||||
uint8_t bssid[6];
|
||||
};
|
||||
|
||||
esp_err_t esp_wifi_get_station_list(struct station_info **station);
|
||||
|
||||
esp_err_t esp_wifi_free_station_list(void);
|
||||
|
||||
typedef esp_err_t (*wifi_rxcb_t)(void *buffer, uint16_t len, void* eb);
|
||||
|
||||
esp_err_t esp_wifi_reg_rxcb(wifi_interface_t ifx, wifi_rxcb_t fn);
|
||||
|
@@ -232,10 +232,10 @@ void intr_matrix_set(int cpu_no, uint32_t model_num, uint32_t intr_num);
|
||||
|
||||
|
||||
#define ETS_INTR_ENABLE(inum) \
|
||||
ets_isr_unmask((1<<inum))
|
||||
xt_ints_on((1<<inum))
|
||||
|
||||
#define ETS_INTR_DISABLE(inum) \
|
||||
ets_isr_mask((1<<inum))
|
||||
xt_ints_off((1<<inum))
|
||||
|
||||
#define ETS_CCOMPARE_INTR_ENBALE() \
|
||||
ETS_INTR_ENABLE(ETS_CCOMPARE_INUM)
|
||||
|
@@ -89,7 +89,7 @@
|
||||
#define APB_CLK_FREQ_ROM 13*1000000
|
||||
#define CPU_CLK_FREQ_ROM APB_CLK_FREQ_ROM
|
||||
#define CPU_CLK_FREQ APB_CLK_FREQ
|
||||
#define APB_CLK_FREQ 40*1000000 //unit: Hz
|
||||
#define APB_CLK_FREQ 80*1000000 //unit: Hz
|
||||
#define UART_CLK_FREQ APB_CLK_FREQ
|
||||
//#define WDT_CLK_FREQ APB_CLK_FREQ
|
||||
#define TIMER_CLK_FREQ (80000000>>4) //80MHz divided by 16
|
||||
|
Submodule components/esp32/lib updated: 40dc7af7f3...7c8bd4ec5a
@@ -13,6 +13,7 @@
|
||||
// limitations under the License.
|
||||
#include <stddef.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "esp_err.h"
|
||||
#include "esp_wifi.h"
|
||||
@@ -23,30 +24,11 @@
|
||||
#include "freertos/queue.h"
|
||||
#include "freertos/semphr.h"
|
||||
|
||||
//#include "tcpip_adapter.h"
|
||||
|
||||
#define ESP32_WORKAROUND 1
|
||||
|
||||
#if CONFIG_WIFI_ENABLED
|
||||
|
||||
#ifdef ESP32_WORKAROUND
|
||||
|
||||
SemaphoreHandle_t stdio_mutex_tx = NULL;
|
||||
#define os_printf(fmt, ...) do {\
|
||||
if (!stdio_mutex_tx) {\
|
||||
stdio_mutex_tx = xSemaphoreCreateMutex();\
|
||||
}\
|
||||
\
|
||||
xSemaphoreTake(stdio_mutex_tx, portMAX_DELAY);\
|
||||
ets_printf(fmt, ##__VA_ARGS__);\
|
||||
xSemaphoreGive(stdio_mutex_tx);\
|
||||
} while (0)
|
||||
|
||||
#endif
|
||||
|
||||
static wifi_startup_cb_t startup_cb;
|
||||
|
||||
#define WIFI_DEBUG os_printf
|
||||
#define WIFI_DEBUG printf
|
||||
#define WIFI_API_CALL_CHECK(info, api_call, ret) \
|
||||
do{\
|
||||
esp_err_t __err = (api_call);\
|
||||
@@ -56,6 +38,8 @@ do{\
|
||||
}\
|
||||
} while(0)
|
||||
|
||||
|
||||
|
||||
static void esp_wifi_task(void *pvParameters)
|
||||
{
|
||||
esp_err_t err;
|
||||
@@ -65,29 +49,35 @@ static void esp_wifi_task(void *pvParameters)
|
||||
do {
|
||||
err = esp_wifi_init(&cfg);
|
||||
if (err != ESP_OK) {
|
||||
WIFI_DEBUG("esp_wifi_init fail, ret=%d\n", err);
|
||||
break;
|
||||
}
|
||||
|
||||
if (startup_cb) {
|
||||
err = (*startup_cb)();
|
||||
if (err != ESP_OK) {
|
||||
WIFI_DEBUG("startup_cb fail, ret=%d\n", err);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
err = esp_wifi_start();
|
||||
if (err != ESP_OK) { // TODO: if already started, it's also OK
|
||||
if (err != ESP_OK) {
|
||||
WIFI_DEBUG("esp_wifi_start fail, ret=%d\n", err);
|
||||
break;
|
||||
}
|
||||
|
||||
#if CONFIG_WIFI_AUTO_CONNECT
|
||||
wifi_mode_t mode;
|
||||
|
||||
esp_wifi_get_mode(&mode);
|
||||
err = esp_wifi_get_mode(&mode);
|
||||
if (err != ESP_OK){
|
||||
WIFI_DEBUG("esp_wifi_get_mode fail, ret=%d\n", err);
|
||||
}
|
||||
|
||||
if (mode == WIFI_MODE_STA || mode == WIFI_MODE_APSTA) {
|
||||
err = esp_wifi_connect();
|
||||
if (err != ESP_OK) {
|
||||
WIFI_DEBUG("esp_wifi_connect fail, ret=%d\n", err);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -95,6 +85,7 @@ static void esp_wifi_task(void *pvParameters)
|
||||
} while (0);
|
||||
|
||||
if (err != ESP_OK) {
|
||||
WIFI_DEBUG("wifi startup fail, deinit\n");
|
||||
esp_wifi_deinit();
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user