├── README.md ├── blobs ├── include │ ├── sdkconfig.h │ ├── esp_netif.h │ ├── esp_task.h │ ├── esp_bt_cfg.h │ ├── hal │ │ ├── efuse_hal.h │ │ └── gpio_types.h │ ├── include.h │ ├── nimble │ │ ├── nimble_npl_os.h │ │ └── nimble_npl.h │ ├── esp_assert.h │ ├── esp_etm.h │ ├── esp_wifi_he.h │ └── esp_wifi_he_types.h ├── libs │ └── esp32c3 │ │ ├── libpp.a │ │ ├── libbtbb.a │ │ ├── libcore.a │ │ ├── libmesh.a │ │ ├── libphy.a │ │ ├── librfate.a │ │ ├── libwapi.a │ │ ├── libcoexist.a │ │ ├── libespnow.a │ │ ├── librftest.a │ │ ├── libbtdm_app.a │ │ ├── libbttestmode.a │ │ ├── libnet80211.a │ │ ├── libsmartconfig.a │ │ └── libwpa_supplicant.a ├── headers │ ├── esp32h2 │ │ └── phy_init_data.h │ ├── esp_private │ │ ├── esp_wifi_private.h │ │ ├── esp_wifi_types_private.h │ │ ├── wifi_types.h │ │ └── wifi_os_adapter.h │ ├── esp_interface.h │ ├── espidf_wifi.h │ ├── espidf_types.h │ ├── esp_event_base.h │ ├── esp_wpa.h │ ├── esp_compiler.h │ ├── esp_coexist_adapter.h │ ├── esp_system.h │ ├── esp32 │ │ └── phy_init_data.h │ ├── esp32s3 │ │ └── phy_init_data.h │ ├── esp32c2 │ │ ├── phy_init_data.h │ │ └── esp_bt_cfg.h │ ├── esp32c3 │ │ └── phy_init_data.h │ ├── esp32s2 │ │ └── phy_init_data.h │ ├── esp32c6 │ │ └── phy_init_data.h │ ├── phy.h │ ├── esp_wifi_default.h │ ├── esp_smartconfig.h │ ├── esp_err.h │ ├── esp_coexist.h │ ├── esp_phy_init.h │ ├── esp_coexist_internal.h │ ├── esp_event_legacy.h │ ├── esp_timer.h │ └── esp_wpa2.h └── LICENSE.txt ├── go.mod ├── radio_other.go ├── Makefile ├── examples └── starting │ └── main.go ├── error.go ├── radio_esp32c3.go ├── radio.c ├── radio.go └── sync.go /README.md: -------------------------------------------------------------------------------- 1 | # espradio 2 | -------------------------------------------------------------------------------- /blobs/include/sdkconfig.h: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /blobs/include/esp_netif.h: -------------------------------------------------------------------------------- 1 | // empty 2 | -------------------------------------------------------------------------------- /blobs/include/esp_task.h: -------------------------------------------------------------------------------- 1 | // empty 2 | -------------------------------------------------------------------------------- /blobs/include/esp_bt_cfg.h: -------------------------------------------------------------------------------- 1 | // empty 2 | -------------------------------------------------------------------------------- /blobs/include/hal/efuse_hal.h: -------------------------------------------------------------------------------- 1 | // empty 2 | -------------------------------------------------------------------------------- /blobs/include/hal/gpio_types.h: -------------------------------------------------------------------------------- 1 | // empty 2 | -------------------------------------------------------------------------------- /go.mod: -------------------------------------------------------------------------------- 1 | module tinygo.org/x/espradio 2 | 3 | go 1.24.4 4 | -------------------------------------------------------------------------------- /blobs/libs/esp32c3/libpp.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tinygo-org/espradio/HEAD/blobs/libs/esp32c3/libpp.a -------------------------------------------------------------------------------- /blobs/libs/esp32c3/libbtbb.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tinygo-org/espradio/HEAD/blobs/libs/esp32c3/libbtbb.a -------------------------------------------------------------------------------- /blobs/libs/esp32c3/libcore.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tinygo-org/espradio/HEAD/blobs/libs/esp32c3/libcore.a -------------------------------------------------------------------------------- /blobs/libs/esp32c3/libmesh.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tinygo-org/espradio/HEAD/blobs/libs/esp32c3/libmesh.a -------------------------------------------------------------------------------- /blobs/libs/esp32c3/libphy.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tinygo-org/espradio/HEAD/blobs/libs/esp32c3/libphy.a -------------------------------------------------------------------------------- /blobs/libs/esp32c3/librfate.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tinygo-org/espradio/HEAD/blobs/libs/esp32c3/librfate.a -------------------------------------------------------------------------------- /blobs/libs/esp32c3/libwapi.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tinygo-org/espradio/HEAD/blobs/libs/esp32c3/libwapi.a -------------------------------------------------------------------------------- /blobs/libs/esp32c3/libcoexist.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tinygo-org/espradio/HEAD/blobs/libs/esp32c3/libcoexist.a -------------------------------------------------------------------------------- /blobs/libs/esp32c3/libespnow.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tinygo-org/espradio/HEAD/blobs/libs/esp32c3/libespnow.a -------------------------------------------------------------------------------- /blobs/libs/esp32c3/librftest.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tinygo-org/espradio/HEAD/blobs/libs/esp32c3/librftest.a -------------------------------------------------------------------------------- /blobs/libs/esp32c3/libbtdm_app.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tinygo-org/espradio/HEAD/blobs/libs/esp32c3/libbtdm_app.a -------------------------------------------------------------------------------- /blobs/libs/esp32c3/libbttestmode.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tinygo-org/espradio/HEAD/blobs/libs/esp32c3/libbttestmode.a -------------------------------------------------------------------------------- /blobs/libs/esp32c3/libnet80211.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tinygo-org/espradio/HEAD/blobs/libs/esp32c3/libnet80211.a -------------------------------------------------------------------------------- /blobs/libs/esp32c3/libsmartconfig.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tinygo-org/espradio/HEAD/blobs/libs/esp32c3/libsmartconfig.a -------------------------------------------------------------------------------- /blobs/libs/esp32c3/libwpa_supplicant.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tinygo-org/espradio/HEAD/blobs/libs/esp32c3/libwpa_supplicant.a -------------------------------------------------------------------------------- /radio_other.go: -------------------------------------------------------------------------------- 1 | //go:build !esp32c3 2 | 3 | package espradio 4 | 5 | import "errors" 6 | 7 | // This is the value used for the ESP32-C3. 8 | const ticksPerSecond = 16_000_000 9 | 10 | var errUnsupportedChip = errors.New("espradio: unsupported chip") 11 | 12 | func initHardware() error { 13 | return errUnsupportedChip 14 | } 15 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | update: esp-wifi/README.md 2 | rm -rf blobs/headers 3 | rm -rf blobs/include 4 | rm -rf blobs/libs 5 | mkdir -p blobs/libs 6 | cp -rp esp-wifi/esp-wifi-sys/headers blobs 7 | cp -rp esp-wifi/esp-wifi-sys/include blobs 8 | cp -rp esp-wifi/esp-wifi-sys/libs/esp32c3 blobs/libs 9 | 10 | esp-wifi/README.md: 11 | git clone https://github.com/esp-rs/esp-wifi 12 | -------------------------------------------------------------------------------- /blobs/include/include.h: -------------------------------------------------------------------------------- 1 | typedef int _lock_t; 2 | 3 | #define SOC_COEX_HW_PTI 1 4 | 5 | #include "espidf_types.h" 6 | #include "esp_private/wifi.h" 7 | #include "esp_wpa.h" 8 | #include "esp_phy_init.h" 9 | #include "phy.h" 10 | #include "esp_timer.h" 11 | 12 | #if !defined(CONFIG_IDF_TARGET_ESP32S2) 13 | #include "esp_bt.h" 14 | #include "esp_coexist_internal.h" 15 | #include "esp_coexist_adapter.h" 16 | #endif 17 | 18 | #include "esp_now.h" 19 | -------------------------------------------------------------------------------- /examples/starting/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "time" 5 | 6 | "tinygo.org/x/espradio" 7 | ) 8 | 9 | func main() { 10 | time.Sleep(time.Second * 1) 11 | 12 | println("initializing radio...") 13 | err := espradio.Enable(espradio.Config{ 14 | Logging: espradio.LogLevelVerbose, 15 | }) 16 | if err != nil { 17 | println("could not enable radio:", err) 18 | } else { 19 | println("enabled radio successfully") 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /blobs/headers/esp32h2/phy_init_data.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2016-2022 Espressif Systems (Shanghai) CO LTD 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | 7 | #ifndef PHY_INIT_DATA_H 8 | #define PHY_INIT_DATA_H /* don't use #pragma once here, we compile this file sometimes */ 9 | #include "esp_phy_init.h" 10 | #include "sdkconfig.h" 11 | 12 | #ifdef __cplusplus 13 | extern "C" { 14 | #endif 15 | 16 | // There is no init data for ESP32H2 right now, could be added when necessary. 17 | 18 | #ifdef __cplusplus 19 | } 20 | #endif 21 | 22 | #endif /* PHY_INIT_DATA_H */ 23 | -------------------------------------------------------------------------------- /blobs/headers/esp_private/esp_wifi_private.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2019-2022 Espressif Systems (Shanghai) CO LTD 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | #ifndef _ESP_WIFI_PRIVATE_H 7 | #define _ESP_WIFI_PRIVATE_H 8 | 9 | #include "sys/queue.h" 10 | #include "sdkconfig.h" 11 | #include "esp_wifi_crypto_types.h" 12 | #include "esp_private/wifi_os_adapter.h" 13 | 14 | #ifdef __cplusplus 15 | extern "C" { 16 | #endif 17 | 18 | #define WIFI_OSI_FUNCS_INITIALIZER() &g_wifi_osi_funcs 19 | 20 | #ifdef __cplusplus 21 | } 22 | #endif 23 | 24 | #endif /* _ESP_WIFI_PRIVATE_H */ 25 | -------------------------------------------------------------------------------- /blobs/headers/esp_interface.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | 7 | 8 | #ifndef __ESP_INTERFACE_H__ 9 | #define __ESP_INTERFACE_H__ 10 | 11 | #include 12 | 13 | #ifdef __cplusplus 14 | extern "C" { 15 | #endif 16 | 17 | typedef enum { 18 | ESP_IF_WIFI_STA = 0, /**< Station interface */ 19 | ESP_IF_WIFI_AP, /**< Soft-AP interface */ 20 | ESP_IF_WIFI_NAN, /**< NAN interface */ 21 | ESP_IF_ETH, /**< Ethernet interface */ 22 | ESP_IF_MAX 23 | } esp_interface_t; 24 | 25 | #ifdef __cplusplus 26 | } 27 | #endif 28 | 29 | 30 | #endif /* __ESP_INTERFACE_TYPES_H__ */ 31 | -------------------------------------------------------------------------------- /blobs/headers/esp_private/esp_wifi_types_private.h: -------------------------------------------------------------------------------- 1 | // Copyright 2019 Espressif Systems (Shanghai) PTE LTD 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef _ESP_WIFI_TYPES_PRIVATE_H 16 | #define _ESP_WIFI_TYPES_PRIVATE_H 17 | 18 | #include 19 | #include 20 | #include "sys/queue.h" 21 | #include "esp_err.h" 22 | #include "esp_interface.h" 23 | #include "esp_event_base.h" 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /blobs/headers/espidf_wifi.h: -------------------------------------------------------------------------------- 1 | // Copyright 2020 Espressif Systems (Shanghai) PTE LTD 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | #ifndef _ESPIDF_WIFI_H_ 15 | #define _ESPIDF_WIFI_H_ 16 | 17 | #include "sdkconfig.h" 18 | #include "espidf_types.h" 19 | #include "esp_private/wifi_os_adapter.h" 20 | #include "esp_phy_init.h" 21 | #include "esp_private/wifi.h" 22 | #include "phy.h" 23 | #include "phy_init_data.h" 24 | #include "nvs.h" 25 | #include "esp_wpa.h" 26 | #include "esp_timer.h" 27 | #include "esp_system.h" 28 | #include "esp_wpa2.h" 29 | 30 | #endif /* _ESPIDF_WIFI_H_ */ 31 | -------------------------------------------------------------------------------- /error.go: -------------------------------------------------------------------------------- 1 | package espradio 2 | 3 | /* 4 | #include "include.h" 5 | */ 6 | import "C" 7 | 8 | // Error is an error from the radio stack. 9 | type Error C.esp_err_t 10 | 11 | func (e Error) Error() string { 12 | switch { 13 | case e >= C.ESP_ERR_MEMPROT_BASE: 14 | return "espradio: unknown memprot error" 15 | case e >= C.ESP_ERR_HW_CRYPTO_BASE: 16 | return "espradio: unknown hw crypto error" 17 | case e >= C.ESP_ERR_FLASH_BASE: 18 | return "espradio: unknown flash error" 19 | case e >= C.ESP_ERR_MESH_BASE: 20 | return "espradio: unknown mesh error" 21 | case e >= C.ESP_ERR_WIFI_BASE: 22 | return "espradio: unknown wifi error" 23 | default: 24 | switch e { 25 | case C.ESP_OK: 26 | return "espradio: no error" // invalid usage of the Error type 27 | case C.ESP_ERR_NO_MEM: 28 | return "espradio: no memory" 29 | case C.ESP_ERR_INVALID_ARG: 30 | return "espradio: invalid argument" 31 | default: 32 | return "espradio: unknown error" 33 | } 34 | } 35 | } 36 | 37 | // makeError returns an error (using the Error type) if the error code is 38 | // non-zero, otherwise it returns nil. 39 | func makeError(errCode C.esp_err_t) error { 40 | if errCode != 0 { 41 | return Error(errCode) 42 | } 43 | return nil 44 | } 45 | -------------------------------------------------------------------------------- /radio_esp32c3.go: -------------------------------------------------------------------------------- 1 | //go:build esp32c3 2 | 3 | package espradio 4 | 5 | import "device/esp" 6 | 7 | func initHardware() error { 8 | // See: 9 | // https://github.com/esp-rs/esp-wifi/blob/v0.2.0/esp-wifi/src/common_adapter/common_adapter_esp32c3.rs#L18 10 | 11 | const ( 12 | SYSTEM_WIFIBB_RST = 1 << 0 13 | SYSTEM_FE_RST = 1 << 1 14 | SYSTEM_WIFIMAC_RST = 1 << 2 15 | SYSTEM_BTBB_RST = 1 << 3 // Bluetooth Baseband 16 | SYSTEM_BTMAC_RST = 1 << 4 // deprecated 17 | SYSTEM_RW_BTMAC_RST = 1 << 9 // Bluetooth MAC 18 | SYSTEM_RW_BTMAC_REG_RST = 1 << 11 // Bluetooth MAC Regsiters 19 | SYSTEM_BTBB_REG_RST = 1 << 13 // Bluetooth Baseband Registers 20 | ) 21 | 22 | const MODEM_RESET_FIELD_WHEN_PU = SYSTEM_WIFIBB_RST | 23 | SYSTEM_FE_RST | 24 | SYSTEM_WIFIMAC_RST | 25 | SYSTEM_BTBB_RST | 26 | SYSTEM_BTMAC_RST | 27 | SYSTEM_RW_BTMAC_RST | 28 | SYSTEM_RW_BTMAC_REG_RST | 29 | SYSTEM_BTBB_REG_RST 30 | 31 | esp.RTC_CNTL.DIG_PWC.ClearBits(esp.RTC_CNTL_DIG_PWC_WIFI_FORCE_PD) 32 | esp.APB_CTRL.WIFI_RST_EN.SetBits(MODEM_RESET_FIELD_WHEN_PU) 33 | esp.APB_CTRL.WIFI_RST_EN.ClearBits(MODEM_RESET_FIELD_WHEN_PU) 34 | esp.RTC_CNTL.DIG_ISO.ClearBits(esp.RTC_CNTL_DIG_ISO_FORCE_OFF) 35 | 36 | return nil 37 | } 38 | 39 | // This is the value used for the ESP32-C3, see: 40 | // https://github.com/esp-rs/esp-wifi/blob/v0.2.0/esp-wifi/src/timer/riscv.rs#L28 41 | const ticksPerSecond = 16_000_000 42 | -------------------------------------------------------------------------------- /blobs/headers/espidf_types.h: -------------------------------------------------------------------------------- 1 | // Copyright 2020 Espressif Systems (Shanghai) PTE LTD 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | #ifndef _ESPIDF_TYPES_H_ 15 | #define _ESPIDF_TYPES_H_ 16 | 17 | #include 18 | 19 | #define IDF_DEPRECATED(_s) 20 | 21 | enum esp_log_level_e 22 | { 23 | ESP_LOG_NONE, 24 | ESP_LOG_ERROR, 25 | ESP_LOG_WARN, 26 | ESP_LOG_INFO, 27 | ESP_LOG_DEBUG, 28 | ESP_LOG_VERBOSE 29 | }; 30 | 31 | typedef uint32_t TickType_t; 32 | typedef uint32_t UBaseType_t; 33 | typedef int32_t BaseType_t; 34 | 35 | typedef void* QueueHandle_t; 36 | 37 | typedef void* esp_netif_t; 38 | typedef void* esp_netif_inherent_config_t; 39 | 40 | struct ets_timer 41 | { 42 | struct timer_adpt *next; 43 | uint32_t expire; 44 | uint32_t period; 45 | void (*func)(void *priv); 46 | void *priv; 47 | }; 48 | 49 | #endif /* _ESPIDF_TYPES_H_ */ 50 | -------------------------------------------------------------------------------- /blobs/headers/esp_event_base.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2018-2023 Espressif Systems (Shanghai) CO LTD 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | 7 | #ifndef ESP_EVENT_BASE_H_ 8 | #define ESP_EVENT_BASE_H_ 9 | 10 | #ifdef __cplusplus 11 | extern "C" { 12 | #endif 13 | 14 | // Defines for declaring and defining event base 15 | #define ESP_EVENT_DECLARE_BASE(id) extern esp_event_base_t const id 16 | #define ESP_EVENT_DEFINE_BASE(id) esp_event_base_t const id = #id 17 | 18 | // Event loop library types 19 | typedef const char* esp_event_base_t; /**< unique pointer to a subsystem that exposes events */ 20 | typedef void* esp_event_loop_handle_t; /**< a number that identifies an event with respect to a base */ 21 | typedef void (*esp_event_handler_t)(void* event_handler_arg, 22 | esp_event_base_t event_base, 23 | int32_t event_id, 24 | void* event_data); /**< function called when an event is posted to the queue */ 25 | typedef void* esp_event_handler_instance_t; /**< context identifying an instance of a registered event handler */ 26 | 27 | // Defines for registering/unregistering event handlers 28 | #define ESP_EVENT_ANY_BASE NULL /**< register handler for any event base */ 29 | #define ESP_EVENT_ANY_ID -1 /**< register handler for any event id */ 30 | 31 | #ifdef __cplusplus 32 | } 33 | #endif 34 | 35 | #endif // #ifndef ESP_EVENT_BASE_H_ 36 | -------------------------------------------------------------------------------- /blobs/headers/esp_wpa.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2019-2022 Espressif Systems (Shanghai) CO LTD 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | 7 | #ifndef __ESP_WPA_H__ 8 | #define __ESP_WPA_H__ 9 | 10 | #include 11 | #include 12 | #include "esp_err.h" 13 | #include "esp_wifi_crypto_types.h" 14 | #include "esp_wifi_types.h" 15 | 16 | #ifdef __cplusplus 17 | extern "C" { 18 | #endif 19 | 20 | /** \defgroup WiFi_APIs WiFi Related APIs 21 | * @brief WiFi APIs 22 | */ 23 | 24 | /** @addtogroup WiFi_APIs 25 | * @{ 26 | */ 27 | 28 | /** \defgroup WPA_APIs WPS APIs 29 | * @brief Supplicant APIs 30 | * 31 | */ 32 | 33 | /** @addtogroup WPA_APIs 34 | * @{ 35 | */ 36 | /* Crypto callback functions */ 37 | extern const wpa_crypto_funcs_t g_wifi_default_wpa_crypto_funcs; // NOLINT(readability-redundant-declaration) 38 | 39 | /* Mesh crypto callback functions */ 40 | extern const mesh_crypto_funcs_t g_wifi_default_mesh_crypto_funcs; 41 | 42 | /** 43 | * @brief Supplicant initialization 44 | * 45 | * @return 46 | * - ESP_OK : succeed 47 | * - ESP_ERR_NO_MEM : out of memory 48 | */ 49 | esp_err_t esp_supplicant_init(void); 50 | 51 | /** 52 | * @brief Supplicant deinitialization 53 | * 54 | * @return 55 | * - ESP_OK : succeed 56 | * - others: failed 57 | */ 58 | esp_err_t esp_supplicant_deinit(void); 59 | 60 | /** 61 | * @} 62 | */ 63 | 64 | /** 65 | * @} 66 | */ 67 | 68 | #ifdef __cplusplus 69 | } 70 | #endif 71 | 72 | #endif /* __ESP_WPA_H__ */ 73 | -------------------------------------------------------------------------------- /blobs/include/nimble/nimble_npl_os.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | #ifndef _NIMBLE_NPL_OS_H_ 21 | #define _NIMBLE_NPL_OS_H_ 22 | 23 | #include 24 | 25 | #ifdef __cplusplus 26 | extern "C" { 27 | #endif 28 | 29 | #define BLE_NPL_OS_ALIGNMENT 4 30 | 31 | #define BLE_NPL_TIME_FOREVER UINT32_MAX 32 | 33 | typedef uint32_t ble_npl_time_t; 34 | typedef int32_t ble_npl_stime_t; 35 | 36 | struct ble_npl_event { 37 | int dummy; 38 | }; 39 | 40 | struct ble_npl_eventq { 41 | int dummy; 42 | }; 43 | 44 | struct ble_npl_callout { 45 | int dummy; 46 | }; 47 | 48 | struct ble_npl_mutex { 49 | int dummy; 50 | }; 51 | 52 | struct ble_npl_sem { 53 | int dummy; 54 | }; 55 | 56 | #ifdef __cplusplus 57 | } 58 | #endif 59 | 60 | #endif /* _NPL_H_ */ 61 | -------------------------------------------------------------------------------- /blobs/include/esp_assert.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | #ifndef __ESP_ASSERT_H__ 7 | #define __ESP_ASSERT_H__ 8 | 9 | #include "assert.h" 10 | 11 | /* Since IDF v5.0, C17 standard is used, which supports both _Static_assert and static_assert syntax */ 12 | #define ESP_STATIC_ASSERT static_assert 13 | 14 | /* Assert at compile time if possible, runtime otherwise */ 15 | #ifndef __cplusplus 16 | /* __builtin_choose_expr() is only in C, makes this a lot cleaner */ 17 | #define TRY_STATIC_ASSERT(CONDITION, MSG) do { \ 18 | ESP_STATIC_ASSERT(__builtin_choose_expr(__builtin_constant_p(CONDITION), (CONDITION), 1), #MSG); \ 19 | assert(#MSG && (CONDITION)); \ 20 | } while(0) 21 | #else 22 | /* for C++, use __attribute__((error)) - works almost as well as ESP_STATIC_ASSERT */ 23 | #define TRY_STATIC_ASSERT(CONDITION, MSG) do { \ 24 | if (__builtin_constant_p(CONDITION) && !(CONDITION)) { \ 25 | extern __attribute__((error(#MSG))) void failed_compile_time_assert(void); \ 26 | failed_compile_time_assert(); \ 27 | } \ 28 | assert(#MSG && (CONDITION)); \ 29 | } while(0) 30 | #endif /* __cplusplus */ 31 | 32 | #endif /* __ESP_ASSERT_H__ */ 33 | -------------------------------------------------------------------------------- /blobs/headers/esp_private/wifi_types.h: -------------------------------------------------------------------------------- 1 | // Copyright 2015-2019 Espressif Systems (Shanghai) PTE LTD 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef _WIFI_TYPES_H 16 | #define _WIFI_TYPES_H 17 | 18 | #ifdef __cplusplus 19 | extern "C" { 20 | #endif 21 | 22 | /** 23 | * @brief WiFi ioctl command type 24 | * 25 | */ 26 | typedef enum { 27 | WIFI_IOCTL_SET_STA_HT2040_COEX = 1, /**< Set the configuration of STA's HT2040 coexist management */ 28 | WIFI_IOCTL_GET_STA_HT2040_COEX, /**< Get the configuration of STA's HT2040 coexist management */ 29 | WIFI_IOCTL_MAX, 30 | } wifi_ioctl_cmd_t; 31 | 32 | /** 33 | * @brief Configuration for STA's HT2040 coexist management 34 | * 35 | */ 36 | typedef struct { 37 | int enable; /**< Indicate whether STA's HT2040 coexist management is enabled or not */ 38 | } wifi_ht2040_coex_t; 39 | 40 | /** 41 | * @brief Configuration for WiFi ioctl 42 | * 43 | */ 44 | typedef struct { 45 | union { 46 | wifi_ht2040_coex_t ht2040_coex; /**< Configuration of STA's HT2040 coexist management */ 47 | } data; /**< Configuration of ioctl command */ 48 | } wifi_ioctl_config_t; 49 | 50 | #ifdef __cplusplus 51 | } 52 | #endif 53 | 54 | #endif 55 | -------------------------------------------------------------------------------- /blobs/headers/esp_compiler.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2016-2022 Espressif Systems (Shanghai) CO LTD 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | 7 | #pragma once 8 | 9 | #include "sdkconfig.h" 10 | 11 | /* 12 | * The likely and unlikely macro pairs: 13 | * These macros are useful to place when application 14 | * knows the majority ocurrence of a decision paths, 15 | * placing one of these macros can hint the compiler 16 | * to reorder instructions producing more optimized 17 | * code. 18 | */ 19 | #if (CONFIG_COMPILER_OPTIMIZATION_PERF) 20 | #ifndef likely 21 | #define likely(x) __builtin_expect(!!(x), 1) 22 | #endif 23 | #ifndef unlikely 24 | #define unlikely(x) __builtin_expect(!!(x), 0) 25 | #endif 26 | #else 27 | #ifndef likely 28 | #define likely(x) (x) 29 | #endif 30 | #ifndef unlikely 31 | #define unlikely(x) (x) 32 | #endif 33 | #endif 34 | 35 | /* 36 | * Utility macros used for designated initializers, which work differently 37 | * in C99 and C++ standards mainly for aggregate types. 38 | * The member separator, comma, is already part of the macro, please omit the trailing comma. 39 | * Usage example: 40 | * struct config_t { char* pchr; char arr[SIZE]; } config = { 41 | * ESP_COMPILER_DESIGNATED_INIT_AGGREGATE_TYPE_EMPTY(pchr) 42 | * ESP_COMPILER_DESIGNATED_INIT_AGGREGATE_TYPE_STR(arr, "Value") 43 | * }; 44 | */ 45 | #if defined(__cplusplus) && __cplusplus >= 202002L 46 | #define ESP_COMPILER_DESIGNATED_INIT_AGGREGATE_TYPE_STR(member, value) .member = value, 47 | #define ESP_COMPILER_DESIGNATED_INIT_AGGREGATE_TYPE_EMPTY(member) .member = { }, 48 | #elif defined(__cplusplus) && __cplusplus < 202002L 49 | #define ESP_COMPILER_DESIGNATED_INIT_AGGREGATE_TYPE_STR(member, value) { .member = value }, 50 | #define ESP_COMPILER_DESIGNATED_INIT_AGGREGATE_TYPE_EMPTY(member) .member = { }, 51 | #else 52 | #define ESP_COMPILER_DESIGNATED_INIT_AGGREGATE_TYPE_STR(member, value) .member = value, 53 | #define ESP_COMPILER_DESIGNATED_INIT_AGGREGATE_TYPE_EMPTY(member) 54 | #endif 55 | -------------------------------------------------------------------------------- /blobs/headers/esp_coexist_adapter.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2019-2023 Espressif Systems (Shanghai) CO LTD 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | 7 | #ifndef __ESP_COEXIST_ADAPTER_H__ 8 | #define __ESP_COEXIST_ADAPTER_H__ 9 | 10 | #include 11 | 12 | #ifdef __cplusplus 13 | extern "C" { 14 | #endif 15 | 16 | #define COEX_ADAPTER_VERSION 0x00000002 17 | #define COEX_ADAPTER_MAGIC 0xDEADBEAF 18 | 19 | #define COEX_ADAPTER_FUNCS_TIME_BLOCKING 0xffffffff 20 | 21 | typedef struct { 22 | int32_t _version; 23 | #if CONFIG_IDF_TARGET_ESP32 24 | void *(* _spin_lock_create)(void); 25 | void (* _spin_lock_delete)(void *lock); 26 | uint32_t (*_int_disable)(void *mux); 27 | void (*_int_enable)(void *mux, uint32_t tmp); 28 | #endif 29 | void (*_task_yield_from_isr)(void); 30 | void *(*_semphr_create)(uint32_t max, uint32_t init); 31 | void (*_semphr_delete)(void *semphr); 32 | int32_t (*_semphr_take_from_isr)(void *semphr, void *hptw); 33 | int32_t (*_semphr_give_from_isr)(void *semphr, void *hptw); 34 | int32_t (*_semphr_take)(void *semphr, uint32_t block_time_tick); 35 | int32_t (*_semphr_give)(void *semphr); 36 | int (* _is_in_isr)(void); 37 | void * (* _malloc_internal)(size_t size); 38 | void (* _free)(void *p); 39 | int64_t (* _esp_timer_get_time)(void); 40 | bool (* _env_is_chip)(void); 41 | #if CONFIG_IDF_TARGET_ESP32C2 42 | // this function is only used on esp32c2 43 | uint32_t (* _slowclk_cal_get)(void); 44 | #endif 45 | void (* _timer_disarm)(void *timer); 46 | void (* _timer_done)(void *ptimer); 47 | void (* _timer_setfn)(void *ptimer, void *pfunction, void *parg); 48 | void (* _timer_arm_us)(void *ptimer, uint32_t us, bool repeat); 49 | int32_t _magic; 50 | } coex_adapter_funcs_t; 51 | 52 | extern coex_adapter_funcs_t g_coex_adapter_funcs; 53 | 54 | typedef struct { 55 | uint8_t major; 56 | uint8_t minor; 57 | uint8_t patch; 58 | } coex_version_t; 59 | 60 | #ifdef __cplusplus 61 | } 62 | #endif 63 | 64 | #endif /* __ESP_COEXIST_ADAPTER_H__ */ 65 | -------------------------------------------------------------------------------- /radio.c: -------------------------------------------------------------------------------- 1 | //go:build esp32c3 2 | 3 | #include "sdkconfig.h" 4 | #include "include.h" 5 | #include 6 | 7 | // defined in osi.c 8 | extern wifi_osi_funcs_t espradio_osi_funcs; 9 | 10 | wifi_init_config_t wifi_config = { 11 | .osi_funcs = &espradio_osi_funcs, 12 | .wpa_crypto_funcs = { 13 | .size = sizeof(wpa_crypto_funcs_t), 14 | .version = ESP_WIFI_CRYPTO_VERSION, 15 | // TODO: fill in these functions 16 | }, 17 | .static_rx_buf_num = CONFIG_ESP_WIFI_STATIC_RX_BUFFER_NUM, 18 | .dynamic_rx_buf_num = CONFIG_ESP_WIFI_DYNAMIC_RX_BUFFER_NUM, 19 | .tx_buf_type = CONFIG_ESP_WIFI_TX_BUFFER_TYPE, 20 | .static_tx_buf_num = WIFI_STATIC_TX_BUFFER_NUM, 21 | .dynamic_tx_buf_num = WIFI_DYNAMIC_TX_BUFFER_NUM, 22 | .rx_mgmt_buf_type = CONFIG_ESP_WIFI_DYNAMIC_RX_MGMT_BUF, 23 | .rx_mgmt_buf_num = WIFI_RX_MGMT_BUF_NUM_DEF, 24 | .cache_tx_buf_num = WIFI_CACHE_TX_BUFFER_NUM, 25 | .csi_enable = WIFI_CSI_ENABLED, 26 | .ampdu_rx_enable = WIFI_AMPDU_RX_ENABLED, 27 | .ampdu_tx_enable = WIFI_AMPDU_TX_ENABLED, 28 | .amsdu_tx_enable = WIFI_AMSDU_TX_ENABLED, 29 | .nvs_enable = 0, // currently unsupported 30 | .nano_enable = WIFI_NANO_FORMAT_ENABLED, 31 | .rx_ba_win = WIFI_DEFAULT_RX_BA_WIN, 32 | .wifi_task_core_id = WIFI_TASK_CORE_ID, 33 | .beacon_max_len = WIFI_SOFTAP_BEACON_MAX_LEN, 34 | .mgmt_sbuf_num = WIFI_MGMT_SBUF_NUM, 35 | .feature_caps = WIFI_FEATURE_CAPS, 36 | .sta_disconnected_pm = WIFI_STA_DISCONNECTED_PM_ENABLED, 37 | .espnow_max_encrypt_num = CONFIG_ESP_WIFI_ESPNOW_MAX_ENCRYPT_NUM, 38 | .magic = WIFI_INIT_CONFIG_MAGIC 39 | }; 40 | 41 | static char evt; 42 | esp_event_base_t const WIFI_EVENT = &evt; 43 | 44 | void net80211_printf(const char *format, ...) { 45 | va_list args; 46 | va_start(args, format); 47 | printf("espradio net80211: "); 48 | vprintf(format, args); 49 | va_end(args); 50 | } 51 | 52 | void phy_printf(const char *format, ...) { 53 | va_list args; 54 | va_start(args, format); 55 | printf("espradio phy: "); 56 | vprintf(format, args); 57 | va_end(args); 58 | } 59 | 60 | void pp_printf(const char *format, ...) { 61 | va_list args; 62 | va_start(args, format); 63 | printf("espradio pp: "); 64 | vprintf(format, args); 65 | va_end(args); 66 | } 67 | -------------------------------------------------------------------------------- /radio.go: -------------------------------------------------------------------------------- 1 | package espradio 2 | 3 | /* 4 | // TODO: vary these by chip 5 | #cgo CFLAGS: -Iblobs/headers 6 | #cgo CFLAGS: -Iblobs/headers/esp32c3 7 | #cgo CFLAGS: -Iblobs/include 8 | #cgo LDFLAGS: -Lblobs/libs/esp32c3 -lcore -lmesh -lnet80211 -lphy -lpp -lwpa_supplicant 9 | 10 | #include "include.h" 11 | extern wifi_init_config_t wifi_config; 12 | */ 13 | import "C" 14 | import ( 15 | "runtime/interrupt" 16 | "time" 17 | "unsafe" 18 | ) 19 | 20 | type LogLevel uint8 21 | 22 | // Various log levels to use inside the espradio. Higher log levels will produce 23 | // more output over the serial console. 24 | const ( 25 | LogLevelNone = C.WIFI_LOG_NONE 26 | LogLevelError = C.WIFI_LOG_ERROR 27 | LogLevelWarning = C.WIFI_LOG_WARNING 28 | LogLevelInfo = C.WIFI_LOG_INFO 29 | LogLevelDebug = C.WIFI_LOG_DEBUG 30 | LogLevelVerbose = C.WIFI_LOG_VERBOSE 31 | ) 32 | 33 | type Config struct { 34 | Logging LogLevel 35 | } 36 | 37 | // Enable and configure the radio. 38 | func Enable(config Config) error { 39 | initHardware() 40 | 41 | // TODO: run timers in separate goroutine 42 | 43 | errCode := C.esp_wifi_internal_set_log_level(C.wifi_log_level_t(config.Logging)) 44 | if errCode != 0 { 45 | return makeError(errCode) 46 | } 47 | 48 | // TODO: BLE needs the interrupts RWBT, RWBLE, BT_BB 49 | 50 | mask := interrupt.Disable() 51 | // TODO: setup 200Hz tick rate timer 52 | // TODO: init_clocks 53 | interrupt.Restore(mask) 54 | 55 | // Initialize the wireless stack. 56 | errCode = C.esp_wifi_init_internal(&C.wifi_config) 57 | if errCode != 0 { 58 | return makeError(errCode) 59 | } 60 | 61 | return nil 62 | } 63 | 64 | func millisecondsToTicks(ms uint32) uint32 { 65 | return ms * (ticksPerSecond / 1000) 66 | } 67 | 68 | func ticksToMilliseconds(ticks uint32) uint32 { 69 | return ticks / (ticksPerSecond / 1000) 70 | } 71 | 72 | //export espradio_panic 73 | func espradio_panic(msg *C.char) { 74 | panic("espradio: " + C.GoString(msg)) 75 | } 76 | 77 | //export espradio_log_timestamp 78 | func espradio_log_timestamp() uint32 { 79 | return uint32(time.Now().UnixMilli()) 80 | } 81 | 82 | //export espradio_run_task 83 | func espradio_run_task(task_func, param unsafe.Pointer) 84 | 85 | //export espradio_task_create_pinned_to_core 86 | func espradio_task_create_pinned_to_core(task_func unsafe.Pointer, name *C.char, stack_depth uint32, param unsafe.Pointer, prio uint32, task_handle *unsafe.Pointer, core_id uint32) int32 { 87 | ch := make(chan struct{}, 1) 88 | go func() { 89 | *task_handle = tinygo_task_current() 90 | close(ch) 91 | espradio_run_task(task_func, unsafe.Pointer(task_handle)) 92 | }() 93 | <-ch 94 | return 1 95 | } 96 | 97 | //export espradio_task_delete 98 | func espradio_task_delete(task_handle unsafe.Pointer) { 99 | println("espradio TODO: delete task", task_handle) 100 | } 101 | 102 | //export tinygo_task_current 103 | func tinygo_task_current() unsafe.Pointer 104 | 105 | //export espradio_task_get_current_task 106 | func espradio_task_get_current_task() unsafe.Pointer { 107 | return tinygo_task_current() 108 | } 109 | 110 | //export espradio_task_delay 111 | func espradio_task_delay(ticks uint32) { 112 | const ticksPerMillisecond = ticksPerSecond / 1000 113 | // Round milliseconds up. 114 | ms := (ticks + ticksPerMillisecond - 1) / ticksPerMillisecond 115 | time.Sleep(time.Duration(ms) * time.Millisecond) 116 | } 117 | 118 | //export espradio_task_ms_to_tick 119 | func espradio_task_ms_to_tick(ms uint32) int32 { 120 | return int32(millisecondsToTicks(ms)) 121 | } 122 | 123 | //export espradio_wifi_int_disable 124 | func espradio_wifi_int_disable(wifi_int_mux unsafe.Pointer) uint32 { 125 | // This is portENTER_CRITICAL (or portENTER_CRITICAL_ISR). 126 | return uint32(interrupt.Disable()) 127 | } 128 | 129 | //export espradio_wifi_int_restore 130 | func espradio_wifi_int_restore(wifi_int_mux unsafe.Pointer, tmp uint32) { 131 | // This is portEXIT_CRITICAL (or portEXIT_CRITICAL_ISR). 132 | interrupt.Restore(interrupt.State(tmp)) 133 | } 134 | -------------------------------------------------------------------------------- /blobs/headers/esp_system.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | 7 | #ifndef __ESP_SYSTEM_H__ 8 | #define __ESP_SYSTEM_H__ 9 | 10 | #include 11 | #include 12 | #include "esp_err.h" 13 | 14 | #ifdef __cplusplus 15 | extern "C" { 16 | #endif 17 | 18 | /** 19 | * @brief Reset reasons 20 | */ 21 | typedef enum { 22 | ESP_RST_UNKNOWN, //!< Reset reason can not be determined 23 | ESP_RST_POWERON, //!< Reset due to power-on event 24 | ESP_RST_EXT, //!< Reset by external pin (not applicable for ESP32) 25 | ESP_RST_SW, //!< Software reset via esp_restart 26 | ESP_RST_PANIC, //!< Software reset due to exception/panic 27 | ESP_RST_INT_WDT, //!< Reset (software or hardware) due to interrupt watchdog 28 | ESP_RST_TASK_WDT, //!< Reset due to task watchdog 29 | ESP_RST_WDT, //!< Reset due to other watchdogs 30 | ESP_RST_DEEPSLEEP, //!< Reset after exiting deep sleep mode 31 | ESP_RST_BROWNOUT, //!< Brownout reset (software or hardware) 32 | ESP_RST_SDIO, //!< Reset over SDIO 33 | } esp_reset_reason_t; 34 | 35 | /** 36 | * Shutdown handler type 37 | */ 38 | typedef void (*shutdown_handler_t)(void); 39 | 40 | /** 41 | * @brief Register shutdown handler 42 | * 43 | * This function allows you to register a handler that gets invoked before 44 | * the application is restarted using esp_restart function. 45 | * @param handle function to execute on restart 46 | * @return 47 | * - ESP_OK on success 48 | * - ESP_ERR_INVALID_STATE if the handler has already been registered 49 | * - ESP_ERR_NO_MEM if no more shutdown handler slots are available 50 | */ 51 | esp_err_t esp_register_shutdown_handler(shutdown_handler_t handle); 52 | 53 | /** 54 | * @brief Unregister shutdown handler 55 | * 56 | * This function allows you to unregister a handler which was previously 57 | * registered using esp_register_shutdown_handler function. 58 | * - ESP_OK on success 59 | * - ESP_ERR_INVALID_STATE if the given handler hasn't been registered before 60 | */ 61 | esp_err_t esp_unregister_shutdown_handler(shutdown_handler_t handle); 62 | 63 | 64 | /** 65 | * @brief Restart PRO and APP CPUs. 66 | * 67 | * This function can be called both from PRO and APP CPUs. 68 | * After successful restart, CPU reset reason will be SW_CPU_RESET. 69 | * Peripherals (except for Wi-Fi, BT, UART0, SPI1, and legacy timers) are not reset. 70 | * This function does not return. 71 | */ 72 | void esp_restart(void) __attribute__ ((__noreturn__)); 73 | 74 | /** 75 | * @brief Get reason of last reset 76 | * @return See description of esp_reset_reason_t for explanation of each value. 77 | */ 78 | esp_reset_reason_t esp_reset_reason(void); 79 | 80 | /** 81 | * @brief Get the size of available heap. 82 | * 83 | * @note Note that the returned value may be larger than the maximum contiguous block 84 | * which can be allocated. 85 | * 86 | * @return Available heap size, in bytes. 87 | */ 88 | uint32_t esp_get_free_heap_size(void); 89 | 90 | /** 91 | * @brief Get the size of available internal heap. 92 | * 93 | * @note Note that the returned value may be larger than the maximum contiguous block 94 | * which can be allocated. 95 | * 96 | * @return Available internal heap size, in bytes. 97 | */ 98 | uint32_t esp_get_free_internal_heap_size(void); 99 | 100 | /** 101 | * @brief Get the minimum heap that has ever been available 102 | * 103 | * @return Minimum free heap ever available 104 | */ 105 | uint32_t esp_get_minimum_free_heap_size( void ); 106 | 107 | /** 108 | * @brief Trigger a software abort 109 | * 110 | * @param details Details that will be displayed during panic handling. 111 | */ 112 | void __attribute__((__noreturn__)) esp_system_abort(const char* details); 113 | 114 | #ifdef __cplusplus 115 | } 116 | #endif 117 | 118 | #endif /* __ESP_SYSTEM_H__ */ 119 | -------------------------------------------------------------------------------- /blobs/headers/esp32/phy_init_data.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2016-2021 Espressif Systems (Shanghai) CO LTD 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | 7 | #ifndef PHY_INIT_DATA_H 8 | #define PHY_INIT_DATA_H /* don't use #pragma once here, we compile this file sometimes */ 9 | #include "esp_phy_init.h" 10 | #include "sdkconfig.h" 11 | 12 | // constrain a value between 'low' and 'high', inclusive 13 | #define LIMIT(val, low, high) ((val < low) ? low : (val > high) ? high : val) 14 | 15 | #define PHY_INIT_MAGIC "PHYINIT" 16 | 17 | // define the lowest tx power as LOWEST_PHY_TX_POWER 18 | #define PHY_TX_POWER_LOWEST LIMIT(CONFIG_ESP_PHY_MAX_TX_POWER * 4, 0, 52) 19 | #define PHY_TX_POWER_OFFSET 44 20 | #define PHY_TX_POWER_NUM 5 21 | 22 | #if CONFIG_ESP_PHY_MULTIPLE_INIT_DATA_BIN 23 | #define PHY_CRC_ALGORITHM 1 24 | #define PHY_COUNTRY_CODE_LEN 2 25 | #define PHY_INIT_DATA_TYPE_OFFSET 126 26 | #define PHY_SUPPORT_MULTIPLE_BIN_OFFSET 125 27 | #endif 28 | static const char phy_init_magic_pre[] = PHY_INIT_MAGIC; 29 | 30 | /** 31 | * @brief Structure containing default recommended PHY initialization parameters. 32 | */ 33 | static const esp_phy_init_data_t phy_init_data= { { 34 | 3, 35 | 3, 36 | 0x05, 37 | 0x09, 38 | 0x06, 39 | 0x05, 40 | 0x03, 41 | 0x06, 42 | 0x05, 43 | 0x04, 44 | 0x06, 45 | 0x04, 46 | 0x05, 47 | 0x00, 48 | 0x00, 49 | 0x00, 50 | 0x00, 51 | 0x05, 52 | 0x09, 53 | 0x06, 54 | 0x05, 55 | 0x03, 56 | 0x06, 57 | 0x05, 58 | 0x00, 59 | 0x00, 60 | 0x00, 61 | 0x00, 62 | 0x00, 63 | 0x00, 64 | 0x00, 65 | 0x00, 66 | 0xfc, 67 | 0xfc, 68 | 0xfe, 69 | 0xf0, 70 | 0xf0, 71 | 0xf0, 72 | 0xe0, 73 | 0xe0, 74 | 0xe0, 75 | 0x18, 76 | 0x18, 77 | 0x18, 78 | LIMIT(CONFIG_ESP_PHY_MAX_TX_POWER * 4, 40, 78), 79 | LIMIT(CONFIG_ESP_PHY_MAX_TX_POWER * 4, 40, 72), 80 | LIMIT(CONFIG_ESP_PHY_MAX_TX_POWER * 4, 40, 66), 81 | LIMIT(CONFIG_ESP_PHY_MAX_TX_POWER * 4, 40, 60), 82 | LIMIT(CONFIG_ESP_PHY_MAX_TX_POWER * 4, 40, 56), 83 | LIMIT(CONFIG_ESP_PHY_MAX_TX_POWER * 4, 40, 52), 84 | 0, 85 | 1, 86 | 1, 87 | 2, 88 | 2, 89 | 3, 90 | 4, 91 | 5, 92 | 0, 93 | 0, 94 | 0, 95 | 0, 96 | 0, 97 | 0, 98 | 0, 99 | 0, 100 | 0, 101 | 0, 102 | 0, 103 | 0, 104 | 0, 105 | 0, 106 | 0, 107 | 0, 108 | 0, 109 | 0, 110 | 0, 111 | 0, 112 | 0, 113 | 0, 114 | 0, 115 | 0, 116 | 0, 117 | 0, 118 | 0, 119 | 0, 120 | 0, 121 | 0, 122 | 0, 123 | 0, 124 | 0, 125 | 0, 126 | 0, 127 | 0, 128 | 0, 129 | 0, 130 | 0, 131 | 0, 132 | 0, 133 | 0, 134 | 0, 135 | 0, 136 | 0, 137 | 0, 138 | 0, 139 | 0, 140 | 0, 141 | } }; 142 | 143 | static const char phy_init_magic_post[] = PHY_INIT_MAGIC; 144 | 145 | #if CONFIG_ESP_PHY_MULTIPLE_INIT_DATA_BIN 146 | /** 147 | * @brief PHY init data control infomation structure 148 | */ 149 | typedef struct { 150 | uint8_t control_info_checksum[4]; /*!< 4-byte control infomation checksum */ 151 | uint8_t multiple_bin_checksum[4]; /*!< 4-byte multiple bin checksum */ 152 | uint8_t check_algorithm; /*!< check algorithm */ 153 | uint8_t version; /*!< PHY init data bin version */ 154 | uint8_t number; /*!< PHY init data bin number */ 155 | uint8_t length[2]; /*!< Length of each PHY init data bin */ 156 | uint8_t reserved[19]; /*!< 19-byte reserved */ 157 | } __attribute__ ((packed)) phy_control_info_data_t; 158 | 159 | /** 160 | * @brief Country corresponds to PHY init data type structure 161 | */ 162 | typedef struct { 163 | char cc[PHY_COUNTRY_CODE_LEN]; 164 | uint8_t type; 165 | } phy_country_to_bin_type_t; 166 | #endif 167 | #endif /* PHY_INIT_DATA_H */ 168 | -------------------------------------------------------------------------------- /blobs/headers/esp32s3/phy_init_data.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2016-2021 Espressif Systems (Shanghai) CO LTD 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | 7 | #ifndef PHY_INIT_DATA_H 8 | #define PHY_INIT_DATA_H /* don't use #pragma once here, we compile this file sometimes */ 9 | #include "esp_phy_init.h" 10 | #include "sdkconfig.h" 11 | 12 | #ifdef __cplusplus 13 | extern "C" { 14 | #endif 15 | 16 | // constrain a value between 'low' and 'high', inclusive 17 | #define LIMIT(val, low, high) ((val < low) ? low : (val > high) ? high : val) 18 | 19 | #define PHY_INIT_MAGIC "PHYINIT" 20 | 21 | // define the lowest tx power as LOWEST_PHY_TX_POWER 22 | #define PHY_TX_POWER_LOWEST LIMIT(CONFIG_ESP_PHY_MAX_TX_POWER * 4, 0, 52) 23 | #define PHY_TX_POWER_OFFSET 2 24 | #define PHY_TX_POWER_NUM 14 25 | 26 | #if CONFIG_ESP_PHY_MULTIPLE_INIT_DATA_BIN 27 | #define PHY_CRC_ALGORITHM 1 28 | #define PHY_COUNTRY_CODE_LEN 2 29 | #define PHY_INIT_DATA_TYPE_OFFSET 126 30 | #define PHY_SUPPORT_MULTIPLE_BIN_OFFSET 125 31 | #endif 32 | 33 | static const char phy_init_magic_pre[] = PHY_INIT_MAGIC; 34 | 35 | /** 36 | * @brief Structure containing default recommended PHY initialization parameters. 37 | */ 38 | static const esp_phy_init_data_t phy_init_data= { { 39 | 0x00, 40 | 0x00, 41 | LIMIT(CONFIG_ESP_PHY_MAX_TX_POWER * 4, 0, 0x50), 42 | LIMIT(CONFIG_ESP_PHY_MAX_TX_POWER * 4, 0, 0x50), 43 | LIMIT(CONFIG_ESP_PHY_MAX_TX_POWER * 4, 0, 0x50), 44 | LIMIT(CONFIG_ESP_PHY_MAX_TX_POWER * 4, 0, 0x4c), 45 | LIMIT(CONFIG_ESP_PHY_MAX_TX_POWER * 4, 0, 0x4c), 46 | LIMIT(CONFIG_ESP_PHY_MAX_TX_POWER * 4, 0, 0x48), 47 | LIMIT(CONFIG_ESP_PHY_MAX_TX_POWER * 4, 0, 0x4c), 48 | LIMIT(CONFIG_ESP_PHY_MAX_TX_POWER * 4, 0, 0x48), 49 | LIMIT(CONFIG_ESP_PHY_MAX_TX_POWER * 4, 0, 0x48), 50 | LIMIT(CONFIG_ESP_PHY_MAX_TX_POWER * 4, 0, 0x44), 51 | LIMIT(CONFIG_ESP_PHY_MAX_TX_POWER * 4, 0, 0x4a), 52 | LIMIT(CONFIG_ESP_PHY_MAX_TX_POWER * 4, 0, 0x46), 53 | LIMIT(CONFIG_ESP_PHY_MAX_TX_POWER * 4, 0, 0x46), 54 | LIMIT(CONFIG_ESP_PHY_MAX_TX_POWER * 4, 0, 0x42), 55 | 0x00, 56 | 0x00, 57 | 0x00, 58 | 0xff, 59 | 0xff, 60 | 0xff, 61 | 0xff, 62 | 0xff, 63 | 0xff, 64 | 0xff, 65 | 0xff, 66 | 0xff, 67 | 0xff, 68 | 0xff, 69 | 0xff, 70 | 0xff, 71 | 0xff, 72 | 0xff, 73 | 0xff, 74 | 0xff, 75 | 0xff, 76 | 0xff, 77 | 0xff, 78 | 0xff, 79 | 0xff, 80 | 0xff, 81 | 0xff, 82 | 0xff, 83 | 0xff, 84 | 0xff, 85 | 0xff, 86 | 0xff, 87 | 0xff, 88 | 0xff, 89 | 0xff, 90 | 0xff, 91 | 0xff, 92 | 0xff, 93 | 0xff, 94 | 0xff, 95 | 0xff, 96 | 0xff, 97 | 0xff, 98 | 0xff, 99 | 0xff, 100 | 0xff, 101 | 0xff, 102 | 0xff, 103 | 0xff, 104 | 0xff, 105 | 0xff, 106 | 0xff, 107 | 0xff, 108 | 0xff, 109 | 0, 110 | 0, 111 | 0, 112 | 0, 113 | 0, 114 | 0, 115 | 0, 116 | 0, 117 | 0, 118 | 0, 119 | 0, 120 | 0, 121 | 0, 122 | 0, 123 | 0, 124 | 0, 125 | 0, 126 | 0, 127 | 0, 128 | 0, 129 | 0, 130 | 0, 131 | 0, 132 | 0, 133 | 0, 134 | 0, 135 | 0, 136 | 0, 137 | 0, 138 | 0, 139 | 0, 140 | 0, 141 | 0, 142 | 0, 143 | 0, 144 | 0, 145 | 0, 146 | 0, 147 | 0, 148 | 0, 149 | 0, 150 | 0x74 151 | } }; 152 | 153 | static const char phy_init_magic_post[] = PHY_INIT_MAGIC; 154 | 155 | #if CONFIG_ESP_PHY_MULTIPLE_INIT_DATA_BIN 156 | /** 157 | * @brief PHY init data control infomation structure 158 | */ 159 | typedef struct { 160 | uint8_t control_info_checksum[4]; /*!< 4-byte control infomation checksum */ 161 | uint8_t multiple_bin_checksum[4]; /*!< 4-byte multiple bin checksum */ 162 | uint8_t check_algorithm; /*!< check algorithm */ 163 | uint8_t version; /*!< PHY init data bin version */ 164 | uint8_t number; /*!< PHY init data bin number */ 165 | uint8_t length[2]; /*!< Length of each PHY init data bin */ 166 | uint8_t reserved[19]; /*!< 19-byte reserved */ 167 | } __attribute__ ((packed)) phy_control_info_data_t; 168 | 169 | /** 170 | * @brief Country corresponds to PHY init data type structure 171 | */ 172 | typedef struct { 173 | char cc[PHY_COUNTRY_CODE_LEN]; 174 | uint8_t type; 175 | } phy_country_to_bin_type_t; 176 | #endif 177 | 178 | #ifdef __cplusplus 179 | } 180 | #endif 181 | 182 | #endif /* PHY_INIT_DATA_H */ 183 | -------------------------------------------------------------------------------- /blobs/headers/esp32c2/phy_init_data.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2016-2021 Espressif Systems (Shanghai) CO LTD 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | 7 | #ifndef PHY_INIT_DATA_H 8 | #define PHY_INIT_DATA_H /* don't use #pragma once here, we compile this file sometimes */ 9 | #include "esp_phy_init.h" 10 | #include "sdkconfig.h" 11 | 12 | #ifdef __cplusplus 13 | extern "C" { 14 | #endif 15 | 16 | // constrain a value between 'low' and 'high', inclusive 17 | #define LIMIT(val, low, high) ((val < low) ? low : (val > high) ? high : val) 18 | 19 | #define PHY_INIT_MAGIC "PHYINIT" 20 | 21 | // define the lowest tx power as LOWEST_PHY_TX_POWER 22 | #define PHY_TX_POWER_LOWEST LIMIT(CONFIG_ESP_PHY_MAX_TX_POWER * 4, 0, 52) 23 | #define PHY_TX_POWER_OFFSET 2 24 | #define PHY_TX_POWER_NUM 14 25 | 26 | #if CONFIG_ESP_PHY_MULTIPLE_INIT_DATA_BIN 27 | #define PHY_CRC_ALGORITHM 1 28 | #define PHY_COUNTRY_CODE_LEN 2 29 | #define PHY_INIT_DATA_TYPE_OFFSET 126 30 | #define PHY_SUPPORT_MULTIPLE_BIN_OFFSET 125 31 | #endif 32 | 33 | static const char __attribute__((section(".rodata"))) phy_init_magic_pre[] = PHY_INIT_MAGIC; 34 | 35 | /** 36 | * @brief Structure containing default recommended PHY initialization parameters. 37 | */ 38 | static const esp_phy_init_data_t phy_init_data= { { 39 | 0x00, 40 | 0x00, 41 | LIMIT(CONFIG_ESP_PHY_MAX_TX_POWER * 4, 0, 0x50), 42 | LIMIT(CONFIG_ESP_PHY_MAX_TX_POWER * 4, 0, 0x50), 43 | LIMIT(CONFIG_ESP_PHY_MAX_TX_POWER * 4, 0, 0x50), 44 | LIMIT(CONFIG_ESP_PHY_MAX_TX_POWER * 4, 0, 0x4c), 45 | LIMIT(CONFIG_ESP_PHY_MAX_TX_POWER * 4, 0, 0x4c), 46 | LIMIT(CONFIG_ESP_PHY_MAX_TX_POWER * 4, 0, 0x48), 47 | LIMIT(CONFIG_ESP_PHY_MAX_TX_POWER * 4, 0, 0x4c), 48 | LIMIT(CONFIG_ESP_PHY_MAX_TX_POWER * 4, 0, 0x48), 49 | LIMIT(CONFIG_ESP_PHY_MAX_TX_POWER * 4, 0, 0x48), 50 | LIMIT(CONFIG_ESP_PHY_MAX_TX_POWER * 4, 0, 0x44), 51 | LIMIT(CONFIG_ESP_PHY_MAX_TX_POWER * 4, 0, 0x4a), 52 | LIMIT(CONFIG_ESP_PHY_MAX_TX_POWER * 4, 0, 0x46), 53 | LIMIT(CONFIG_ESP_PHY_MAX_TX_POWER * 4, 0, 0x46), 54 | LIMIT(CONFIG_ESP_PHY_MAX_TX_POWER * 4, 0, 0x42), 55 | 0x00, 56 | 0x00, 57 | 0x00, 58 | 0xff, 59 | 0xff, 60 | 0xff, 61 | 0xff, 62 | 0xff, 63 | 0xff, 64 | 0xff, 65 | 0xff, 66 | 0xff, 67 | 0xff, 68 | 0xff, 69 | 0xff, 70 | 0xff, 71 | 0xff, 72 | 0xff, 73 | 0xff, 74 | 0xff, 75 | 0xff, 76 | 0xff, 77 | 0xff, 78 | 0xff, 79 | 0xff, 80 | 0xff, 81 | 0xff, 82 | 0xff, 83 | 0xff, 84 | 0xff, 85 | 0xff, 86 | 0xff, 87 | 0xff, 88 | 0xff, 89 | 0xff, 90 | 0xff, 91 | 0xff, 92 | 0xff, 93 | 0xff, 94 | 0xff, 95 | 0xff, 96 | 0xff, 97 | 0xff, 98 | 0xff, 99 | 0xff, 100 | 0xff, 101 | 0xff, 102 | 0xff, 103 | 0xff, 104 | 0xff, 105 | 0xff, 106 | 0xff, 107 | 0xff, 108 | 0xff, 109 | 0, 110 | 0, 111 | 0, 112 | 0, 113 | 0, 114 | 0, 115 | 0, 116 | 0, 117 | 0, 118 | 0, 119 | 0, 120 | 0, 121 | 0, 122 | 0, 123 | 0, 124 | 0, 125 | 0, 126 | 0, 127 | 0, 128 | 0, 129 | 0, 130 | 0, 131 | 0, 132 | 0, 133 | 0, 134 | 0, 135 | 0, 136 | 0, 137 | 0, 138 | 0, 139 | 0, 140 | 0, 141 | 0, 142 | 0, 143 | 0, 144 | 0, 145 | 0, 146 | 0, 147 | 0, 148 | 0, 149 | 0, 150 | 0x74 151 | } }; 152 | 153 | static const char __attribute__((section(".rodata"))) phy_init_magic_post[] = PHY_INIT_MAGIC; 154 | 155 | #if CONFIG_ESP_PHY_MULTIPLE_INIT_DATA_BIN 156 | /** 157 | * @brief PHY init data control infomation structure 158 | */ 159 | typedef struct { 160 | uint8_t control_info_checksum[4]; /*!< 4-byte control infomation checksum */ 161 | uint8_t multiple_bin_checksum[4]; /*!< 4-byte multiple bin checksum */ 162 | uint8_t check_algorithm; /*!< check algorithm */ 163 | uint8_t version; /*!< PHY init data bin version */ 164 | uint8_t number; /*!< PHY init data bin number */ 165 | uint8_t length[2]; /*!< Length of each PHY init data bin */ 166 | uint8_t reserved[19]; /*!< 19-byte reserved */ 167 | } __attribute__ ((packed)) phy_control_info_data_t; 168 | 169 | /** 170 | * @brief Country corresponds to PHY init data type structure 171 | */ 172 | typedef struct { 173 | char cc[PHY_COUNTRY_CODE_LEN]; 174 | uint8_t type; 175 | } phy_country_to_bin_type_t; 176 | #endif 177 | 178 | #ifdef __cplusplus 179 | } 180 | #endif 181 | 182 | #endif /* PHY_INIT_DATA_H */ 183 | -------------------------------------------------------------------------------- /blobs/headers/esp32c3/phy_init_data.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2016-2021 Espressif Systems (Shanghai) CO LTD 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | 7 | #ifndef PHY_INIT_DATA_H 8 | #define PHY_INIT_DATA_H /* don't use #pragma once here, we compile this file sometimes */ 9 | #include "esp_phy_init.h" 10 | #include "sdkconfig.h" 11 | 12 | #ifdef __cplusplus 13 | extern "C" { 14 | #endif 15 | 16 | // constrain a value between 'low' and 'high', inclusive 17 | #define LIMIT(val, low, high) ((val < low) ? low : (val > high) ? high : val) 18 | 19 | #define PHY_INIT_MAGIC "PHYINIT" 20 | 21 | // define the lowest tx power as LOWEST_PHY_TX_POWER 22 | #define PHY_TX_POWER_LOWEST LIMIT(CONFIG_ESP_PHY_MAX_TX_POWER * 4, 0, 52) 23 | #define PHY_TX_POWER_OFFSET 2 24 | #define PHY_TX_POWER_NUM 14 25 | 26 | #if CONFIG_ESP_PHY_MULTIPLE_INIT_DATA_BIN 27 | #define PHY_CRC_ALGORITHM 1 28 | #define PHY_COUNTRY_CODE_LEN 2 29 | #define PHY_INIT_DATA_TYPE_OFFSET 126 30 | #define PHY_SUPPORT_MULTIPLE_BIN_OFFSET 125 31 | #endif 32 | 33 | static const char __attribute__((section(".rodata"))) phy_init_magic_pre[] = PHY_INIT_MAGIC; 34 | 35 | /** 36 | * @brief Structure containing default recommended PHY initialization parameters. 37 | */ 38 | static const esp_phy_init_data_t phy_init_data= { { 39 | 0x00, 40 | 0x00, 41 | LIMIT(CONFIG_ESP_PHY_MAX_TX_POWER * 4, 0, 0x50), 42 | LIMIT(CONFIG_ESP_PHY_MAX_TX_POWER * 4, 0, 0x50), 43 | LIMIT(CONFIG_ESP_PHY_MAX_TX_POWER * 4, 0, 0x50), 44 | LIMIT(CONFIG_ESP_PHY_MAX_TX_POWER * 4, 0, 0x4c), 45 | LIMIT(CONFIG_ESP_PHY_MAX_TX_POWER * 4, 0, 0x4c), 46 | LIMIT(CONFIG_ESP_PHY_MAX_TX_POWER * 4, 0, 0x48), 47 | LIMIT(CONFIG_ESP_PHY_MAX_TX_POWER * 4, 0, 0x4c), 48 | LIMIT(CONFIG_ESP_PHY_MAX_TX_POWER * 4, 0, 0x48), 49 | LIMIT(CONFIG_ESP_PHY_MAX_TX_POWER * 4, 0, 0x48), 50 | LIMIT(CONFIG_ESP_PHY_MAX_TX_POWER * 4, 0, 0x44), 51 | LIMIT(CONFIG_ESP_PHY_MAX_TX_POWER * 4, 0, 0x4a), 52 | LIMIT(CONFIG_ESP_PHY_MAX_TX_POWER * 4, 0, 0x46), 53 | LIMIT(CONFIG_ESP_PHY_MAX_TX_POWER * 4, 0, 0x46), 54 | LIMIT(CONFIG_ESP_PHY_MAX_TX_POWER * 4, 0, 0x42), 55 | 0x00, 56 | 0x00, 57 | 0x00, 58 | 0xff, 59 | 0xff, 60 | 0xff, 61 | 0xff, 62 | 0xff, 63 | 0xff, 64 | 0xff, 65 | 0xff, 66 | 0xff, 67 | 0xff, 68 | 0xff, 69 | 0xff, 70 | 0xff, 71 | 0xff, 72 | 0xff, 73 | 0xff, 74 | 0xff, 75 | 0xff, 76 | 0xff, 77 | 0xff, 78 | 0xff, 79 | 0xff, 80 | 0xff, 81 | 0xff, 82 | 0xff, 83 | 0xff, 84 | 0xff, 85 | 0xff, 86 | 0xff, 87 | 0xff, 88 | 0xff, 89 | 0xff, 90 | 0xff, 91 | 0xff, 92 | 0xff, 93 | 0xff, 94 | 0xff, 95 | 0xff, 96 | 0xff, 97 | 0xff, 98 | 0xff, 99 | 0xff, 100 | 0xff, 101 | 0xff, 102 | 0xff, 103 | 0xff, 104 | 0xff, 105 | 0xff, 106 | 0xff, 107 | 0xff, 108 | 0xff, 109 | 0, 110 | 0, 111 | 0, 112 | 0, 113 | 0, 114 | 0, 115 | 0, 116 | 0, 117 | 0, 118 | 0, 119 | 0, 120 | 0, 121 | 0, 122 | 0, 123 | 0, 124 | 0, 125 | 0, 126 | 0, 127 | 0, 128 | 0, 129 | 0, 130 | 0, 131 | 0, 132 | 0, 133 | 0, 134 | 0, 135 | 0, 136 | 0, 137 | 0, 138 | 0, 139 | 0, 140 | 0, 141 | 0, 142 | 0, 143 | 0, 144 | 0, 145 | 0, 146 | 0, 147 | 0, 148 | 0, 149 | 0, 150 | 0x74 151 | } }; 152 | 153 | static const char __attribute__((section(".rodata"))) phy_init_magic_post[] = PHY_INIT_MAGIC; 154 | 155 | #if CONFIG_ESP_PHY_MULTIPLE_INIT_DATA_BIN 156 | /** 157 | * @brief PHY init data control infomation structure 158 | */ 159 | typedef struct { 160 | uint8_t control_info_checksum[4]; /*!< 4-byte control infomation checksum */ 161 | uint8_t multiple_bin_checksum[4]; /*!< 4-byte multiple bin checksum */ 162 | uint8_t check_algorithm; /*!< check algorithm */ 163 | uint8_t version; /*!< PHY init data bin version */ 164 | uint8_t number; /*!< PHY init data bin number */ 165 | uint8_t length[2]; /*!< Length of each PHY init data bin */ 166 | uint8_t reserved[19]; /*!< 19-byte reserved */ 167 | } __attribute__ ((packed)) phy_control_info_data_t; 168 | 169 | /** 170 | * @brief Country corresponds to PHY init data type structure 171 | */ 172 | typedef struct { 173 | char cc[PHY_COUNTRY_CODE_LEN]; 174 | uint8_t type; 175 | } phy_country_to_bin_type_t; 176 | #endif 177 | 178 | #ifdef __cplusplus 179 | } 180 | #endif 181 | 182 | #endif /* PHY_INIT_DATA_H */ 183 | -------------------------------------------------------------------------------- /blobs/headers/esp32s2/phy_init_data.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2016-2022 Espressif Systems (Shanghai) CO LTD 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | 7 | #ifndef PHY_INIT_DATA_H 8 | #define PHY_INIT_DATA_H /* don't use #pragma once here, we compile this file sometimes */ 9 | #include "esp_phy_init.h" 10 | #include "sdkconfig.h" 11 | 12 | #ifdef __cplusplus 13 | extern "C" { 14 | #endif 15 | 16 | // constrain a value between 'low' and 'high', inclusive 17 | #define LIMIT(val, low, high) ((val < low) ? low : (val > high) ? high : val) 18 | 19 | #define PHY_INIT_MAGIC "PHYINIT" 20 | 21 | // define the lowest tx power as LOWEST_PHY_TX_POWER 22 | #define PHY_TX_POWER_LOWEST LIMIT(CONFIG_ESP_PHY_MAX_TX_POWER * 4, 0, 52) 23 | #define PHY_TX_POWER_OFFSET 2 24 | #define PHY_TX_POWER_NUM 14 25 | 26 | #if CONFIG_ESP_PHY_MULTIPLE_INIT_DATA_BIN 27 | #define PHY_CRC_ALGORITHM 1 28 | #define PHY_COUNTRY_CODE_LEN 2 29 | #define PHY_INIT_DATA_TYPE_OFFSET 126 30 | #define PHY_SUPPORT_MULTIPLE_BIN_OFFSET 125 31 | #endif 32 | 33 | static const char phy_init_magic_pre[] = PHY_INIT_MAGIC; 34 | 35 | /** 36 | * @brief Structure containing default recommended PHY initialization parameters. 37 | */ 38 | static const esp_phy_init_data_t phy_init_data= { { 39 | 0x80, 40 | 0x00, 41 | LIMIT(CONFIG_ESP_PHY_MAX_TX_POWER * 4, 0, 0x4E), 42 | LIMIT(CONFIG_ESP_PHY_MAX_TX_POWER * 4, 0, 0x4E), 43 | LIMIT(CONFIG_ESP_PHY_MAX_TX_POWER * 4, 0, 0x48), 44 | LIMIT(CONFIG_ESP_PHY_MAX_TX_POWER * 4, 0, 0x48), 45 | LIMIT(CONFIG_ESP_PHY_MAX_TX_POWER * 4, 0, 0x48), 46 | LIMIT(CONFIG_ESP_PHY_MAX_TX_POWER * 4, 0, 0x48), 47 | LIMIT(CONFIG_ESP_PHY_MAX_TX_POWER * 4, 0, 0x48), 48 | LIMIT(CONFIG_ESP_PHY_MAX_TX_POWER * 4, 0, 0x48), 49 | LIMIT(CONFIG_ESP_PHY_MAX_TX_POWER * 4, 0, 0x44), 50 | LIMIT(CONFIG_ESP_PHY_MAX_TX_POWER * 4, 0, 0x44), 51 | LIMIT(CONFIG_ESP_PHY_MAX_TX_POWER * 4, 0, 0x48), 52 | LIMIT(CONFIG_ESP_PHY_MAX_TX_POWER * 4, 0, 0x48), 53 | LIMIT(CONFIG_ESP_PHY_MAX_TX_POWER * 4, 0, 0x44), 54 | LIMIT(CONFIG_ESP_PHY_MAX_TX_POWER * 4, 0, 0x42), 55 | 0x00, 56 | 0x00, 57 | 0x00, 58 | 0xff, 59 | 0xff, 60 | 0xff, 61 | 0xff, 62 | 0xff, 63 | 0xff, 64 | 0xff, 65 | 0xff, 66 | 0xff, 67 | 0xff, 68 | 0xff, 69 | 0xff, 70 | 0xff, 71 | 0xff, 72 | 0xff, 73 | 0xff, 74 | 0xff, 75 | 0xff, 76 | 0xff, 77 | 0xff, 78 | 0xff, 79 | 0xff, 80 | 0xff, 81 | 0xff, 82 | 0xff, 83 | 0xff, 84 | 0xff, 85 | 0xff, 86 | 0xff, 87 | 0xff, 88 | 0xff, 89 | 0xff, 90 | 0xff, 91 | 0xff, 92 | 0xff, 93 | 0xff, 94 | 0xff, 95 | 0xff, 96 | 0xff, 97 | 0xff, 98 | 0xff, 99 | 0xff, 100 | 0xff, 101 | 0xff, 102 | 0xff, 103 | 0xff, 104 | 0xff, 105 | 0xff, 106 | 0xff, 107 | 0xff, 108 | 0xff, 109 | 0, 110 | 0, 111 | 0, 112 | 0, 113 | 0, 114 | 0, 115 | 0, 116 | 0, 117 | 0, 118 | 0, 119 | 0, 120 | 0, 121 | 0, 122 | 0, 123 | 0, 124 | 0, 125 | 0, 126 | 0, 127 | 0, 128 | 0, 129 | 0, 130 | 0, 131 | 0, 132 | 0, 133 | 0, 134 | 0, 135 | 0, 136 | 0, 137 | 0, 138 | 0, 139 | 0, 140 | 0, 141 | 0, 142 | 0, 143 | 0, 144 | 0, 145 | 0, 146 | 0, 147 | 0, 148 | 0, 149 | 0, 150 | 0, 151 | 0, 152 | 0, 153 | 0, 154 | 0, 155 | 0, 156 | 0, 157 | 0, 158 | 0, 159 | 0, 160 | 0, 161 | 0, 162 | 0, 163 | 0, 164 | 0, 165 | 0, 166 | 0xf1 167 | } }; 168 | 169 | static const char phy_init_magic_post[] = PHY_INIT_MAGIC; 170 | 171 | #if CONFIG_ESP_PHY_MULTIPLE_INIT_DATA_BIN 172 | /** 173 | * @brief PHY init data control infomation structure 174 | */ 175 | typedef struct { 176 | uint8_t control_info_checksum[4]; /*!< 4-byte control infomation checksum */ 177 | uint8_t multiple_bin_checksum[4]; /*!< 4-byte multiple bin checksum */ 178 | uint8_t check_algorithm; /*!< check algorithm */ 179 | uint8_t version; /*!< PHY init data bin version */ 180 | uint8_t number; /*!< PHY init data bin number */ 181 | uint8_t length[2]; /*!< Length of each PHY init data bin */ 182 | uint8_t reserved[19]; /*!< 19-byte reserved */ 183 | } __attribute__ ((packed)) phy_control_info_data_t; 184 | 185 | /** 186 | * @brief Country corresponds to PHY init data type structure 187 | */ 188 | typedef struct { 189 | char cc[PHY_COUNTRY_CODE_LEN]; 190 | uint8_t type; 191 | } phy_country_to_bin_type_t; 192 | #endif 193 | 194 | #ifdef __cplusplus 195 | } 196 | #endif 197 | 198 | #endif /* PHY_INIT_DATA_H */ 199 | -------------------------------------------------------------------------------- /blobs/headers/esp32c6/phy_init_data.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2016-2022 Espressif Systems (Shanghai) CO LTD 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | 7 | #ifndef PHY_INIT_DATA_H 8 | #define PHY_INIT_DATA_H /* don't use #pragma once here, we compile this file sometimes */ 9 | #include "esp_phy_init.h" 10 | #include "sdkconfig.h" 11 | 12 | #ifdef __cplusplus 13 | extern "C" { 14 | #endif 15 | 16 | // constrain a value between 'low' and 'high', inclusive 17 | #define LIMIT(val, low, high) ((val < low) ? low : (val > high) ? high : val) 18 | 19 | #define PHY_INIT_MAGIC "PHYINIT" 20 | 21 | // define the lowest tx power as LOWEST_PHY_TX_POWER 22 | #define PHY_TX_POWER_LOWEST LIMIT(CONFIG_ESP_PHY_MAX_TX_POWER * 4, 0, 52) 23 | #define PHY_TX_POWER_OFFSET 2 24 | #define PHY_TX_POWER_NUM 14 25 | 26 | #if CONFIG_ESP_PHY_MULTIPLE_INIT_DATA_BIN 27 | #define PHY_CRC_ALGORITHM 1 28 | #define PHY_COUNTRY_CODE_LEN 2 29 | #define PHY_INIT_DATA_TYPE_OFFSET 126 30 | #define PHY_SUPPORT_MULTIPLE_BIN_OFFSET 125 31 | #endif 32 | 33 | 34 | static const char __attribute__((section(".rodata"))) phy_init_magic_pre[] = PHY_INIT_MAGIC; 35 | 36 | /** 37 | * @brief Structure containing default recommended PHY initialization parameters. 38 | */ 39 | static const esp_phy_init_data_t phy_init_data= { { 40 | 0x01, 41 | 0x00, 42 | LIMIT(CONFIG_ESP_PHY_MAX_TX_POWER * 4, 0, 0x54), 43 | LIMIT(CONFIG_ESP_PHY_MAX_TX_POWER * 4, 0, 0x54), 44 | LIMIT(CONFIG_ESP_PHY_MAX_TX_POWER * 4, 0, 0x50), 45 | LIMIT(CONFIG_ESP_PHY_MAX_TX_POWER * 4, 0, 0x50), 46 | LIMIT(CONFIG_ESP_PHY_MAX_TX_POWER * 4, 0, 0x50), 47 | LIMIT(CONFIG_ESP_PHY_MAX_TX_POWER * 4, 0, 0x4c), 48 | LIMIT(CONFIG_ESP_PHY_MAX_TX_POWER * 4, 0, 0x4c), 49 | LIMIT(CONFIG_ESP_PHY_MAX_TX_POWER * 4, 0, 0x4c), 50 | LIMIT(CONFIG_ESP_PHY_MAX_TX_POWER * 4, 0, 0x4c), 51 | LIMIT(CONFIG_ESP_PHY_MAX_TX_POWER * 4, 0, 0x48), 52 | LIMIT(CONFIG_ESP_PHY_MAX_TX_POWER * 4, 0, 0x44), 53 | LIMIT(CONFIG_ESP_PHY_MAX_TX_POWER * 4, 0, 0x3C), 54 | LIMIT(CONFIG_ESP_PHY_MAX_TX_POWER * 4, 0, 0x3C), 55 | LIMIT(CONFIG_ESP_PHY_MAX_TX_POWER * 4, 0, 0x3C), 56 | 0x00, 57 | 0x00, 58 | 0x00, 59 | 0xff, 60 | 0xff, 61 | 0xff, 62 | 0xff, 63 | 0xff, 64 | 0xff, 65 | 0xff, 66 | 0xff, 67 | 0xff, 68 | 0xff, 69 | 0xff, 70 | 0xff, 71 | 0xff, 72 | 0xff, 73 | 0xff, 74 | 0xff, 75 | 0xff, 76 | 0xff, 77 | 0xff, 78 | 0xff, 79 | 0xff, 80 | 0xff, 81 | 0xff, 82 | 0xff, 83 | 0xff, 84 | 0xff, 85 | 0xff, 86 | 0xff, 87 | 0xff, 88 | 0xff, 89 | 0xff, 90 | 0xff, 91 | 0xff, 92 | 0xff, 93 | 0xff, 94 | 0xff, 95 | 0xff, 96 | 0xff, 97 | 0xff, 98 | 0xff, 99 | 0xff, 100 | 0xff, 101 | 0xff, 102 | 0xff, 103 | 0xff, 104 | 0xff, 105 | 0xff, 106 | 0xff, 107 | 0xff, 108 | 0xff, 109 | 0xff, 110 | 0, 111 | 0, 112 | 0, 113 | 0, 114 | 0, 115 | 0, 116 | 0, 117 | 0, 118 | 0, 119 | 0, 120 | 0, 121 | 0, 122 | 0, 123 | 0, 124 | 0, 125 | 0, 126 | 0, 127 | 0, 128 | 0, 129 | 0, 130 | 0, 131 | 0, 132 | 0, 133 | 0, 134 | 0, 135 | 0, 136 | 0, 137 | 0, 138 | 0, 139 | 0, 140 | 0, 141 | 0, 142 | 0, 143 | 0, 144 | 0, 145 | 0, 146 | 0, 147 | 0, 148 | 0, 149 | 0, 150 | 0, 151 | 0, 152 | 0, 153 | 0, 154 | 0, 155 | 0, 156 | 0, 157 | 0, 158 | 0, 159 | 0, 160 | 0, 161 | 0, 162 | 0, 163 | 0, 164 | 0, 165 | 0, 166 | 0, 167 | 0x70 168 | } }; 169 | 170 | static const char __attribute__((section(".rodata"))) phy_init_magic_post[] = PHY_INIT_MAGIC; 171 | 172 | #if CONFIG_ESP_PHY_MULTIPLE_INIT_DATA_BIN 173 | /** 174 | * @brief PHY init data control infomation structure 175 | */ 176 | typedef struct { 177 | uint8_t control_info_checksum[4]; /*!< 4-byte control infomation checksum */ 178 | uint8_t multiple_bin_checksum[4]; /*!< 4-byte multiple bin checksum */ 179 | uint8_t check_algorithm; /*!< check algorithm */ 180 | uint8_t version; /*!< PHY init data bin version */ 181 | uint8_t number; /*!< PHY init data bin number */ 182 | uint8_t length[2]; /*!< Length of each PHY init data bin */ 183 | uint8_t reserved[19]; /*!< 19-byte reserved */ 184 | } __attribute__ ((packed)) phy_control_info_data_t; 185 | 186 | /** 187 | * @brief Country corresponds to PHY init data type structure 188 | */ 189 | typedef struct { 190 | char cc[PHY_COUNTRY_CODE_LEN]; 191 | uint8_t type; 192 | } phy_country_to_bin_type_t; 193 | #endif 194 | 195 | #ifdef __cplusplus 196 | } 197 | #endif 198 | 199 | #endif /* PHY_INIT_DATA_H */ 200 | -------------------------------------------------------------------------------- /blobs/headers/phy.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | 7 | #pragma once 8 | #include "esp_phy_init.h" 9 | 10 | #ifdef __cplusplus 11 | extern "C" { 12 | #endif 13 | 14 | #define ESP_CAL_DATA_CHECK_FAIL 1 15 | 16 | typedef enum { 17 | PHY_I2C_MST_CMD_TYPE_OFF = 0, 18 | PHY_I2C_MST_CMD_TYPE_ON, 19 | PHY_I2C_MST_CMD_TYPE_MAX 20 | } phy_i2c_master_command_type_t; 21 | 22 | typedef struct { 23 | struct { 24 | uint8_t start, end; /* the start and end index of phy i2c master command memory */ 25 | uint8_t host_id; /* phy i2c master host id */ 26 | } config[PHY_I2C_MST_CMD_TYPE_MAX]; 27 | } phy_i2c_master_command_attribute_t; 28 | 29 | /** 30 | * @file phy.h 31 | * @brief Declarations for functions provided by libphy.a 32 | */ 33 | 34 | /** 35 | * @brief Return ROM function pointer table from PHY library. 36 | */ 37 | void phy_get_romfunc_addr(void); 38 | 39 | /** 40 | * @brief Initialize PHY module and do RF calibration 41 | * @param[in] init_data Initialization parameters to be used by the PHY 42 | * @param[inout] cal_data As input, calibration data previously obtained. As output, will contain new calibration data. 43 | * @param[in] cal_mode RF calibration mode 44 | * @return ESP_CAL_DATA_CHECK_FAIL if calibration data checksum fails, other values are reserved for future use 45 | */ 46 | int register_chipv7_phy(const esp_phy_init_data_t* init_data, esp_phy_calibration_data_t *cal_data, esp_phy_calibration_mode_t cal_mode); 47 | 48 | /** 49 | * @brief Get the format version of calibration data used by PHY library. 50 | * @return Format version number, OR'ed with BIT(16) if PHY is in WIFI only mode. 51 | */ 52 | uint32_t phy_get_rf_cal_version(void); 53 | 54 | /** 55 | * @brief Set RF/BB for only WIFI mode or coexist(WIFI & BT) mode 56 | * @param[in] true is for only WIFI mode, false is for coexist mode. default is 0. 57 | * @return NULL 58 | */ 59 | void phy_set_wifi_mode_only(bool wifi_only); 60 | 61 | /** 62 | * @brief Set BT the highest priority in coexist mode. 63 | * @return NULL 64 | */ 65 | void coex_bt_high_prio(void); 66 | 67 | /** 68 | * @brief Open PHY and RF. 69 | */ 70 | void phy_wakeup_init(void); 71 | 72 | /** 73 | * @brief Shutdown PHY and RF. 74 | */ 75 | void phy_close_rf(void); 76 | 77 | #if !CONFIG_IDF_TARGET_ESP32 78 | /** 79 | * @brief Disable PHY temperature sensor. 80 | */ 81 | void phy_xpd_tsens(void); 82 | #endif 83 | 84 | #if CONFIG_IDF_TARGET_ESP32C3 85 | /** 86 | * @brief Update internal state of PHY when wifi deinit powers off the wifi power domain. 87 | */ 88 | void phy_init_flag(void); 89 | #endif 90 | 91 | #if CONFIG_IDF_TARGET_ESP32C6 92 | /** 93 | * @brief Get the configuration info of PHY i2c master command memory. 94 | * 95 | * @param attr the configuration info of PHY i2c master command memory 96 | */ 97 | void phy_i2c_master_mem_cfg(phy_i2c_master_command_attribute_t *attr); 98 | #endif 99 | 100 | /** 101 | * @brief Store and load PHY digital registers. 102 | * 103 | * @param backup_en if backup_en is true, store PHY digital registers to memory. Otherwise load PHY digital registers from memory 104 | * @param mem_addr Memory address to store and load PHY digital registers 105 | * 106 | * @return memory size 107 | */ 108 | uint8_t phy_dig_reg_backup(bool backup_en, uint32_t *mem_addr); 109 | 110 | #if CONFIG_MAC_BB_PD 111 | /** 112 | * @brief Store and load baseband registers. 113 | */ 114 | void phy_freq_mem_backup(bool backup_en, uint32_t *mem); 115 | #endif 116 | 117 | #if CONFIG_ESP_PHY_ENABLE_USB 118 | /** 119 | * @brief Enable or disable USB when phy init. 120 | */ 121 | void phy_bbpll_en_usb(bool en); 122 | #endif 123 | 124 | #if CONFIG_IDF_TARGET_ESP32S2 125 | /** 126 | * @brief Phy version select for ESP32S2 127 | */ 128 | void phy_eco_version_sel(uint8_t chip_ver); 129 | #endif 130 | 131 | #if CONFIG_ESP_PHY_IMPROVE_RX_11B 132 | /** 133 | * @brief Improve Wi-Fi receive 11b pkts when modules with high interference. 134 | * 135 | * @attention 1.This is a workaround to improve Wi-Fi receive 11b pkts for some modules using AC-DC power supply with high interference. 136 | * @attention 2.Enable this will sacrifice Wi-Fi OFDM receive performance. But to guarantee 11b receive performance serves as a bottom line in this case. 137 | * 138 | * @param enable Enable or disable. 139 | */ 140 | void phy_improve_rx_special(bool enable); 141 | #endif 142 | 143 | /** 144 | * @brief Enable phy track pll 145 | * 146 | */ 147 | void phy_track_pll_init(void); 148 | 149 | /** 150 | * @brief Disable phy track pll 151 | * 152 | */ 153 | void phy_track_pll_deinit(void); 154 | 155 | /** 156 | * @brief Set the flag recorded which modem has already enabled phy 157 | * 158 | */ 159 | void phy_set_modem_flag(esp_phy_modem_t modem); 160 | 161 | /** 162 | * @brief Clear the flag to record which modem calls phy disenable 163 | */ 164 | void phy_clr_modem_flag(esp_phy_modem_t modem); 165 | 166 | /** 167 | * @brief Get the flag recorded which modem has already enabled phy 168 | * 169 | */ 170 | esp_phy_modem_t phy_get_modem_flag(void); 171 | 172 | /** 173 | * @brief Get the PHY lock, only used in esp_phy, the user should not use this function. 174 | * 175 | */ 176 | _lock_t phy_get_lock(void); 177 | #ifdef __cplusplus 178 | } 179 | #endif 180 | -------------------------------------------------------------------------------- /sync.go: -------------------------------------------------------------------------------- 1 | package espradio 2 | 3 | // Various functions related to locks, mutexes, semaphores, and queues. 4 | 5 | /* 6 | #include "include.h" 7 | */ 8 | import "C" 9 | 10 | import ( 11 | "sync" 12 | "sync/atomic" 13 | "time" 14 | "unsafe" 15 | ) 16 | 17 | // Use a single fake spinlock. This is also how the Rust port does it. 18 | var fakeSpinLock uint8 19 | 20 | //export espradio_spin_lock_create 21 | func espradio_spin_lock_create() unsafe.Pointer { 22 | return unsafe.Pointer(&fakeSpinLock) 23 | } 24 | 25 | //export espradio_spin_lock_delete 26 | func espradio_spin_lock_delete(lock unsafe.Pointer) { 27 | } 28 | 29 | // Use a global array of mutexes, because the binary blobs don't need that many. 30 | var mutexes [2]sync.Mutex 31 | var mutexIndex uint32 32 | 33 | //export espradio_recursive_mutex_create 34 | func espradio_recursive_mutex_create() unsafe.Pointer { 35 | // Allocate a mutex from the global array. 36 | // If the radio needs more mutexes, this will result in an index out of 37 | // range panic (hopefully including a source location, if using 38 | // `tinygo flash -monitor`). 39 | newIndex := atomic.AddUint32(&mutexIndex, 1) 40 | mutex := &mutexes[newIndex-1] 41 | return unsafe.Pointer(mutex) 42 | } 43 | 44 | //export espradio_mutex_lock 45 | func espradio_mutex_lock(cmut unsafe.Pointer) int32 { 46 | // This is xSemaphoreTake with an infinite timeout in ESP-IDF. Therefore, 47 | // just lock the mutex and return true. 48 | // TODO: recursive locking. See: 49 | // https://www.freertos.org/RTOS-Recursive-Mutexes.html 50 | // For that we need to track the current goroutine - or maybe just whether 51 | // we're inside a special goroutine like the timer goroutine. 52 | mut := (*sync.Mutex)(cmut) 53 | mut.Lock() 54 | return 1 55 | } 56 | 57 | //export espradio_mutex_unlock 58 | func espradio_mutex_unlock(cmut unsafe.Pointer) int32 { 59 | // Note: this is xSemaphoreGive in the ESP-IDF, which doesn't panic when 60 | // unlocking fails but rather returns false. 61 | mut := (*sync.Mutex)(cmut) 62 | mut.Unlock() 63 | return 1 64 | } 65 | 66 | type semaphore chan struct{} 67 | 68 | var semaphores [2]semaphore 69 | var semaphoreIndex uint32 70 | var wifiSemaphore semaphore 71 | 72 | //export espradio_semphr_create 73 | func espradio_semphr_create(max, init uint32) unsafe.Pointer { 74 | newIndex := atomic.AddUint32(&semaphoreIndex, 1) 75 | sem := &semaphores[newIndex-1] 76 | ch := make(semaphore, max) 77 | for i := uint32(0); i < init; i++ { 78 | ch <- struct{}{} 79 | } 80 | *sem = ch 81 | return unsafe.Pointer(sem) 82 | } 83 | 84 | //export espradio_semphr_take 85 | func espradio_semphr_take(semphr unsafe.Pointer, block_time_tick uint32) int32 { 86 | sem := (*semaphore)(semphr) 87 | if block_time_tick != C.OSI_FUNCS_TIME_BLOCKING { 88 | panic("espradio: todo: semphr_take with timeout") 89 | } 90 | <-*sem 91 | return 1 92 | } 93 | 94 | //export espradio_semphr_give 95 | func espradio_semphr_give(semphr unsafe.Pointer) int32 { 96 | // Note: we might need to return 0 when sending isn't possible (e.g. using a 97 | // non-blocking send). According to the documentation of xSemaphoreGive: 98 | // 99 | // > pdTRUE if the semaphore was released. pdFALSE if an error occurred. 100 | // > Semaphores are implemented using queues. An error can occur if there is 101 | // > no space on the queue to post a message - indicating that the semaphore 102 | // > was not first obtained correctly. 103 | sem := (*semaphore)(semphr) 104 | *sem <- struct{}{} 105 | return 1 106 | } 107 | 108 | //export espradio_semphr_delete 109 | func espradio_semphr_delete(semphr unsafe.Pointer) { 110 | sem := (*semaphore)(semphr) 111 | close(*sem) 112 | } 113 | 114 | //export espradio_wifi_thread_semphr_get 115 | func espradio_wifi_thread_semphr_get() unsafe.Pointer { 116 | if wifiSemaphore == nil { 117 | wifiSemaphore = make(semaphore, 1) 118 | } 119 | return unsafe.Pointer(&wifiSemaphore) 120 | } 121 | 122 | type queueElementType [8]byte 123 | 124 | //export espradio_wifi_create_queue 125 | func espradio_wifi_create_queue(queue_len, item_size int) chan queueElementType { 126 | if item_size != len(queueElementType{}) { 127 | panic("espradio: unexpected queue item_size") 128 | } 129 | return make(chan queueElementType, item_size) 130 | } 131 | 132 | //export espradio_wifi_delete_queue 133 | func espradio_wifi_delete_queue(queue chan queueElementType) { 134 | // We can't really delete a channel, but we can close it. 135 | close(queue) 136 | } 137 | 138 | //export espradio_queue_recv 139 | func espradio_queue_recv(queue chan queueElementType, item unsafe.Pointer, block_time_tick uint32) int32 { 140 | // This is xQueueReceive. 141 | if block_time_tick != C.OSI_FUNCS_TIME_BLOCKING { 142 | panic("espradio: todo: queue_recv with timeout") 143 | } 144 | *(*[8]byte)(item) = <-queue 145 | return 1 146 | } 147 | 148 | //export espradio_queue_send 149 | func espradio_queue_send(queue chan queueElementType, item unsafe.Pointer, block_time_tick uint32) int32 { 150 | // This is xQueueSend. 151 | if block_time_tick != C.OSI_FUNCS_TIME_BLOCKING { 152 | duration := time.Duration(ticksToMilliseconds(block_time_tick)) * time.Millisecond 153 | // TODO: reuse the timer to avoid allocating a new timer on each queue send 154 | select { 155 | case <-time.After(duration): 156 | return 0 157 | case queue <- *(*[8]byte)(item): 158 | return 1 159 | } 160 | } 161 | queue <- *(*[8]byte)(item) 162 | return 1 163 | } 164 | -------------------------------------------------------------------------------- /blobs/include/nimble/nimble_npl.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | #ifndef _NIMBLE_NPL_H_ 21 | #define _NIMBLE_NPL_H_ 22 | 23 | #include 24 | #include 25 | #include 26 | 27 | #ifdef __cplusplus 28 | extern "C" { 29 | #endif 30 | 31 | struct ble_npl_event; 32 | typedef void ble_npl_event_fn(struct ble_npl_event *ev); 33 | 34 | enum ble_npl_error { 35 | BLE_NPL_OK = 0, 36 | BLE_NPL_ENOMEM = 1, 37 | BLE_NPL_EINVAL = 2, 38 | BLE_NPL_INVALID_PARAM = 3, 39 | BLE_NPL_MEM_NOT_ALIGNED = 4, 40 | BLE_NPL_BAD_MUTEX = 5, 41 | BLE_NPL_TIMEOUT = 6, 42 | BLE_NPL_ERR_IN_ISR = 7, 43 | BLE_NPL_ERR_PRIV = 8, 44 | BLE_NPL_OS_NOT_STARTED = 9, 45 | BLE_NPL_ENOENT = 10, 46 | BLE_NPL_EBUSY = 11, 47 | BLE_NPL_ERROR = 12, 48 | }; 49 | 50 | typedef enum ble_npl_error ble_npl_error_t; 51 | 52 | /* Include OS-specific definitions */ 53 | #include "nimble/nimble_npl_os.h" 54 | 55 | /* 56 | * Generic 57 | */ 58 | 59 | bool ble_npl_os_started(void); 60 | 61 | void *ble_npl_get_current_task_id(void); 62 | 63 | /* 64 | * Event queue 65 | */ 66 | 67 | void ble_npl_eventq_init(struct ble_npl_eventq *evq); 68 | 69 | void ble_npl_eventq_deinit(struct ble_npl_eventq *evq); 70 | 71 | struct ble_npl_event *ble_npl_eventq_get(struct ble_npl_eventq *evq, 72 | ble_npl_time_t tmo); 73 | 74 | void ble_npl_eventq_put(struct ble_npl_eventq *evq, struct ble_npl_event *ev); 75 | 76 | void ble_npl_eventq_remove(struct ble_npl_eventq *evq, 77 | struct ble_npl_event *ev); 78 | 79 | void ble_npl_event_init(struct ble_npl_event *ev, ble_npl_event_fn *fn, 80 | void *arg); 81 | 82 | bool ble_npl_event_is_queued(struct ble_npl_event *ev); 83 | 84 | void *ble_npl_event_get_arg(struct ble_npl_event *ev); 85 | 86 | void ble_npl_event_set_arg(struct ble_npl_event *ev, void *arg); 87 | 88 | bool ble_npl_eventq_is_empty(struct ble_npl_eventq *evq); 89 | 90 | void ble_npl_event_run(struct ble_npl_event *ev); 91 | 92 | /* 93 | * Mutexes 94 | */ 95 | 96 | ble_npl_error_t ble_npl_mutex_init(struct ble_npl_mutex *mu); 97 | 98 | ble_npl_error_t ble_npl_mutex_pend(struct ble_npl_mutex *mu, 99 | ble_npl_time_t timeout); 100 | 101 | ble_npl_error_t ble_npl_mutex_release(struct ble_npl_mutex *mu); 102 | 103 | ble_npl_error_t ble_npl_mutex_deinit(struct ble_npl_mutex *mu); 104 | 105 | /* 106 | * Semaphores 107 | */ 108 | 109 | ble_npl_error_t ble_npl_sem_init(struct ble_npl_sem *sem, uint16_t tokens); 110 | 111 | ble_npl_error_t ble_npl_sem_pend(struct ble_npl_sem *sem, 112 | ble_npl_time_t timeout); 113 | 114 | ble_npl_error_t ble_npl_sem_release(struct ble_npl_sem *sem); 115 | 116 | ble_npl_error_t ble_npl_sem_deinit(struct ble_npl_sem *sem); 117 | 118 | uint16_t ble_npl_sem_get_count(struct ble_npl_sem *sem); 119 | 120 | /* 121 | * Callouts 122 | */ 123 | 124 | int ble_npl_callout_init(struct ble_npl_callout *co, struct ble_npl_eventq *evq, 125 | ble_npl_event_fn *ev_cb, void *ev_arg); 126 | 127 | ble_npl_error_t ble_npl_callout_reset(struct ble_npl_callout *co, 128 | ble_npl_time_t ticks); 129 | 130 | void ble_npl_callout_stop(struct ble_npl_callout *co); 131 | 132 | bool ble_npl_callout_is_active(struct ble_npl_callout *co); 133 | 134 | ble_npl_time_t ble_npl_callout_get_ticks(struct ble_npl_callout *co); 135 | 136 | ble_npl_time_t ble_npl_callout_remaining_ticks(struct ble_npl_callout *co, 137 | ble_npl_time_t time); 138 | 139 | void ble_npl_callout_set_arg(struct ble_npl_callout *co, 140 | void *arg); 141 | /* 142 | * Time functions 143 | */ 144 | 145 | ble_npl_time_t ble_npl_time_get(void); 146 | 147 | ble_npl_error_t ble_npl_time_ms_to_ticks(uint32_t ms, ble_npl_time_t *out_ticks); 148 | 149 | ble_npl_error_t ble_npl_time_ticks_to_ms(ble_npl_time_t ticks, uint32_t *out_ms); 150 | 151 | ble_npl_time_t ble_npl_time_ms_to_ticks32(uint32_t ms); 152 | 153 | uint32_t ble_npl_time_ticks_to_ms32(ble_npl_time_t ticks); 154 | 155 | void ble_npl_time_delay(ble_npl_time_t ticks); 156 | 157 | /* 158 | * Hardware-specific 159 | * 160 | * These symbols should be most likely defined by application since they are 161 | * specific to hardware, not to OS. 162 | */ 163 | 164 | #if NIMBLE_CFG_CONTROLLER 165 | 166 | void ble_npl_hw_set_isr(int irqn, uint32_t addr); 167 | 168 | #endif 169 | 170 | uint32_t ble_npl_hw_enter_critical(void); 171 | 172 | void ble_npl_hw_exit_critical(uint32_t ctx); 173 | 174 | bool ble_npl_hw_is_in_critical(void); 175 | 176 | #ifdef __cplusplus 177 | } 178 | #endif 179 | 180 | #endif /* _NIMBLE_NPL_H_ */ 181 | -------------------------------------------------------------------------------- /blobs/headers/esp_wifi_default.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2019-2023 Espressif Systems (Shanghai) CO LTD 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | 7 | #ifndef _ESP_WIFI_DEFAULT_H 8 | #define _ESP_WIFI_DEFAULT_H 9 | 10 | #include "esp_netif.h" 11 | #include "esp_wifi_types.h" 12 | 13 | #ifdef __cplusplus 14 | extern "C" { 15 | #endif 16 | 17 | /** 18 | * @brief Attaches wifi station interface to supplied netif 19 | * 20 | * @param esp_netif instance to attach the wifi station to 21 | * 22 | * @return 23 | * - ESP_OK on success 24 | * - ESP_FAIL if attach failed 25 | */ 26 | esp_err_t esp_netif_attach_wifi_station(esp_netif_t *esp_netif); 27 | 28 | /** 29 | * @brief Attaches wifi soft AP interface to supplied netif 30 | * 31 | * @param esp_netif instance to attach the wifi AP to 32 | * 33 | * @return 34 | * - ESP_OK on success 35 | * - ESP_FAIL if attach failed 36 | */ 37 | esp_err_t esp_netif_attach_wifi_ap(esp_netif_t *esp_netif); 38 | 39 | /** 40 | * @brief Sets default wifi event handlers for STA interface 41 | * 42 | * @return 43 | * - ESP_OK on success, error returned from esp_event_handler_register if failed 44 | */ 45 | esp_err_t esp_wifi_set_default_wifi_sta_handlers(void); 46 | 47 | /** 48 | * @brief Sets default wifi event handlers for AP interface 49 | * 50 | * @return 51 | * - ESP_OK on success, error returned from esp_event_handler_register if failed 52 | */ 53 | esp_err_t esp_wifi_set_default_wifi_ap_handlers(void); 54 | 55 | /** 56 | * @brief Sets default wifi event handlers for NAN interface 57 | * 58 | * @return 59 | * - ESP_OK on success, error returned from esp_event_handler_register if failed 60 | */ 61 | esp_err_t esp_wifi_set_default_wifi_nan_handlers(void); 62 | 63 | /** 64 | * @brief Clears default wifi event handlers for supplied network interface 65 | * 66 | * @param esp_netif instance of corresponding if object 67 | * 68 | * @return 69 | * - ESP_OK on success, error returned from esp_event_handler_register if failed 70 | */ 71 | esp_err_t esp_wifi_clear_default_wifi_driver_and_handlers(void *esp_netif); 72 | 73 | /** 74 | * @brief Creates default WIFI AP. In case of any init error this API aborts. 75 | * 76 | * @note The API creates esp_netif object with default WiFi access point config, 77 | * attaches the netif to wifi and registers wifi handlers to the default event loop. 78 | * This API uses assert() to check for potential errors, so it could abort the program. 79 | * (Note that the default event loop needs to be created prior to calling this API) 80 | * 81 | * @return pointer to esp-netif instance 82 | */ 83 | esp_netif_t* esp_netif_create_default_wifi_ap(void); 84 | 85 | /** 86 | * @brief Creates default WIFI STA. In case of any init error this API aborts. 87 | * 88 | * @note The API creates esp_netif object with default WiFi station config, 89 | * attaches the netif to wifi and registers wifi handlers to the default event loop. 90 | * This API uses assert() to check for potential errors, so it could abort the program. 91 | * (Note that the default event loop needs to be created prior to calling this API) 92 | * 93 | * @return pointer to esp-netif instance 94 | */ 95 | esp_netif_t* esp_netif_create_default_wifi_sta(void); 96 | 97 | /** 98 | * @brief Creates default WIFI NAN. In case of any init error this API aborts. 99 | * 100 | * @note The API creates esp_netif object with default WiFi station config, 101 | * attaches the netif to wifi and registers wifi handlers to the default event loop. 102 | * (Note that the default event loop needs to be created prior to calling this API) 103 | * 104 | * @return pointer to esp-netif instance 105 | */ 106 | esp_netif_t* esp_netif_create_default_wifi_nan(void); 107 | 108 | /** 109 | * @brief Destroys default WIFI netif created with esp_netif_create_default_wifi_...() API. 110 | * 111 | * @param[in] esp_netif object to detach from WiFi and destroy 112 | * 113 | * @note This API unregisters wifi handlers and detaches the created object from the wifi. 114 | * (this function is a no-operation if esp_netif is NULL) 115 | */ 116 | void esp_netif_destroy_default_wifi(void *esp_netif); 117 | 118 | /** 119 | * @brief Creates esp_netif WiFi object based on the custom configuration. 120 | * 121 | * @attention This API DOES NOT register default handlers! 122 | * 123 | * @param[in] wifi_if type of wifi interface 124 | * @param[in] esp_netif_config inherent esp-netif configuration pointer 125 | * 126 | * @return pointer to esp-netif instance 127 | */ 128 | esp_netif_t* esp_netif_create_wifi(wifi_interface_t wifi_if, const esp_netif_inherent_config_t *esp_netif_config); 129 | 130 | /** 131 | * @brief Creates default STA and AP network interfaces for esp-mesh. 132 | * 133 | * Both netifs are almost identical to the default station and softAP, but with 134 | * DHCP client and server disabled. Please note that the DHCP client is typically 135 | * enabled only if the device is promoted to a root node. 136 | * 137 | * Returns created interfaces which could be ignored setting parameters to NULL 138 | * if an application code does not need to save the interface instances 139 | * for further processing. 140 | * 141 | * @param[out] p_netif_sta pointer where the resultant STA interface is saved (if non NULL) 142 | * @param[out] p_netif_ap pointer where the resultant AP interface is saved (if non NULL) 143 | * 144 | * @return ESP_OK on success 145 | */ 146 | esp_err_t esp_netif_create_default_wifi_mesh_netifs(esp_netif_t **p_netif_sta, esp_netif_t **p_netif_ap); 147 | 148 | #ifdef __cplusplus 149 | } 150 | #endif 151 | 152 | #endif //_ESP_WIFI_DEFAULT_H 153 | -------------------------------------------------------------------------------- /blobs/headers/esp_smartconfig.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | 7 | #ifndef __ESP_SMARTCONFIG_H__ 8 | #define __ESP_SMARTCONFIG_H__ 9 | 10 | #include 11 | #include 12 | #include "esp_err.h" 13 | #include "esp_event_base.h" 14 | 15 | #ifdef __cplusplus 16 | extern "C" { 17 | #endif 18 | 19 | typedef enum { 20 | SC_TYPE_ESPTOUCH = 0, /**< protocol: ESPTouch */ 21 | SC_TYPE_AIRKISS, /**< protocol: AirKiss */ 22 | SC_TYPE_ESPTOUCH_AIRKISS, /**< protocol: ESPTouch and AirKiss */ 23 | SC_TYPE_ESPTOUCH_V2, /**< protocol: ESPTouch v2*/ 24 | } smartconfig_type_t; 25 | 26 | /** Smartconfig event declarations */ 27 | typedef enum { 28 | SC_EVENT_SCAN_DONE, /*!< Station smartconfig has finished to scan for APs */ 29 | SC_EVENT_FOUND_CHANNEL, /*!< Station smartconfig has found the channel of the target AP */ 30 | SC_EVENT_GOT_SSID_PSWD, /*!< Station smartconfig got the SSID and password */ 31 | SC_EVENT_SEND_ACK_DONE, /*!< Station smartconfig has sent ACK to cellphone */ 32 | } smartconfig_event_t; 33 | 34 | /** @brief smartconfig event base declaration */ 35 | ESP_EVENT_DECLARE_BASE(SC_EVENT); 36 | 37 | /** Argument structure for SC_EVENT_GOT_SSID_PSWD event */ 38 | typedef struct { 39 | uint8_t ssid[32]; /**< SSID of the AP. Null terminated string. */ 40 | uint8_t password[64]; /**< Password of the AP. Null terminated string. */ 41 | bool bssid_set; /**< whether set MAC address of target AP or not. */ 42 | uint8_t bssid[6]; /**< MAC address of target AP. */ 43 | smartconfig_type_t type; /**< Type of smartconfig(ESPTouch or AirKiss). */ 44 | uint8_t token; /**< Token from cellphone which is used to send ACK to cellphone. */ 45 | uint8_t cellphone_ip[4]; /**< IP address of cellphone. */ 46 | } smartconfig_event_got_ssid_pswd_t; 47 | 48 | /** Configure structure for esp_smartconfig_start */ 49 | typedef struct { 50 | bool enable_log; /**< Enable smartconfig logs. */ 51 | bool esp_touch_v2_enable_crypt; /**< Enable ESPTouch v2 crypt. */ 52 | char *esp_touch_v2_key; /**< ESPTouch v2 crypt key, len should be 16. */ 53 | } smartconfig_start_config_t; 54 | 55 | #define SMARTCONFIG_START_CONFIG_DEFAULT() { \ 56 | .enable_log = false, \ 57 | .esp_touch_v2_enable_crypt = false,\ 58 | .esp_touch_v2_key = NULL \ 59 | }; 60 | 61 | /** 62 | * @brief Get the version of SmartConfig. 63 | * 64 | * @return 65 | * - SmartConfig version const char. 66 | */ 67 | const char *esp_smartconfig_get_version(void); 68 | 69 | /** 70 | * @brief Start SmartConfig, config ESP device to connect AP. You need to broadcast information by phone APP. 71 | * Device sniffer special packets from the air that containing SSID and password of target AP. 72 | * 73 | * @attention 1. This API can be called in station or softAP-station mode. 74 | * @attention 2. Can not call esp_smartconfig_start twice before it finish, please call 75 | * esp_smartconfig_stop first. 76 | * 77 | * @param config pointer to smartconfig start configure structure 78 | * 79 | * @return 80 | * - ESP_OK: succeed 81 | * - others: fail 82 | */ 83 | esp_err_t esp_smartconfig_start(const smartconfig_start_config_t *config); 84 | 85 | /** 86 | * @brief Stop SmartConfig, free the buffer taken by esp_smartconfig_start. 87 | * 88 | * @attention Whether connect to AP succeed or not, this API should be called to free 89 | * memory taken by smartconfig_start. 90 | * 91 | * @return 92 | * - ESP_OK: succeed 93 | * - others: fail 94 | */ 95 | esp_err_t esp_smartconfig_stop(void); 96 | 97 | /** 98 | * @brief Set timeout of SmartConfig process. 99 | * 100 | * @attention Timing starts from SC_STATUS_FIND_CHANNEL status. SmartConfig will restart if timeout. 101 | * 102 | * @param time_s range 15s~255s, offset:45s. 103 | * 104 | * @return 105 | * - ESP_OK: succeed 106 | * - others: fail 107 | */ 108 | esp_err_t esp_esptouch_set_timeout(uint8_t time_s); 109 | 110 | /** 111 | * @brief Set protocol type of SmartConfig. 112 | * 113 | * @attention If users need to set the SmartConfig type, please set it before calling 114 | * esp_smartconfig_start. 115 | * 116 | * @param type Choose from the smartconfig_type_t. 117 | * 118 | * @return 119 | * - ESP_OK: succeed 120 | * - others: fail 121 | */ 122 | esp_err_t esp_smartconfig_set_type(smartconfig_type_t type); 123 | 124 | /** 125 | * @brief Set mode of SmartConfig. default normal mode. 126 | * 127 | * @attention 1. Please call it before API esp_smartconfig_start. 128 | * @attention 2. Fast mode have corresponding APP(phone). 129 | * @attention 3. Two mode is compatible. 130 | * 131 | * @param enable false-disable(default); true-enable; 132 | * 133 | * @return 134 | * - ESP_OK: succeed 135 | * - others: fail 136 | */ 137 | esp_err_t esp_smartconfig_fast_mode(bool enable); 138 | 139 | /** 140 | * @brief Get reserved data of ESPTouch v2. 141 | * 142 | * @param rvd_data reserved data 143 | * @param len length of reserved data 144 | * 145 | * @return 146 | * - ESP_OK: succeed 147 | * - others: fail 148 | */ 149 | esp_err_t esp_smartconfig_get_rvd_data(uint8_t *rvd_data, uint8_t len); 150 | 151 | #ifdef __cplusplus 152 | } 153 | #endif 154 | 155 | #endif 156 | -------------------------------------------------------------------------------- /blobs/include/esp_etm.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | #pragma once 7 | 8 | #include 9 | #include 10 | #include "esp_err.h" 11 | 12 | #ifdef __cplusplus 13 | extern "C" { 14 | #endif 15 | 16 | /** 17 | * @brief ETM channel handle 18 | */ 19 | typedef struct esp_etm_channel_t *esp_etm_channel_handle_t; 20 | 21 | /** 22 | * @brief ETM event handle 23 | */ 24 | typedef struct esp_etm_event_t *esp_etm_event_handle_t; 25 | 26 | /** 27 | * @brief ETM task handle 28 | */ 29 | typedef struct esp_etm_task_t *esp_etm_task_handle_t; 30 | 31 | /** 32 | * @brief ETM channel configuration 33 | */ 34 | typedef struct { 35 | 36 | } esp_etm_channel_config_t; 37 | 38 | /** 39 | * @brief Allocate an ETM channel 40 | * 41 | * @note The channel can later be freed by `esp_etm_del_channel` 42 | * 43 | * @param[in] config ETM channel configuration 44 | * @param[out] ret_chan Returned ETM channel handle 45 | * @return 46 | * - ESP_OK: Allocate ETM channel successfully 47 | * - ESP_ERR_INVALID_ARG: Allocate ETM channel failed because of invalid argument 48 | * - ESP_ERR_NO_MEM: Allocate ETM channel failed because of out of memory 49 | * - ESP_ERR_NOT_FOUND: Allocate ETM channel failed because all channels are used up and no more free one 50 | * - ESP_FAIL: Allocate ETM channel failed because of other reasons 51 | */ 52 | esp_err_t esp_etm_new_channel(const esp_etm_channel_config_t *config, esp_etm_channel_handle_t *ret_chan); 53 | 54 | /** 55 | * @brief Delete an ETM channel 56 | * 57 | * @param[in] chan ETM channel handle that created by `esp_etm_new_channel` 58 | * @return 59 | * - ESP_OK: Delete ETM channel successfully 60 | * - ESP_ERR_INVALID_ARG: Delete ETM channel failed because of invalid argument 61 | * - ESP_FAIL: Delete ETM channel failed because of other reasons 62 | */ 63 | esp_err_t esp_etm_del_channel(esp_etm_channel_handle_t chan); 64 | 65 | /** 66 | * @brief Enable ETM channel 67 | * 68 | * @note This function will transit the channel state from init to enable. 69 | * 70 | * @param[in] chan ETM channel handle that created by `esp_etm_new_channel` 71 | * @return 72 | * - ESP_OK: Enable ETM channel successfully 73 | * - ESP_ERR_INVALID_ARG: Enable ETM channel failed because of invalid argument 74 | * - ESP_ERR_INVALID_STATE: Enable ETM channel failed because the channel has been enabled already 75 | * - ESP_FAIL: Enable ETM channel failed because of other reasons 76 | */ 77 | esp_err_t esp_etm_channel_enable(esp_etm_channel_handle_t chan); 78 | 79 | /** 80 | * @brief Disable ETM channel 81 | * 82 | * @note This function will transit the channel state from enable to init. 83 | * 84 | * @param[in] chan ETM channel handle that created by `esp_etm_new_channel` 85 | * @return 86 | * - ESP_OK: Disable ETM channel successfully 87 | * - ESP_ERR_INVALID_ARG: Disable ETM channel failed because of invalid argument 88 | * - ESP_ERR_INVALID_STATE: Disable ETM channel failed because the channel is not enabled yet 89 | * - ESP_FAIL: Disable ETM channel failed because of other reasons 90 | */ 91 | esp_err_t esp_etm_channel_disable(esp_etm_channel_handle_t chan); 92 | 93 | /** 94 | * @brief Connect an ETM event to an ETM task via a previously allocated ETM channel 95 | * 96 | * @note Setting the ETM event/task handle to NULL means to disconnect the channel from any event/task 97 | * 98 | * @param[in] chan ETM channel handle that created by `esp_etm_new_channel` 99 | * @param[in] event ETM event handle obtained from a driver/peripheral, e.g. `xxx_new_etm_event` 100 | * @param[in] task ETM task handle obtained from a driver/peripheral, e.g. `xxx_new_etm_task` 101 | * @return 102 | * - ESP_OK: Connect ETM event and task to the channel successfully 103 | * - ESP_ERR_INVALID_ARG: Connect ETM event and task to the channel failed because of invalid argument 104 | * - ESP_FAIL: Connect ETM event and task to the channel failed because of other reasons 105 | */ 106 | esp_err_t esp_etm_channel_connect(esp_etm_channel_handle_t chan, esp_etm_event_handle_t event, esp_etm_task_handle_t task); 107 | 108 | /** 109 | * @brief Delete ETM event 110 | * 111 | * @note Although the ETM event comes from various peripherals, we provide the same user API to delete the event handle seamlessly. 112 | * 113 | * @param[in] event ETM event handle obtained from a driver/peripheral, e.g. `xxx_new_etm_event` 114 | * @return 115 | * - ESP_OK: Delete ETM event successfully 116 | * - ESP_ERR_INVALID_ARG: Delete ETM event failed because of invalid argument 117 | * - ESP_FAIL: Delete ETM event failed because of other reasons 118 | */ 119 | esp_err_t esp_etm_del_event(esp_etm_event_handle_t event); 120 | 121 | /** 122 | * @brief Delete ETM task 123 | * 124 | * @note Although the ETM task comes from various peripherals, we provide the same user API to delete the task handle seamlessly. 125 | * 126 | * @param[in] task ETM task handle obtained from a driver/peripheral, e.g. `xxx_new_etm_task` 127 | * @return 128 | * - ESP_OK: Delete ETM task successfully 129 | * - ESP_ERR_INVALID_ARG: Delete ETM task failed because of invalid argument 130 | * - ESP_FAIL: Delete ETM task failed because of other reasons 131 | */ 132 | esp_err_t esp_etm_del_task(esp_etm_task_handle_t task); 133 | 134 | /** 135 | * @brief Dump ETM channel usages to the given IO stream 136 | * 137 | * @param[in] out_stream IO stream (e.g. stdout) 138 | * @return 139 | * - ESP_OK: Dump ETM channel usages successfully 140 | * - ESP_ERR_INVALID_ARG: Dump ETM channel usages failed because of invalid argument 141 | * - ESP_FAIL: Dump ETM channel usages failed because of other reasons 142 | */ 143 | esp_err_t esp_etm_dump(FILE *out_stream); 144 | 145 | #ifdef __cplusplus 146 | } 147 | #endif 148 | -------------------------------------------------------------------------------- /blobs/headers/esp_err.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | 7 | #pragma once 8 | 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include "esp_compiler.h" 14 | 15 | #ifdef __cplusplus 16 | extern "C" { 17 | #endif 18 | 19 | typedef int esp_err_t; 20 | 21 | /* Definitions for error constants. */ 22 | #define ESP_OK 0 /*!< esp_err_t value indicating success (no error) */ 23 | #define ESP_FAIL -1 /*!< Generic esp_err_t code indicating failure */ 24 | 25 | #define ESP_ERR_NO_MEM 0x101 /*!< Out of memory */ 26 | #define ESP_ERR_INVALID_ARG 0x102 /*!< Invalid argument */ 27 | #define ESP_ERR_INVALID_STATE 0x103 /*!< Invalid state */ 28 | #define ESP_ERR_INVALID_SIZE 0x104 /*!< Invalid size */ 29 | #define ESP_ERR_NOT_FOUND 0x105 /*!< Requested resource not found */ 30 | #define ESP_ERR_NOT_SUPPORTED 0x106 /*!< Operation or feature not supported */ 31 | #define ESP_ERR_TIMEOUT 0x107 /*!< Operation timed out */ 32 | #define ESP_ERR_INVALID_RESPONSE 0x108 /*!< Received response was invalid */ 33 | #define ESP_ERR_INVALID_CRC 0x109 /*!< CRC or checksum was invalid */ 34 | #define ESP_ERR_INVALID_VERSION 0x10A /*!< Version was invalid */ 35 | #define ESP_ERR_INVALID_MAC 0x10B /*!< MAC address was invalid */ 36 | #define ESP_ERR_NOT_FINISHED 0x10C /*!< There are items remained to retrieve */ 37 | #define ESP_ERR_ROC_IN_PROGRESS 0x10E /*!< ROC Operation is in progress */ 38 | 39 | 40 | #define ESP_ERR_WIFI_BASE 0x3000 /*!< Starting number of WiFi error codes */ 41 | #define ESP_ERR_MESH_BASE 0x4000 /*!< Starting number of MESH error codes */ 42 | #define ESP_ERR_FLASH_BASE 0x6000 /*!< Starting number of flash error codes */ 43 | #define ESP_ERR_HW_CRYPTO_BASE 0xc000 /*!< Starting number of HW cryptography module error codes */ 44 | #define ESP_ERR_MEMPROT_BASE 0xd000 /*!< Starting number of Memory Protection API error codes */ 45 | 46 | /** 47 | * @brief Returns string for esp_err_t error codes 48 | * 49 | * This function finds the error code in a pre-generated lookup-table and 50 | * returns its string representation. 51 | * 52 | * The function is generated by the Python script 53 | * tools/gen_esp_err_to_name.py which should be run each time an esp_err_t 54 | * error is modified, created or removed from the IDF project. 55 | * 56 | * @param code esp_err_t error code 57 | * @return string error message 58 | */ 59 | const char *esp_err_to_name(esp_err_t code); 60 | 61 | /** 62 | * @brief Returns string for esp_err_t and system error codes 63 | * 64 | * This function finds the error code in a pre-generated lookup-table of 65 | * esp_err_t errors and returns its string representation. If the error code 66 | * is not found then it is attempted to be found among system errors. 67 | * 68 | * The function is generated by the Python script 69 | * tools/gen_esp_err_to_name.py which should be run each time an esp_err_t 70 | * error is modified, created or removed from the IDF project. 71 | * 72 | * @param code esp_err_t error code 73 | * @param[out] buf buffer where the error message should be written 74 | * @param buflen Size of buffer buf. At most buflen bytes are written into the buf buffer (including the terminating null byte). 75 | * @return buf containing the string error message 76 | */ 77 | const char *esp_err_to_name_r(esp_err_t code, char *buf, size_t buflen); 78 | 79 | /** @cond */ 80 | void _esp_error_check_failed(esp_err_t rc, const char *file, int line, const char *function, const char *expression) __attribute__((__noreturn__)); 81 | 82 | void _esp_error_check_failed_without_abort(esp_err_t rc, const char *file, int line, const char *function, const char *expression); 83 | 84 | #ifndef __ASSERT_FUNC 85 | /* This won't happen on IDF, which defines __ASSERT_FUNC in assert.h, but it does happen when building on the host which 86 | uses /usr/include/assert.h or equivalent. 87 | */ 88 | #ifdef __ASSERT_FUNCTION 89 | #define __ASSERT_FUNC __ASSERT_FUNCTION /* used in glibc assert.h */ 90 | #else 91 | #define __ASSERT_FUNC "??" 92 | #endif 93 | #endif 94 | /** @endcond */ 95 | 96 | /** 97 | * Macro which can be used to check the error code, 98 | * and terminate the program in case the code is not ESP_OK. 99 | * Prints the error code, error location, and the failed statement to serial output. 100 | * 101 | * Disabled if assertions are disabled. 102 | */ 103 | #ifdef NDEBUG 104 | #define ESP_ERROR_CHECK(x) do { \ 105 | esp_err_t err_rc_ = (x); \ 106 | (void) sizeof(err_rc_); \ 107 | } while(0) 108 | #elif defined(CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_SILENT) 109 | #define ESP_ERROR_CHECK(x) do { \ 110 | esp_err_t err_rc_ = (x); \ 111 | if (unlikely(err_rc_ != ESP_OK)) { \ 112 | abort(); \ 113 | } \ 114 | } while(0) 115 | #else 116 | #define ESP_ERROR_CHECK(x) do { \ 117 | esp_err_t err_rc_ = (x); \ 118 | if (unlikely(err_rc_ != ESP_OK)) { \ 119 | _esp_error_check_failed(err_rc_, __FILE__, __LINE__, \ 120 | __ASSERT_FUNC, #x); \ 121 | } \ 122 | } while(0) 123 | #endif 124 | 125 | /** 126 | * Macro which can be used to check the error code. Prints the error code, error location, and the failed statement to 127 | * serial output. 128 | * In comparison with ESP_ERROR_CHECK(), this prints the same error message but isn't terminating the program. 129 | */ 130 | #if defined NDEBUG || defined CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_SILENT 131 | #define ESP_ERROR_CHECK_WITHOUT_ABORT(x) ({ \ 132 | esp_err_t err_rc_ = (x); \ 133 | err_rc_; \ 134 | }) 135 | #else 136 | #define ESP_ERROR_CHECK_WITHOUT_ABORT(x) ({ \ 137 | esp_err_t err_rc_ = (x); \ 138 | if (unlikely(err_rc_ != ESP_OK)) { \ 139 | _esp_error_check_failed_without_abort(err_rc_, __FILE__, __LINE__, \ 140 | __ASSERT_FUNC, #x); \ 141 | } \ 142 | err_rc_; \ 143 | }) 144 | #endif //NDEBUG 145 | 146 | #ifdef __cplusplus 147 | } 148 | #endif 149 | -------------------------------------------------------------------------------- /blobs/include/esp_wifi_he.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | 7 | #pragma once 8 | 9 | #include 10 | #include 11 | #include "esp_err.h" 12 | #include "esp_wifi_he_types.h" 13 | 14 | #ifdef __cplusplus 15 | extern "C" { 16 | #endif 17 | 18 | 19 | /** 20 | * @brief Set up an individual TWT agreement (NegotiationType=0) or change TWT parameters of the existing TWT agreement 21 | * - TWT Wake Interval = TWT Wake Interval Mantissa * (2 ^ TWT Wake Interval Exponent), unit: us 22 | * - e.g. TWT Wake Interval Mantissa = 512, TWT Wake Interval Exponent = 12, then TWT Wake Interval is 2097.152 ms 23 | * Nominal Minimum Wake Duration = 255, then TWT Wake Duration is 65.28 ms 24 | * 25 | * @attention Support at most 4 TWT agreements, otherwise ESP_ERR_WIFI_TWT_FULL will be returned. 26 | * Support sleep time up to (1 << 35) us. 27 | * 28 | * @param[in] setup_cmd Indicates the type of TWT command 29 | * @param[in] trigger true: a trigger-enabled TWT, false: a non-trigger-enabled TWT 30 | * @param[in] flow_type 0: an announced TWT, 1: an unannounced TWT 31 | * @param[in] min_wake_dura Nominal Minimum Wake Duration, indicates the minimum amount of time, in unit of 256 us, that the TWT requesting STA expects that it needs to be awake. The value range is [1, 255]. 32 | * @param[in] wake_invl_expn TWT Wake Interval Exponent. The value range is [0, 31]. 33 | * @param[in] wake_invl_mant TWT Wake Interval Mantissa. The value range is [1, 65535]. 34 | * @param[in/out] flow_id When set up an individual TWT agreement, the flow id will be assigned by AP after a successful agreement setup. 35 | * flow_id is allowed to be NULL. flow_id could be specified to a value in the range of [0, 7], but it might be changed by AP in the response. 36 | * When change TWT parameters of the existing TWT agreement, flow_id should be an existing one. The value range is [0, 7]. 37 | * 38 | * @return 39 | * - ESP_OK: succeed 40 | * - ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init 41 | * - ESP_ERR_WIFI_NOT_STARTED: WiFi is not started by esp_wifi_start 42 | * - ESP_ERR_WIFI_CONN: WiFi internal error, station or soft-AP control block wrong 43 | * - ESP_ERR_WIFI_NOT_CONNECT: The station is in disconnect status 44 | * - ESP_ERR_WIFI_TWT_FULL: no available flow id 45 | * - ESP_ERR_INVALID_ARG: invalid argument 46 | */ 47 | esp_err_t esp_wifi_sta_itwt_setup(wifi_twt_setup_cmds_t setup_cmd, bool trigger, int flow_type, int min_wake_dura, int wake_invl_expn, int wake_invl_mant, int *flow_id); 48 | 49 | /** 50 | * @brief Tear down individual TWT agreements 51 | * 52 | * @param[in] flow_id The value range is [0, 8]. 8 indicates tear down all individual TWT agreements. 53 | * 54 | * @return 55 | * - ESP_OK: succeed 56 | * - ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init 57 | * - ESP_ERR_WIFI_NOT_STARTED: WiFi is not started by esp_wifi_start 58 | * - ESP_ERR_WIFI_CONN: WiFi internal error, station or soft-AP control block wrong 59 | * - ESP_ERR_WIFI_NOT_CONNECT: The station is in disconnect status 60 | * - ESP_ERR_INVALID_ARG: invalid argument 61 | */ 62 | esp_err_t esp_wifi_sta_itwt_teardown(int flow_id); 63 | 64 | /** 65 | * @brief Send a TWT Information frame to AP for suspending/resuming established iTWT agreements. 66 | * 67 | * @param[in] flow_id The value range is [0, 8]. 8 indicates suspend all individual TWT agreements 68 | * @param[in] suspend_time_ms If the value is 0, indicates the specified flow_id or all established agreements will be suspended until resume by users. 69 | * If the value is greater than 0, indicates the specified flow_id or all established agreements will be suspended until suspend_time_ms timeout, unit: ms. 70 | * 71 | * @return 72 | * - ESP_OK: succeed 73 | * - ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init 74 | * - ESP_ERR_WIFI_NOT_STARTED: WiFi is not started by esp_wifi_start 75 | * - ESP_ERR_WIFI_CONN: WiFi internal error, station or soft-AP control block wrong 76 | * - ESP_ERR_WIFI_NOT_ASSOC: WiFi is not associated 77 | * - ESP_ERR_INVALID_ARG: invalid argument 78 | */ 79 | esp_err_t esp_wifi_sta_itwt_suspend(int flow_id, int suspend_time_ms); 80 | 81 | /** 82 | * @brief Get flow id status 83 | * 84 | * @param[in] flow_id_bitmap Flow id status bitmap with 8 bit. Each bit represents that whether the corresponding flow id is setup. 85 | * 1: setup, 0: not setup. 86 | * 87 | * @return 88 | * - ESP_OK: succeed 89 | * - ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init 90 | * - ESP_ERR_WIFI_NOT_STARTED: WiFi is not started by esp_wifi_start 91 | * - ESP_ERR_WIFI_CONN: WiFi internal error, station or soft-AP control block wrong 92 | * - ESP_ERR_WIFI_NOT_CONNECT: The station is in disconnect status 93 | * - ESP_ERR_INVALID_ARG: invalid argument 94 | */ 95 | esp_err_t esp_wifi_sta_itwt_get_flow_id_status(int *flow_id_bitmap); 96 | 97 | /** 98 | * @brief Send probe to update TSF time 99 | * 100 | * @attention In bad network, timeout_ms is variable with the network 101 | * 102 | * @param[in] timeout_ms The estimated time includes sending probe request and receiving probe response, unit: ms. 103 | * 104 | * @return 105 | * - ESP_OK: succeed 106 | * - ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init 107 | * - ESP_ERR_WIFI_NOT_STARTED: WiFi is not started by esp_wifi_start 108 | * - ESP_ERR_WIFI_CONN: WiFi internal error, station or soft-AP control block wrong 109 | * - ESP_ERR_WIFI_NOT_ASSOC: WiFi is not associated 110 | */ 111 | esp_err_t esp_wifi_sta_itwt_send_probe_req(int timeout_ms); 112 | 113 | /** 114 | * @brief Set time offset with TBTT of target wake time field in itwt setup request frame. 115 | * 116 | * @param[in] offset_us Offset with TBTT of target wake time field in itwt setup request frame, range is [0, 102400], unit microseconds. 117 | * 118 | * @return 119 | * - ESP_OK: succeed 120 | * - ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init 121 | * - ESP_ERR_WIFI_NOT_STARTED: WiFi is not started by esp_wifi_start 122 | * - ESP_ERR_WIFI_CONN: WiFi internal error, station or soft-AP control block wrong 123 | * - ESP_ERR_WIFI_NOT_ASSOC: WiFi is not associated 124 | * - ESP_ERR_INVALID_ARG: invalid argument 125 | */ 126 | esp_err_t esp_wifi_sta_itwt_set_target_wake_time_offset(int offset_us); 127 | 128 | /** 129 | * @brief Enable the reception statistics. 130 | * 131 | * @param[in] rx_stats indicate whether enable the reception statistics for HT, HE SU, HE ER SU and legacy 132 | * @param[in] rx_mu_stats indicate whether enable the reception statistics for DL MU-MIMO and DL OFDMA 133 | * 134 | * @return 135 | * - ESP_OK: succeed 136 | * - ESP_ERR_NO_MEM: out of memory 137 | */ 138 | esp_err_t esp_wifi_enable_rx_statistics(bool rx_stats, bool rx_mu_stats); 139 | 140 | /** 141 | * @brief Enable the transmission statistics. 142 | * 143 | * @param[in] aci access category of the transmission 144 | * @param[in] tx_stats indicate whether enable the transmission statistics 145 | * 146 | * @return 147 | * - ESP_OK: succeed 148 | * - ESP_ERR_NO_MEM: out of memory 149 | */ 150 | esp_err_t esp_wifi_enable_tx_statistics(esp_wifi_aci_t aci, bool tx_stats); 151 | 152 | 153 | #ifdef __cplusplus 154 | } 155 | #endif 156 | -------------------------------------------------------------------------------- /blobs/headers/esp32c2/esp_bt_cfg.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | 7 | #ifndef __ESP_BT_CFG_H__ 8 | #define __ESP_BT_CFG_H__ 9 | 10 | #include 11 | #include 12 | #include "esp_err.h" 13 | 14 | #ifdef __cplusplus 15 | extern "C" { 16 | #endif 17 | 18 | #if CONFIG_BT_NIMBLE_ENABLED 19 | #include "syscfg/syscfg.h" 20 | #endif 21 | 22 | #define NIMBLE_LL_STACK_SIZE CONFIG_BT_LE_CONTROLLER_TASK_STACK_SIZE 23 | 24 | #if CONFIG_BT_NIMBLE_ENABLED 25 | 26 | #if CONFIG_BT_NIMBLE_LL_CFG_FEAT_LE_CODED_PHY 27 | #define BLE_LL_SCAN_PHY_NUMBER_N (2) 28 | #else 29 | #define BLE_LL_SCAN_PHY_NUMBER_N (1) 30 | #endif 31 | 32 | #define DEFAULT_BT_LE_MAX_PERIODIC_ADVERTISER_LIST MYNEWT_VAL(BLE_MAX_PERIODIC_ADVERTISER_LIST) 33 | #define DEFAULT_BT_LE_MAX_PERIODIC_SYNCS MYNEWT_VAL(BLE_MAX_PERIODIC_SYNCS) 34 | #define DEFAULT_BT_LE_MAX_CONNECTIONS MYNEWT_VAL(BLE_MAX_CONNECTIONS) 35 | #define DEFAULT_BT_LE_ACL_BUF_SIZE MYNEWT_VAL(BLE_ACL_BUF_SIZE) 36 | #define DEFAULT_BT_LE_ACL_BUF_COUNT MYNEWT_VAL(BLE_ACL_BUF_COUNT) 37 | #define DEFAULT_BT_LE_HCI_EVT_BUF_SIZE MYNEWT_VAL(BLE_HCI_EVT_BUF_SIZE) 38 | #define DEFAULT_BT_LE_EXT_ADV_MAX_SIZE MYNEWT_VAL(BLE_EXT_ADV_MAX_SIZE) 39 | #define DEFAULT_BT_LE_MAX_EXT_ADV_INSTANCES MYNEWT_VAL(BLE_MULTI_ADV_INSTANCES) 40 | #define DEFAULT_BT_NIMBLE_WHITELIST_SIZE MYNEWT_VAL(BLE_LL_WHITELIST_SIZE) 41 | #define DEFAULT_BT_LE_HCI_EVT_HI_BUF_COUNT MYNEWT_VAL(BLE_HCI_EVT_HI_BUF_COUNT) 42 | #define DEFAULT_BT_LE_HCI_EVT_LO_BUF_COUNT MYNEWT_VAL(BLE_HCI_EVT_LO_BUF_COUNT) 43 | #define DEFAULT_BT_LE_COEX_PHY_CODED_TX_RX_TLIM_EFF CONFIG_BT_NIMBLE_COEX_PHY_CODED_TX_RX_TLIM_EFF 44 | 45 | #else 46 | 47 | #if CONFIG_BT_LE_LL_CFG_FEAT_LE_CODED_PHY 48 | #define BLE_LL_SCAN_PHY_NUMBER_N (2) 49 | #else 50 | #define BLE_LL_SCAN_PHY_NUMBER_N (1) 51 | #endif 52 | 53 | #if defined(CONFIG_BT_LE_MAX_PERIODIC_ADVERTISER_LIST) 54 | #define DEFAULT_BT_LE_MAX_PERIODIC_ADVERTISER_LIST (CONFIG_BT_LE_MAX_PERIODIC_ADVERTISER_LIST) 55 | #else 56 | #define DEFAULT_BT_LE_MAX_PERIODIC_ADVERTISER_LIST (5) 57 | #endif 58 | 59 | #if defined(CONFIG_BT_LE_MAX_PERIODIC_SYNCS) 60 | #define DEFAULT_BT_LE_MAX_PERIODIC_SYNCS (CONFIG_BT_LE_MAX_PERIODIC_SYNCS) 61 | #else 62 | #define DEFAULT_BT_LE_MAX_PERIODIC_SYNCS (1) 63 | #endif 64 | 65 | #if defined(CONFIG_BT_LE_MAX_CONNECTIONS) 66 | #define DEFAULT_BT_LE_MAX_CONNECTIONS (CONFIG_BT_LE_MAX_CONNECTIONS) 67 | #else 68 | #define DEFAULT_BT_LE_MAX_CONNECTIONS (2) 69 | #endif 70 | 71 | #if defined(CONFIG_BT_LE_ACL_BUF_SIZE) 72 | #define DEFAULT_BT_LE_ACL_BUF_SIZE (CONFIG_BT_LE_ACL_BUF_SIZE) 73 | #else 74 | #define DEFAULT_BT_LE_ACL_BUF_SIZE (255) 75 | #endif 76 | 77 | #if defined(CONFIG_BT_LE_ACL_BUF_COUNT) 78 | #define DEFAULT_BT_LE_ACL_BUF_COUNT (CONFIG_BT_LE_ACL_BUF_COUNT) 79 | #else 80 | #define DEFAULT_BT_LE_ACL_BUF_COUNT (24) 81 | #endif 82 | 83 | #if defined(CONFIG_BT_LE_HCI_EVT_BUF_SIZE) 84 | #define DEFAULT_BT_LE_HCI_EVT_BUF_SIZE (CONFIG_BT_LE_HCI_EVT_BUF_SIZE) 85 | #else 86 | #define DEFAULT_BT_LE_HCI_EVT_BUF_SIZE (70) 87 | #endif 88 | 89 | #if defined(CONFIG_BT_LE_EXT_ADV_MAX_SIZE) 90 | #define DEFAULT_BT_LE_EXT_ADV_MAX_SIZE (CONFIG_BT_LE_EXT_ADV_MAX_SIZE) 91 | #else 92 | #define DEFAULT_BT_LE_EXT_ADV_MAX_SIZE (31) 93 | #endif 94 | 95 | #if defined(CONFIG_BT_LE_MAX_EXT_ADV_INSTANCES) 96 | #define DEFAULT_BT_LE_MAX_EXT_ADV_INSTANCES (CONFIG_BT_LE_MAX_EXT_ADV_INSTANCES) 97 | #else 98 | #define DEFAULT_BT_LE_MAX_EXT_ADV_INSTANCES (1) 99 | #endif 100 | 101 | #if defined(CONFIG_BT_LE_WHITELIST_SIZE) 102 | #define DEFAULT_BT_NIMBLE_WHITELIST_SIZE (CONFIG_BT_LE_WHITELIST_SIZE) 103 | #else 104 | #define DEFAULT_BT_NIMBLE_WHITELIST_SIZE (12) 105 | #endif 106 | 107 | #if defined(CONFIG_BT_LE_HCI_EVT_HI_BUF_COUNT) 108 | #define DEFAULT_BT_LE_HCI_EVT_HI_BUF_COUNT (CONFIG_BT_LE_HCI_EVT_HI_BUF_COUNT) 109 | #else 110 | #define DEFAULT_BT_LE_HCI_EVT_HI_BUF_COUNT (30) 111 | #endif 112 | 113 | #if defined(CONFIG_BT_LE_HCI_EVT_LO_BUF_COUNT) 114 | #define DEFAULT_BT_LE_HCI_EVT_LO_BUF_COUNT (CONFIG_BT_LE_HCI_EVT_LO_BUF_COUNT) 115 | #else 116 | #define DEFAULT_BT_LE_HCI_EVT_LO_BUF_COUNT (8) 117 | #endif 118 | 119 | #define DEFAULT_BT_LE_COEX_PHY_CODED_TX_RX_TLIM_EFF CONFIG_BT_LE_COEX_PHY_CODED_TX_RX_TLIM_EFF 120 | 121 | #endif 122 | 123 | 124 | 125 | #ifdef CONFIG_BT_LE_HCI_INTERFACE_USE_UART 126 | #define HCI_UART_EN CONFIG_BT_LE_HCI_INTERFACE_USE_UART 127 | #else 128 | #define HCI_UART_EN 0 // hci ram mode 129 | #endif 130 | 131 | #ifdef CONFIG_BT_LE_SLEEP_ENABLE 132 | #define NIMBLE_SLEEP_ENABLE CONFIG_BT_LE_SLEEP_ENABLE 133 | #else 134 | #define NIMBLE_SLEEP_ENABLE 0 135 | #endif 136 | 137 | 138 | #ifdef CONFIG_BT_LE_TX_CCA_ENABLED 139 | #define DEFAULT_BT_LE_TX_CCA_ENABLED (CONFIG_BT_LE_TX_CCA_ENABLED) 140 | #else 141 | #define DEFAULT_BT_LE_TX_CCA_ENABLED (0) 142 | #endif 143 | 144 | #ifdef CONFIG_BT_LE_CCA_RSSI_THRESH 145 | #define DEFAULT_BT_LE_CCA_RSSI_THRESH (CONFIG_BT_LE_CCA_RSSI_THRESH) 146 | #else 147 | #define DEFAULT_BT_LE_CCA_RSSI_THRESH (50) 148 | #endif 149 | 150 | #define DEFAULT_BT_LE_SCAN_RSP_DATA_MAX_LEN_N DEFAULT_BT_LE_EXT_ADV_MAX_SIZE 151 | 152 | 153 | #if HCI_UART_EN 154 | #define DEFAULT_BT_LE_HCI_UART_TX_PIN (CONFIG_BT_LE_HCI_UART_TX_PIN) 155 | #define DEFAULT_BT_LE_HCI_UART_RX_PIN (CONFIG_BT_LE_HCI_UART_RX_PIN) 156 | #define DEFAULT_BT_LE_HCI_UART_PORT (CONFIG_BT_LE_HCI_UART_PORT) 157 | #define DEFAULT_BT_LE_HCI_UART_BAUD (CONFIG_BT_LE_HCI_UART_BAUD) 158 | #define DEFAULT_BT_LE_HCI_UART_DATA_BITS (UART_DATA_8_BITS) 159 | #define DEFAULT_BT_LE_HCI_UART_STOP_BITS (UART_STOP_BITS_1) 160 | #define DEFAULT_BT_LE_HCI_UART_PARITY (0) 161 | #define DEFAULT_BT_LE_HCI_UART_TASK_STACK_SIZE (CONFIG_BT_LE_HCI_UART_TASK_STACK_SIZE) 162 | #define DEFAULT_BT_LE_HCI_UART_FLOW_CTRL (0) 163 | #else 164 | #define DEFAULT_BT_LE_HCI_UART_TX_PIN (0) 165 | #define DEFAULT_BT_LE_HCI_UART_RX_PIN (0) 166 | #define DEFAULT_BT_LE_HCI_UART_PORT (0) 167 | #define DEFAULT_BT_LE_HCI_UART_BAUD (0) 168 | #define DEFAULT_BT_LE_HCI_UART_DATA_BITS (0) 169 | #define DEFAULT_BT_LE_HCI_UART_STOP_BITS (0) 170 | #define DEFAULT_BT_LE_HCI_UART_PARITY (0) 171 | #define DEFAULT_BT_LE_HCI_UART_TASK_STACK_SIZE (0) 172 | #define DEFAULT_BT_LE_HCI_UART_FLOW_CTRL (0) 173 | #endif 174 | 175 | /* Unchanged configuration */ 176 | 177 | #define BLE_LL_CTRL_PROC_TIMEOUT_MS_N (40000) /* ms */ 178 | 179 | #define BLE_LL_CFG_NUM_HCI_CMD_PKTS_N (1) 180 | 181 | #define BLE_LL_SCHED_ADV_MAX_USECS_N (852) 182 | 183 | #define BLE_LL_SCHED_DIRECT_ADV_MAX_USECS_N (502) 184 | 185 | #define BLE_LL_SCHED_MAX_ADV_PDU_USECS_N (376) 186 | 187 | #define BLE_LL_SUB_VERS_NR_N (0x0000) 188 | 189 | #define BLE_LL_JITTER_USECS_N (16) 190 | 191 | #define BLE_PHY_MAX_PWR_DBM_N (10) 192 | 193 | #define BLE_LL_CONN_DEF_AUTH_PYLD_TMO_N (3000) 194 | 195 | #ifdef CONFIG_XTAL_FREQ_26 196 | #define RTC_FREQ_N (40000) /* in Hz */ 197 | #else 198 | #define RTC_FREQ_N (32000) /* in Hz */ 199 | #endif // CONFIG_XTAL_FREQ_26 200 | 201 | #define BLE_LL_TX_PWR_DBM_N (9) 202 | 203 | 204 | #define RUN_BQB_TEST (0) 205 | #define RUN_QA_TEST (0) 206 | #define NIMBLE_DISABLE_SCAN_BACKOFF (0) 207 | 208 | 209 | #ifdef __cplusplus 210 | } 211 | #endif 212 | 213 | #endif /* __ESP_BT_CFG_H__ */ 214 | -------------------------------------------------------------------------------- /blobs/headers/esp_private/wifi_os_adapter.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2018-2021 Espressif Systems (Shanghai) CO LTD 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | 7 | #ifndef ESP_WIFI_OS_ADAPTER_H_ 8 | #define ESP_WIFI_OS_ADAPTER_H_ 9 | 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include "sdkconfig.h" 15 | 16 | #ifdef __cplusplus 17 | extern "C" { 18 | #endif 19 | 20 | #define ESP_WIFI_OS_ADAPTER_VERSION 0x00000008 21 | #define ESP_WIFI_OS_ADAPTER_MAGIC 0xDEADBEAF 22 | 23 | #define OSI_FUNCS_TIME_BLOCKING 0xffffffff 24 | 25 | #define OSI_QUEUE_SEND_FRONT 0 26 | #define OSI_QUEUE_SEND_BACK 1 27 | #define OSI_QUEUE_SEND_OVERWRITE 2 28 | 29 | typedef struct { 30 | int32_t _version; 31 | bool (* _env_is_chip)(void); 32 | void (*_set_intr)(int32_t cpu_no, uint32_t intr_source, uint32_t intr_num, int32_t intr_prio); 33 | void (*_clear_intr)(uint32_t intr_source, uint32_t intr_num); 34 | void (*_set_isr)(int32_t n, void *f, void *arg); 35 | void (*_ints_on)(uint32_t mask); 36 | void (*_ints_off)(uint32_t mask); 37 | bool (* _is_from_isr)(void); 38 | void *(* _spin_lock_create)(void); 39 | void (* _spin_lock_delete)(void *lock); 40 | uint32_t (*_wifi_int_disable)(void *wifi_int_mux); 41 | void (*_wifi_int_restore)(void *wifi_int_mux, uint32_t tmp); 42 | void (*_task_yield_from_isr)(void); 43 | void *(*_semphr_create)(uint32_t max, uint32_t init); 44 | void (*_semphr_delete)(void *semphr); 45 | int32_t (*_semphr_take)(void *semphr, uint32_t block_time_tick); 46 | int32_t (*_semphr_give)(void *semphr); 47 | void *(*_wifi_thread_semphr_get)(void); 48 | void *(*_mutex_create)(void); 49 | void *(*_recursive_mutex_create)(void); 50 | void (*_mutex_delete)(void *mutex); 51 | int32_t (*_mutex_lock)(void *mutex); 52 | int32_t (*_mutex_unlock)(void *mutex); 53 | void *(* _queue_create)(uint32_t queue_len, uint32_t item_size); 54 | void (* _queue_delete)(void *queue); 55 | int32_t (* _queue_send)(void *queue, void *item, uint32_t block_time_tick); 56 | int32_t (* _queue_send_from_isr)(void *queue, void *item, void *hptw); 57 | int32_t (* _queue_send_to_back)(void *queue, void *item, uint32_t block_time_tick); 58 | int32_t (* _queue_send_to_front)(void *queue, void *item, uint32_t block_time_tick); 59 | int32_t (* _queue_recv)(void *queue, void *item, uint32_t block_time_tick); 60 | uint32_t (* _queue_msg_waiting)(void *queue); 61 | void *(* _event_group_create)(void); 62 | void (* _event_group_delete)(void *event); 63 | uint32_t (* _event_group_set_bits)(void *event, uint32_t bits); 64 | uint32_t (* _event_group_clear_bits)(void *event, uint32_t bits); 65 | uint32_t (* _event_group_wait_bits)(void *event, uint32_t bits_to_wait_for, int clear_on_exit, int wait_for_all_bits, uint32_t block_time_tick); 66 | int32_t (* _task_create_pinned_to_core)(void *task_func, const char *name, uint32_t stack_depth, void *param, uint32_t prio, void *task_handle, uint32_t core_id); 67 | int32_t (* _task_create)(void *task_func, const char *name, uint32_t stack_depth, void *param, uint32_t prio, void *task_handle); 68 | void (* _task_delete)(void *task_handle); 69 | void (* _task_delay)(uint32_t tick); 70 | int32_t (* _task_ms_to_tick)(uint32_t ms); 71 | void *(* _task_get_current_task)(void); 72 | int32_t (* _task_get_max_priority)(void); 73 | void *(* _malloc)(size_t size); 74 | void (* _free)(void *p); 75 | int32_t (* _event_post)(const char* event_base, int32_t event_id, void* event_data, size_t event_data_size, uint32_t ticks_to_wait); 76 | uint32_t (* _get_free_heap_size)(void); 77 | uint32_t (* _rand)(void); 78 | void (* _dport_access_stall_other_cpu_start_wrap)(void); 79 | void (* _dport_access_stall_other_cpu_end_wrap)(void); 80 | void (* _wifi_apb80m_request)(void); 81 | void (* _wifi_apb80m_release)(void); 82 | void (* _phy_disable)(void); 83 | void (* _phy_enable)(void); 84 | #if CONFIG_IDF_TARGET_ESP32 || CONFIG_IDF_TARGET_ESP32S2 85 | void (* _phy_common_clock_enable)(void); 86 | void (* _phy_common_clock_disable)(void); 87 | #endif 88 | int (* _phy_update_country_info)(const char* country); 89 | int (* _read_mac)(uint8_t* mac, unsigned int type); 90 | void (* _timer_arm)(void *timer, uint32_t tmout, bool repeat); 91 | void (* _timer_disarm)(void *timer); 92 | void (* _timer_done)(void *ptimer); 93 | void (* _timer_setfn)(void *ptimer, void *pfunction, void *parg); 94 | void (* _timer_arm_us)(void *ptimer, uint32_t us, bool repeat); 95 | void (* _wifi_reset_mac)(void); 96 | void (* _wifi_clock_enable)(void); 97 | void (* _wifi_clock_disable)(void); 98 | void (* _wifi_rtc_enable_iso)(void); 99 | void (* _wifi_rtc_disable_iso)(void); 100 | int64_t (* _esp_timer_get_time)(void); 101 | int (* _nvs_set_i8)(uint32_t handle, const char* key, int8_t value); 102 | int (* _nvs_get_i8)(uint32_t handle, const char* key, int8_t* out_value); 103 | int (* _nvs_set_u8)(uint32_t handle, const char* key, uint8_t value); 104 | int (* _nvs_get_u8)(uint32_t handle, const char* key, uint8_t* out_value); 105 | int (* _nvs_set_u16)(uint32_t handle, const char* key, uint16_t value); 106 | int (* _nvs_get_u16)(uint32_t handle, const char* key, uint16_t* out_value); 107 | int (* _nvs_open)(const char* name, unsigned int open_mode, uint32_t *out_handle); 108 | void (* _nvs_close)(uint32_t handle); 109 | int (* _nvs_commit)(uint32_t handle); 110 | int (* _nvs_set_blob)(uint32_t handle, const char* key, const void* value, size_t length); 111 | int (* _nvs_get_blob)(uint32_t handle, const char* key, void* out_value, size_t* length); 112 | int (* _nvs_erase_key)(uint32_t handle, const char* key); 113 | int (* _get_random)(uint8_t *buf, size_t len); 114 | int (* _get_time)(void *t); 115 | unsigned long (* _random)(void); 116 | #if !CONFIG_IDF_TARGET_ESP32 117 | uint32_t (* _slowclk_cal_get)(void); 118 | #endif 119 | void (* _log_write)(unsigned int level, const char* tag, const char* format, ...); 120 | void (* _log_writev)(unsigned int level, const char* tag, const char* format, va_list args); 121 | uint32_t (* _log_timestamp)(void); 122 | void * (* _malloc_internal)(size_t size); 123 | void * (* _realloc_internal)(void *ptr, size_t size); 124 | void * (* _calloc_internal)(size_t n, size_t size); 125 | void * (* _zalloc_internal)(size_t size); 126 | void * (* _wifi_malloc)(size_t size); 127 | void * (* _wifi_realloc)(void *ptr, size_t size); 128 | void * (* _wifi_calloc)(size_t n, size_t size); 129 | void * (* _wifi_zalloc)(size_t size); 130 | void * (* _wifi_create_queue)(int queue_len, int item_size); 131 | void (* _wifi_delete_queue)(void * queue); 132 | int (* _coex_init)(void); 133 | void (* _coex_deinit)(void); 134 | int (* _coex_enable)(void); 135 | void (* _coex_disable)(void); 136 | uint32_t (* _coex_status_get)(void); 137 | void (* _coex_condition_set)(uint32_t type, bool dissatisfy); 138 | int (* _coex_wifi_request)(uint32_t event, uint32_t latency, uint32_t duration); 139 | int (* _coex_wifi_release)(uint32_t event); 140 | int (* _coex_wifi_channel_set)(uint8_t primary, uint8_t secondary); 141 | int (* _coex_event_duration_get)(uint32_t event, uint32_t *duration); 142 | int (* _coex_pti_get)(uint32_t event, uint8_t *pti); 143 | void (* _coex_schm_status_bit_clear)(uint32_t type, uint32_t status); 144 | void (* _coex_schm_status_bit_set)(uint32_t type, uint32_t status); 145 | int (* _coex_schm_interval_set)(uint32_t interval); 146 | uint32_t (* _coex_schm_interval_get)(void); 147 | uint8_t (* _coex_schm_curr_period_get)(void); 148 | void * (* _coex_schm_curr_phase_get)(void); 149 | int (* _coex_schm_process_restart)(void); 150 | int (* _coex_schm_register_cb)(int, int (* cb)(int)); 151 | int (* _coex_register_start_cb)(int (* cb)(void)); 152 | #if CONFIG_IDF_TARGET_ESP32C6 153 | void (* _regdma_link_set_write_wait_content)(void *, uint32_t, uint32_t); 154 | void * (* _sleep_retention_find_link_by_id)(int); 155 | int (* _sleep_retention_entries_create)(const void *, int, int, int); 156 | void (* _sleep_retention_entries_destroy)(int); 157 | #endif 158 | int32_t _magic; 159 | } wifi_osi_funcs_t; 160 | 161 | extern wifi_osi_funcs_t g_wifi_osi_funcs; 162 | 163 | #ifdef __cplusplus 164 | } 165 | #endif 166 | 167 | #endif /* ESP_WIFI_OS_ADAPTER_H_ */ 168 | -------------------------------------------------------------------------------- /blobs/headers/esp_coexist.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | 7 | #ifndef __ESP_COEXIST_H__ 8 | #define __ESP_COEXIST_H__ 9 | 10 | #include 11 | #include "esp_err.h" 12 | #include "hal/gpio_types.h" 13 | 14 | #ifdef __cplusplus 15 | extern "C" { 16 | #endif 17 | 18 | #define EXTERNAL_COEXIST_WIRE_1 0 19 | #define EXTERNAL_COEXIST_WIRE_2 1 20 | #define EXTERNAL_COEXIST_WIRE_3 2 21 | #define EXTERNAL_COEXIST_WIRE_4 3 22 | /** 23 | * @brief coex prefer value 24 | */ 25 | typedef enum { 26 | ESP_COEX_PREFER_WIFI = 0, /*!< Prefer to WiFi, WiFi will have more opportunity to use RF */ 27 | ESP_COEX_PREFER_BT, /*!< Prefer to bluetooth, bluetooth will have more opportunity to use RF */ 28 | ESP_COEX_PREFER_BALANCE, /*!< Do balance of WiFi and bluetooth */ 29 | ESP_COEX_PREFER_NUM, /*!< Prefer value numbers */ 30 | } esp_coex_prefer_t; 31 | 32 | typedef enum { 33 | EXTERN_COEX_WIRE_1 = EXTERNAL_COEXIST_WIRE_1, 34 | EXTERN_COEX_WIRE_2 = EXTERNAL_COEXIST_WIRE_2, 35 | EXTERN_COEX_WIRE_3 = EXTERNAL_COEXIST_WIRE_3, 36 | EXTERN_COEX_WIRE_4 = EXTERNAL_COEXIST_WIRE_4, 37 | EXTERN_COEX_WIRE_NUM, 38 | } external_coex_wire_t; 39 | 40 | /** 41 | * @brief coex status type 42 | */ 43 | typedef enum { 44 | ESP_COEX_ST_TYPE_WIFI = 0, 45 | ESP_COEX_ST_TYPE_BLE, 46 | ESP_COEX_ST_TYPE_BT, 47 | } esp_coex_status_type_t; 48 | 49 | #if CONFIG_EXTERNAL_COEX_ENABLE 50 | /** 51 | * @brief external coex gpio pti 52 | */ 53 | typedef struct { 54 | union { 55 | uint32_t in_pin0 __attribute__((deprecated("Use 'request' instead"))); 56 | gpio_num_t request; /**< request gpio signal from follower to leader */ 57 | }; 58 | union { 59 | uint32_t in_pin1 __attribute__((deprecated("Use 'priority' instead"))); 60 | gpio_num_t priority; /**< request gpio signal priority from follower to leader */ 61 | }; 62 | union { 63 | uint32_t out_pin0 __attribute__((deprecated("Use 'grant' instead"))); 64 | gpio_num_t grant; /**< grant gpio signal from leader to follower */ 65 | }; 66 | union { 67 | uint32_t out_pin1 __attribute__((deprecated("Use 'tx_line' instead"))); 68 | gpio_num_t tx_line; /**< tx_line gpio signal from leader to follower, indicates whether the leader's WiFi is transmitting or not*/ 69 | }; 70 | } esp_external_coex_gpio_set_t; 71 | 72 | 73 | /** 74 | * @brief external coex pti level 75 | */ 76 | typedef enum { 77 | EXTERN_COEX_PTI_MID = 0, 78 | EXTERN_COEX_PTI_HIGH, 79 | EXTERN_COEX_PTI_NUM, 80 | } esp_coex_pti_level_t; 81 | 82 | /** 83 | * @brief external coex role 84 | */ 85 | typedef enum { 86 | EXTERNAL_COEX_LEADER_ROLE = 0, 87 | EXTERNAL_COEX_FOLLOWER_ROLE = 2, 88 | EXTERNAL_COEX_UNKNOWN_ROLE, 89 | } esp_extern_coex_work_mode_t; 90 | 91 | /** 92 | * @brief external coex advance setup 93 | */ 94 | typedef struct { 95 | esp_extern_coex_work_mode_t work_mode; 96 | uint8_t delay_us; 97 | bool is_high_valid; 98 | } esp_external_coex_advance_t; 99 | #endif 100 | 101 | #define ESP_COEX_BLE_ST_MESH_CONFIG 0x08 102 | #define ESP_COEX_BLE_ST_MESH_TRAFFIC 0x10 103 | #define ESP_COEX_BLE_ST_MESH_STANDBY 0x20 104 | 105 | #define ESP_COEX_BT_ST_A2DP_STREAMING 0x10 106 | #define ESP_COEX_BT_ST_A2DP_PAUSED 0x20 107 | 108 | /** 109 | * @brief Get software coexist version string 110 | * 111 | * @return : version string 112 | */ 113 | const char *esp_coex_version_get(void); 114 | 115 | /** 116 | * @deprecated Use esp_coex_status_bit_set() and esp_coex_status_bit_clear() instead. 117 | * Set coexist preference of performance 118 | * For example, if prefer to bluetooth, then it will make A2DP(play audio via classic bt) 119 | * more smooth while wifi is runnning something. 120 | * If prefer to wifi, it will do similar things as prefer to bluetooth. 121 | * Default, it prefer to balance. 122 | * 123 | * @param prefer : the prefer enumeration value 124 | * @return : ESP_OK - success, other - failed 125 | */ 126 | esp_err_t esp_coex_preference_set(esp_coex_prefer_t prefer); 127 | 128 | /** 129 | * @brief Set coex schm status 130 | * @param type : WIFI/BLE/BT 131 | * @param status : WIFI/BLE/BT STATUS 132 | * @return : ESP_OK - success, other - failed 133 | */ 134 | esp_err_t esp_coex_status_bit_set(esp_coex_status_type_t type, uint32_t status); 135 | 136 | /** 137 | * @brief Clear coex schm status 138 | * @param type : WIFI/BLE/BT 139 | * @param status : WIFI/BLE/BT STATUS 140 | * @return : ESP_OK - success, other - failed 141 | */ 142 | esp_err_t esp_coex_status_bit_clear(esp_coex_status_type_t type, uint32_t status); 143 | 144 | #if CONFIG_EXTERNAL_COEX_ENABLE 145 | /** 146 | * @brief Configure work mode, the default work mode is leader role. 147 | * @param work_mode : work mode. 148 | * @return : ESP_OK - success, other - failed 149 | */ 150 | esp_err_t esp_external_coex_set_work_mode(esp_extern_coex_work_mode_t work_mode); 151 | 152 | /** 153 | * @brief Setup gpio pin and corresponding pti level, start external coex, 154 | * the default work mode is leader role, the default output grant validate pin is high, 155 | * and the default delay output grant value is zero. 156 | * @param wire_type : to select the whole external coex gpio number. 157 | * @param gpio_pin : gpio pin number to choose. 158 | * @return : ESP_OK - success, other - failed 159 | */ 160 | esp_err_t esp_enable_extern_coex_gpio_pin(external_coex_wire_t wire_type, 161 | esp_external_coex_gpio_set_t gpio_pin); 162 | 163 | /** 164 | * @brief Disable external coex. 165 | * @return : ESP_OK - success, other - failed 166 | */ 167 | esp_err_t esp_disable_extern_coex_gpio_pin(); 168 | 169 | #if SOC_EXTERNAL_COEX_ADVANCE 170 | /** 171 | * @brief Configure leader work mode, gpio pin correspondly and finally enable external coex, 172 | * demand not to call the legacy function of `esp_enable_extern_coex_gpio_pin` any more. 173 | * @param wire_type : to select the whole external coex gpio number. 174 | * @param request : request gpio pin number to select. 175 | * @param priority : priority gpio pin number to select. 176 | * @param grant : grant gpio pin number to select. 177 | * @return : ESP_OK - success, other - failed 178 | */ 179 | esp_err_t esp_external_coex_leader_role_set_gpio_pin(external_coex_wire_t wire_type, uint32_t request, uint32_t priority, 180 | uint32_t grant) __attribute__((deprecated("Please use esp_external_coex_set_work_mode and esp_enable_extern_coex_gpio_pin instead"))); 181 | 182 | /** 183 | * @brief Configure follower work mode, gpio pin correspondly and finally enable external coex, 184 | * demand not to call the legacy function of `esp_enable_extern_coex_gpio_pin` any more. 185 | * @param wire_type : to select the whole external coex gpio number. 186 | * @param request : request gpio pin number to select. 187 | * @param priority : priority gpio pin number to select. 188 | * @param grant : grant gpio pin number to select. 189 | * @return : ESP_OK - success, other - failed 190 | */ 191 | esp_err_t esp_external_coex_follower_role_set_gpio_pin(external_coex_wire_t wire_type, uint32_t request, uint32_t priority, 192 | uint32_t grant) __attribute__((deprecated("Please use esp_external_coex_set_work_mode and esp_enable_extern_coex_gpio_pin instead"))); 193 | 194 | /** 195 | * @brief Configure output grant signal latency in delay microseconds only for leader role of external coex, 196 | * demand to call this function before `esp_external_coex_leader_role_set_gpio_pin`, 197 | * if users want to setup output delay value. 198 | * @param delay_us : to setup how many microseconds the output signal performs latency. 199 | * @return : ESP_OK - success, other - failed 200 | */ 201 | esp_err_t esp_external_coex_set_grant_delay(uint8_t delay_us); 202 | 203 | /** 204 | * @brief Configure output grant signal is high validate or not only for leader role of external coex, 205 | * demand to call this function before `esp_external_coex_leader_role_set_gpio_pin`, 206 | * if users want to setup output grant validate pin value. 207 | * @param is_high_valid : to select true means the output grant signal validate is high, other - validate is low. 208 | * @return : ESP_OK - success, other - failed 209 | */ 210 | esp_err_t esp_external_coex_set_validate_high(bool is_high_valid); 211 | #endif /* SOC_EXTERNAL_COEX_ADVANCE */ 212 | #endif /* CONFIG_EXTERNAL_COEX_ENABLE */ 213 | 214 | #if CONFIG_ESP_COEX_SW_COEXIST_ENABLE && CONFIG_SOC_IEEE802154_SUPPORTED 215 | /** 216 | * @brief Enable Wi-Fi and 802.15.4 coexistence. 217 | * @return : ESP_OK - success, other - failed 218 | */ 219 | esp_err_t esp_coex_wifi_i154_enable(void); 220 | #endif 221 | 222 | #ifdef __cplusplus 223 | } 224 | #endif 225 | 226 | 227 | #endif /* __ESP_COEXIST_H__ */ 228 | -------------------------------------------------------------------------------- /blobs/headers/esp_phy_init.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | 7 | #pragma once 8 | #include 9 | #include 10 | #include "esp_err.h" 11 | 12 | #ifdef __cplusplus 13 | extern "C" { 14 | #endif 15 | 16 | /** 17 | * @file 18 | * init parameters and API 19 | */ 20 | 21 | 22 | /** 23 | * @brief Structure holding PHY init parameters 24 | */ 25 | typedef struct { 26 | uint8_t params[128]; /*!< opaque PHY initialization parameters */ 27 | } esp_phy_init_data_t; 28 | 29 | /** 30 | * @brief PHY enable or disable modem 31 | */ 32 | typedef enum { 33 | PHY_MODEM_WIFI = 1, /*!< PHY modem WIFI */ 34 | PHY_MODEM_BT = 2, /*!< PHY modem BT */ 35 | PHY_MODEM_IEEE802154 = 4, /*!< PHY modem IEEE802154 */ 36 | } esp_phy_modem_t; 37 | 38 | /** 39 | * @brief Opaque PHY calibration data 40 | */ 41 | typedef struct { 42 | uint8_t version[4]; /*!< PHY version */ 43 | uint8_t mac[6]; /*!< The MAC address of the station */ 44 | uint8_t opaque[1894]; /*!< calibration data */ 45 | } esp_phy_calibration_data_t; 46 | 47 | /** 48 | * @brief PHY calibration mode 49 | * 50 | */ 51 | typedef enum { 52 | PHY_RF_CAL_PARTIAL = 0x00000000, /*!< Do part of RF calibration. This should be used after power-on reset. */ 53 | PHY_RF_CAL_NONE = 0x00000001, /*!< Don't do any RF calibration. This mode is only suggested to be used after deep sleep reset. */ 54 | PHY_RF_CAL_FULL = 0x00000002 /*!< Do full RF calibration. Produces best results, but also consumes a lot of time and current. Suggested to be used once. */ 55 | } esp_phy_calibration_mode_t; 56 | 57 | #if CONFIG_ESP_PHY_MULTIPLE_INIT_DATA_BIN 58 | /** 59 | * @brief PHY init data type 60 | */ 61 | typedef enum { 62 | ESP_PHY_INIT_DATA_TYPE_DEFAULT = 0, 63 | ESP_PHY_INIT_DATA_TYPE_SRRC, 64 | ESP_PHY_INIT_DATA_TYPE_FCC, 65 | ESP_PHY_INIT_DATA_TYPE_CE, 66 | ESP_PHY_INIT_DATA_TYPE_NCC, 67 | ESP_PHY_INIT_DATA_TYPE_KCC, 68 | ESP_PHY_INIT_DATA_TYPE_MIC, 69 | ESP_PHY_INIT_DATA_TYPE_IC, 70 | ESP_PHY_INIT_DATA_TYPE_ACMA, 71 | ESP_PHY_INIT_DATA_TYPE_ANATEL, 72 | ESP_PHY_INIT_DATA_TYPE_ISED, 73 | ESP_PHY_INIT_DATA_TYPE_WPC, 74 | ESP_PHY_INIT_DATA_TYPE_OFCA, 75 | ESP_PHY_INIT_DATA_TYPE_IFETEL, 76 | ESP_PHY_INIT_DATA_TYPE_RCM, 77 | ESP_PHY_INIT_DATA_TYPE_NUMBER, 78 | } phy_init_data_type_t; 79 | #endif 80 | 81 | /** 82 | * @brief Get PHY init data 83 | * 84 | * If "Use a partition to store PHY init data" option is set in menuconfig, 85 | * This function will load PHY init data from a partition. Otherwise, 86 | * PHY init data will be compiled into the application itself, and this function 87 | * will return a pointer to PHY init data located in read-only memory (DROM). 88 | * 89 | * If "Use a partition to store PHY init data" option is enabled, this function 90 | * may return NULL if the data loaded from flash is not valid. 91 | * 92 | * @note Call esp_phy_release_init_data to release the pointer obtained using 93 | * this function after the call to esp_wifi_init. 94 | * 95 | * @return pointer to PHY init data structure 96 | */ 97 | const esp_phy_init_data_t* esp_phy_get_init_data(void); 98 | 99 | /** 100 | * @brief Release PHY init data 101 | * @param data pointer to PHY init data structure obtained from 102 | * esp_phy_get_init_data function 103 | */ 104 | void esp_phy_release_init_data(const esp_phy_init_data_t* data); 105 | 106 | /** 107 | * @brief Function called by esp_phy_load_cal_and_init to load PHY calibration data 108 | * 109 | * This is a convenience function which can be used to load PHY calibration 110 | * data from NVS. Data can be stored to NVS using esp_phy_store_cal_data_to_nvs 111 | * function. 112 | * 113 | * If calibration data is not present in the NVS, or 114 | * data is not valid (was obtained for a chip with a different MAC address, 115 | * or obtained for a different version of software), this function will 116 | * return an error. 117 | * 118 | * @param out_cal_data pointer to calibration data structure to be filled with 119 | * loaded data. 120 | * @return ESP_OK on success 121 | */ 122 | esp_err_t esp_phy_load_cal_data_from_nvs(esp_phy_calibration_data_t* out_cal_data); 123 | 124 | /** 125 | * @brief Function called by esp_phy_load_cal_and_init to store PHY calibration data 126 | * 127 | * This is a convenience function which can be used to store PHY calibration 128 | * data to the NVS. Calibration data is returned by esp_phy_load_cal_and_init function. 129 | * Data saved using this function to the NVS can later be loaded using 130 | * esp_phy_store_cal_data_to_nvs function. 131 | * 132 | * @param cal_data pointer to calibration data which has to be saved. 133 | * @return ESP_OK on success 134 | */ 135 | esp_err_t esp_phy_store_cal_data_to_nvs(const esp_phy_calibration_data_t* cal_data); 136 | 137 | /** 138 | * @brief Erase PHY calibration data which is stored in the NVS 139 | * 140 | * This is a function which can be used to trigger full calibration as a last-resort remedy 141 | * if partial calibration is used. It can be called in the application based on some conditions 142 | * (e.g. an option provided in some diagnostic mode). 143 | * 144 | * @return ESP_OK on success 145 | * @return others on fail. Please refer to NVS API return value error number. 146 | */ 147 | esp_err_t esp_phy_erase_cal_data_in_nvs(void); 148 | 149 | /** 150 | * @brief Enable PHY and RF module 151 | * 152 | * PHY and RF module should be enabled in order to use WiFi or BT. 153 | * Now PHY and RF enabling job is done automatically when start WiFi or BT. Users should not 154 | * call this API in their application. 155 | * 156 | * @param modem the modem to call the phy enable. 157 | */ 158 | void esp_phy_enable(esp_phy_modem_t modem); 159 | 160 | /** 161 | * @brief Disable PHY and RF module 162 | * 163 | * PHY module should be disabled in order to shutdown WiFi or BT. 164 | * Now PHY and RF disabling job is done automatically when stop WiFi or BT. Users should not 165 | * call this API in their application. 166 | * 167 | * @param modem the modem to call the phy disable. 168 | */ 169 | void esp_phy_disable(esp_phy_modem_t modem); 170 | 171 | /** 172 | * @brief Enable BTBB module 173 | * 174 | * BTBB module should be enabled in order to use IEEE802154 or BT. 175 | * Now BTBB enabling job is done automatically when start IEEE802154 or BT. Users should not 176 | * call this API in their application. 177 | * 178 | */ 179 | void esp_btbb_enable(void); 180 | 181 | /** 182 | * @brief Disable BTBB module 183 | * 184 | * Dsiable BTBB module, used by IEEE802154 or Bluetooth. 185 | * Users should not call this API in their application. 186 | * 187 | */ 188 | void esp_btbb_disable(void); 189 | 190 | /** 191 | * @brief Load calibration data from NVS and initialize PHY and RF module 192 | */ 193 | void esp_phy_load_cal_and_init(void); 194 | 195 | /** 196 | * @brief Initialize backup memory for Phy power up/down 197 | */ 198 | void esp_phy_modem_init(void); 199 | 200 | /** 201 | * @brief Deinitialize backup memory for Phy power up/down 202 | * Set phy_init_flag if all modems deinit on ESP32C3 203 | */ 204 | void esp_phy_modem_deinit(void); 205 | 206 | #if CONFIG_MAC_BB_PD 207 | /** 208 | * @brief Initialize backup memory for MAC and Baseband power up/down 209 | */ 210 | void esp_mac_bb_pd_mem_init(void); 211 | 212 | /** 213 | * @brief Deinitialize backup memory for MAC and Baseband power up/down 214 | */ 215 | void esp_mac_bb_pd_mem_deinit(void); 216 | 217 | /** 218 | * @brief Power up MAC and Baseband 219 | */ 220 | void esp_mac_bb_power_up(void); 221 | 222 | /** 223 | * @brief Power down MAC and Baseband 224 | */ 225 | void esp_mac_bb_power_down(void); 226 | #endif 227 | 228 | /** 229 | * @brief Enable WiFi/BT common clock 230 | * 231 | */ 232 | void esp_phy_common_clock_enable(void); 233 | 234 | /** 235 | * @brief Disable WiFi/BT common clock 236 | * 237 | */ 238 | void esp_phy_common_clock_disable(void); 239 | 240 | /** 241 | * @brief Get the time stamp when PHY/RF was switched on 242 | * @return return 0 if PHY/RF is never switched on. Otherwise return time in 243 | * microsecond since boot when phy/rf was last switched on 244 | */ 245 | int64_t esp_phy_rf_get_on_ts(void); 246 | 247 | /** 248 | * @brief Update the corresponding PHY init type according to the country code of Wi-Fi. 249 | * 250 | * @param country country code 251 | * @return ESP_OK on success. 252 | * @return esp_err_t code describing the error on fail 253 | */ 254 | esp_err_t esp_phy_update_country_info(const char *country); 255 | 256 | 257 | #if CONFIG_ESP_PHY_MULTIPLE_INIT_DATA_BIN 258 | /** 259 | * @brief Apply PHY init bin to PHY 260 | * @return ESP_OK on success. 261 | * @return ESP_FAIL on fail. 262 | */ 263 | esp_err_t esp_phy_apply_phy_init_data(uint8_t *init_data); 264 | #endif 265 | 266 | /** 267 | * @brief Get PHY lib version 268 | * @return PHY lib version. 269 | */ 270 | char * get_phy_version_str(void); 271 | 272 | /** 273 | * @brief Set PHY init parameters 274 | * @param param is 1 means combo module 275 | */ 276 | void phy_init_param_set(uint8_t param); 277 | 278 | /** 279 | * @brief Wi-Fi RX enable 280 | * @param enable True for enable wifi receiving mode as default, false for closing wifi receiving mode as default. 281 | */ 282 | void phy_wifi_enable_set(uint8_t enable); 283 | 284 | #ifdef __cplusplus 285 | } 286 | #endif 287 | -------------------------------------------------------------------------------- /blobs/headers/esp_coexist_internal.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2018-2023 Espressif Systems (Shanghai) CO LTD 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | 7 | #ifndef __ESP_COEXIST_INTERNAL_H__ 8 | #define __ESP_COEXIST_INTERNAL_H__ 9 | 10 | #include 11 | #include "esp_coexist.h" 12 | #include "esp_coexist_adapter.h" 13 | 14 | #ifdef __cplusplus 15 | extern "C" { 16 | #endif 17 | 18 | typedef enum { 19 | COEX_PREFER_WIFI = 0, 20 | COEX_PREFER_BT, 21 | COEX_PREFER_BALANCE, 22 | COEX_PREFER_NUM, 23 | } coex_prefer_t; 24 | 25 | typedef enum { 26 | COEX_SCHM_CALLBACK_TYPE_WIFI = 0, 27 | COEX_SCHM_CALLBACK_TYPE_BT, 28 | COEX_SCHM_CALLBACK_TYPE_I154, 29 | } coex_schm_callback_type_t; 30 | 31 | typedef void (* coex_func_cb_t)(uint32_t event, int sched_cnt); 32 | typedef esp_err_t (* coex_set_lpclk_source_callback_t)(void); 33 | typedef void (* coex_wifi_channel_change_cb_t)(uint8_t primary, uint8_t secondary); 34 | 35 | /** 36 | * @brief Pre-Init software coexist 37 | * extern function for internal use. 38 | * 39 | * @return Init ok or failed. 40 | */ 41 | esp_err_t coex_pre_init(void); 42 | 43 | /** 44 | * @brief Init software coexist 45 | * extern function for internal use. 46 | * 47 | * @return Init ok or failed. 48 | */ 49 | esp_err_t coex_init(void); 50 | 51 | /** 52 | * @brief De-init software coexist 53 | * extern function for internal use. 54 | */ 55 | void coex_deinit(void); 56 | 57 | /** 58 | * @brief Enable software coexist 59 | * extern function for internal use. 60 | * 61 | * @return Enable ok or failed. 62 | */ 63 | esp_err_t coex_enable(void); 64 | 65 | /** 66 | * @brief Disable software coexist 67 | * extern function for internal use. 68 | */ 69 | void coex_disable(void); 70 | 71 | /** 72 | * @brief Get software coexist version string 73 | * extern function for internal use. 74 | * @return : version string 75 | */ 76 | const char *coex_version_get(void); 77 | 78 | /** 79 | * @brief Get software coexist version value 80 | * extern function for internal use. 81 | * @param ptr_version : points to version structure 82 | * @return : ESP_OK - success, other - failed 83 | */ 84 | esp_err_t coex_version_get_value(coex_version_t* ptr_version); 85 | 86 | /** 87 | * @brief Coexist performance preference set from libbt.a 88 | * extern function for internal use. 89 | * 90 | * @param prefer : the prefer enumeration value 91 | * @return : ESP_OK - success, other - failed 92 | */ 93 | esp_err_t coex_preference_set(coex_prefer_t prefer); 94 | 95 | /** 96 | * @brief Get software coexist status. 97 | * @return : software coexist status 98 | */ 99 | uint32_t coex_status_get(void); 100 | 101 | /** 102 | * @brief WiFi requests coexistence. 103 | * 104 | * @param event : WiFi event 105 | * @param latency : WiFi will request coexistence after latency 106 | * @param duration : duration for WiFi to request coexistence 107 | * @return : 0 - success, other - failed 108 | */ 109 | int coex_wifi_request(uint32_t event, uint32_t latency, uint32_t duration); 110 | 111 | /** 112 | * @brief WiFi release coexistence. 113 | * 114 | * @param event : WiFi event 115 | * @return : 0 - success, other - failed 116 | */ 117 | int coex_wifi_release(uint32_t event); 118 | 119 | /** 120 | * @brief Set WiFi channel to coexistence module. 121 | * 122 | * @param primary : WiFi primary channel 123 | * @param secondary : WiFi secondary channel 124 | * @return : 0 - success, other - failed 125 | */ 126 | int coex_wifi_channel_set(uint8_t primary, uint8_t secondary); 127 | 128 | /** 129 | * @brief Get WiFi channel from coexistence module. 130 | * 131 | * @param primary : pointer to value of WiFi primary channel 132 | * @param secondary : pointer to value of WiFi secondary channel 133 | * @return : 0 - success, other - failed 134 | */ 135 | int coex_wifi_channel_get(uint8_t *primary, uint8_t *secondary); 136 | 137 | /** 138 | * @brief Register application callback function to Wi-Fi update low power clock module. 139 | * 140 | * @param callback : Wi-Fi update low power clock callback function 141 | */ 142 | void coex_wifi_register_update_lpclk_callback(coex_set_lpclk_source_callback_t callback); 143 | 144 | /** 145 | * @brief Bluetooth requests coexistence 146 | * 147 | * @param event : Bluetooth event 148 | * @param latency : Bluetooth will request coexistence after latency 149 | * @param duration : duration for Bluetooth to request coexistence 150 | * @return : 0 - success, other - failed 151 | */ 152 | int coex_bt_request(uint32_t event, uint32_t latency, uint32_t duration); 153 | 154 | /** 155 | * @brief Bluetooth release coexistence. 156 | * 157 | * @param event : Bluetooth event 158 | * @return : 0 - success, other - failed 159 | */ 160 | int coex_bt_release(uint32_t event); 161 | 162 | #if CONFIG_IDF_TARGET_ESP32 163 | /** 164 | * @brief Bluetooth registers callback function to coexistence module 165 | * This function is only used on ESP32. 166 | * 167 | * @param callback: callback function registered to coexistence module 168 | * @return : 0 - success, other - failed 169 | */ 170 | int coex_register_bt_cb(coex_func_cb_t callback); 171 | 172 | /** 173 | * @brief To acquire the spin-lock used in resetting Bluetooth baseband. 174 | * This function is only used to workaround ESP32 hardware issue. 175 | * 176 | * @return : value of the spinlock to be restored 177 | */ 178 | uint32_t coex_bb_reset_lock(void); 179 | 180 | /** 181 | * @brief To release the spin-lock used in resetting Bluetooth baseband. 182 | * This function is only used to workaround ESP32 hardware issue. 183 | * 184 | * @param restore: value of the spinlock returned from previous call of coex_bb_rest_lock 185 | */ 186 | void coex_bb_reset_unlock(uint32_t restore); 187 | #endif /* CONFIG_IDF_TARGET_ESP32 */ 188 | 189 | /** 190 | * @brief Bluetooth registers callback function to receive notification when Wi-Fi channel changes 191 | * 192 | * @param callback: callback function registered to coexistence module 193 | * @return : 0 - success, other - failed 194 | */ 195 | int coex_register_wifi_channel_change_callback(coex_wifi_channel_change_cb_t callback); 196 | 197 | /** 198 | * @brief Update low power clock interval 199 | */ 200 | void coex_update_lpclk_interval(void); 201 | 202 | /** 203 | * @brief Get coexistence event duration. 204 | * 205 | * @param event : Coexistence event 206 | * @param duration: Coexistence event duration 207 | * @return : 0 - success, other - failed 208 | */ 209 | int coex_event_duration_get(uint32_t event, uint32_t *duration); 210 | 211 | #if SOC_COEX_HW_PTI 212 | /** 213 | * @brief Get coexistence event priority. 214 | * 215 | * @param event : Coexistence event 216 | * @param pti: Coexistence event priority 217 | * @return : 0 - success, other - failed 218 | */ 219 | int coex_pti_get(uint32_t event, uint8_t *pti); 220 | #endif 221 | 222 | /** 223 | * @brief Clear coexistence status. 224 | * 225 | * @param type : Coexistence status type 226 | * @param status: Coexistence status 227 | */ 228 | void coex_schm_status_bit_clear(uint32_t type, uint32_t status); 229 | 230 | /** 231 | * @brief Set coexistence status. 232 | * 233 | * @param type : Coexistence status type 234 | * @param status: Coexistence status 235 | */ 236 | void coex_schm_status_bit_set(uint32_t type, uint32_t status); 237 | 238 | /** 239 | * @brief Set coexistence scheme interval. 240 | * 241 | * @param interval : Coexistence scheme interval 242 | * @return : 0 - success, other - failed 243 | */ 244 | int coex_schm_interval_set(uint32_t interval); 245 | 246 | /** 247 | * @brief Get coexistence scheme interval. 248 | * 249 | * @return : Coexistence scheme interval 250 | */ 251 | uint32_t coex_schm_interval_get(void); 252 | 253 | /** 254 | * @brief Get current coexistence scheme period. 255 | * 256 | * @return : Coexistence scheme period 257 | */ 258 | uint8_t coex_schm_curr_period_get(void); 259 | 260 | /** 261 | * @brief Get current coexistence scheme phase. 262 | * 263 | * @return : Coexistence scheme phase 264 | */ 265 | void * coex_schm_curr_phase_get(void); 266 | 267 | /** 268 | * @brief Set current coexistence scheme phase index. 269 | * 270 | * @param idx : Coexistence scheme phase index 271 | * @return : 0 - success, other - failed 272 | */ 273 | int coex_schm_curr_phase_idx_set(int idx); 274 | 275 | /** 276 | * @brief Get current coexistence scheme phase index. 277 | * 278 | * @return : Coexistence scheme phase index 279 | */ 280 | int coex_schm_curr_phase_idx_get(void); 281 | 282 | /** 283 | * @brief Register WiFi callback for coexistence starts. 284 | * 285 | * @param cb : WiFi callback 286 | * @return : 0 - success, other - failed 287 | */ 288 | int coex_register_start_cb(int (* cb)(void)); 289 | 290 | /** 291 | * @brief Restart current coexistence scheme. 292 | * 293 | * @return : 0 - success, other - failed 294 | */ 295 | int coex_schm_process_restart(void); 296 | 297 | /** 298 | * @brief Register callback for coexistence scheme. 299 | * 300 | * @param type : callback type 301 | * @param callback : callback 302 | * @return : 0 - success, other - failed 303 | */ 304 | int coex_schm_register_callback(coex_schm_callback_type_t type, void *callback); 305 | 306 | /** 307 | * @brief Register coexistence adapter functions. 308 | * 309 | * @param funcs : coexistence adapter functions 310 | * @return : ESP_OK - success, other - failed 311 | */ 312 | esp_err_t esp_coex_adapter_register(coex_adapter_funcs_t *funcs); 313 | 314 | #if CONFIG_EXTERNAL_COEX_ENABLE 315 | /** 316 | * @brief Set external coexistence advanced informations, like working mode. 317 | * 318 | * @param out_pti1 This parameter no longer works, will be deprecated and later removed in future releases. 319 | * @param out_pti2 This parameter no longer works, will be deprecated and later removed in future releases. 320 | * 321 | * @return 322 | * - ESP_OK: succeed 323 | */ 324 | esp_err_t esp_coex_external_params(esp_external_coex_advance_t coex_info, uint32_t out_pti1, uint32_t out_pti2); 325 | 326 | /** 327 | * @brief Set external coexistence pti level and enable it. 328 | * 329 | * @param level1 external coex low pti 330 | * @param level2 external coex mid pti 331 | * @param level3 external coex high pti 332 | * 333 | * @return 334 | * - ESP_OK: succeed 335 | */ 336 | esp_err_t esp_coex_external_set(esp_coex_pti_level_t level1, 337 | esp_coex_pti_level_t level2, esp_coex_pti_level_t level3); 338 | 339 | /** 340 | * @brief Disable external coexist 341 | * 342 | * @return 343 | * - ESP_OK: succeed 344 | */ 345 | void esp_coex_external_stop(void); 346 | 347 | /** 348 | * @brief Set external coexistence wire type. 349 | * 350 | * @param wire_type Set external coexistence wire type. 351 | * 352 | */ 353 | void esp_coex_external_set_wire_type(external_coex_wire_t wire_type); 354 | 355 | #if SOC_EXTERNAL_COEX_LEADER_TX_LINE 356 | /** 357 | * @brief Enable external coexist tx line 358 | * 359 | * @param en Enable external coex tx line 360 | * 361 | * @return 362 | * - ESP_OK: succeed 363 | */ 364 | void esp_coex_external_set_txline(bool en); 365 | #endif /*SOC_EXTERNAL_COEX_LEADER_TX_LINE*/ 366 | #endif /*External Coex*/ 367 | 368 | /** 369 | * @brief Check the MD5 values of the coexistence adapter header files in IDF and WiFi library 370 | * 371 | * @attention 1. It is used for internal CI version check 372 | * 373 | * @return 374 | * - ESP_OK : succeed 375 | * - ESP_WIFI_INVALID_ARG : MD5 check fail 376 | */ 377 | esp_err_t esp_coex_adapter_funcs_md5_check(const char *md5); 378 | 379 | #ifdef __cplusplus 380 | } 381 | #endif 382 | 383 | #endif /* __ESP_COEXIST_INTERNAL_H__ */ 384 | -------------------------------------------------------------------------------- /blobs/LICENSE.txt: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright 2022 esp-rs 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /blobs/headers/esp_event_legacy.h: -------------------------------------------------------------------------------- 1 | // Copyright 2015-2018 Espressif Systems (Shanghai) PTE LTD 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #pragma once 16 | 17 | #include 18 | #include 19 | 20 | #include "esp_err.h" 21 | #include "esp_wifi_types.h" 22 | 23 | #ifdef __cplusplus 24 | extern "C" { 25 | #endif 26 | 27 | /** System event types enumeration */ 28 | typedef enum { 29 | SYSTEM_EVENT_WIFI_READY = 0, /*!< ESP32 WiFi ready */ 30 | SYSTEM_EVENT_SCAN_DONE, /*!< ESP32 finish scanning AP */ 31 | SYSTEM_EVENT_STA_START, /*!< ESP32 station start */ 32 | SYSTEM_EVENT_STA_STOP, /*!< ESP32 station stop */ 33 | SYSTEM_EVENT_STA_CONNECTED, /*!< ESP32 station connected to AP */ 34 | SYSTEM_EVENT_STA_DISCONNECTED, /*!< ESP32 station disconnected from AP */ 35 | SYSTEM_EVENT_STA_AUTHMODE_CHANGE, /*!< the auth mode of AP connected by ESP32 station changed */ 36 | SYSTEM_EVENT_STA_GOT_IP, /*!< ESP32 station got IP from connected AP */ 37 | SYSTEM_EVENT_STA_LOST_IP, /*!< ESP32 station lost IP and the IP is reset to 0 */ 38 | SYSTEM_EVENT_STA_BSS_RSSI_LOW, /*!< ESP32 station connected BSS rssi goes below threshold */ 39 | SYSTEM_EVENT_STA_WPS_ER_SUCCESS, /*!< ESP32 station wps succeeds in enrollee mode */ 40 | SYSTEM_EVENT_STA_WPS_ER_FAILED, /*!< ESP32 station wps fails in enrollee mode */ 41 | SYSTEM_EVENT_STA_WPS_ER_TIMEOUT, /*!< ESP32 station wps timeout in enrollee mode */ 42 | SYSTEM_EVENT_STA_WPS_ER_PIN, /*!< ESP32 station wps pin code in enrollee mode */ 43 | SYSTEM_EVENT_STA_WPS_ER_PBC_OVERLAP, /*!< ESP32 station wps overlap in enrollee mode */ 44 | SYSTEM_EVENT_AP_START, /*!< ESP32 soft-AP start */ 45 | SYSTEM_EVENT_AP_STOP, /*!< ESP32 soft-AP stop */ 46 | SYSTEM_EVENT_AP_STACONNECTED, /*!< a station connected to ESP32 soft-AP */ 47 | SYSTEM_EVENT_AP_STADISCONNECTED, /*!< a station disconnected from ESP32 soft-AP */ 48 | SYSTEM_EVENT_AP_STAIPASSIGNED, /*!< ESP32 soft-AP assign an IP to a connected station */ 49 | SYSTEM_EVENT_AP_PROBEREQRECVED, /*!< Receive probe request packet in soft-AP interface */ 50 | SYSTEM_EVENT_ACTION_TX_STATUS, /*!< Receive status of Action frame transmitted */ 51 | SYSTEM_EVENT_ROC_DONE, /*!< Indicates the completion of Remain-on-Channel operation status */ 52 | SYSTEM_EVENT_STA_BEACON_TIMEOUT, /*!< ESP32 station beacon timeout */ 53 | SYSTEM_EVENT_FTM_REPORT, /*!< Receive report of FTM procedure */ 54 | SYSTEM_EVENT_GOT_IP6, /*!< ESP32 station or ap or ethernet interface v6IP addr is preferred */ 55 | SYSTEM_EVENT_ETH_START, /*!< ESP32 ethernet start */ 56 | SYSTEM_EVENT_ETH_STOP, /*!< ESP32 ethernet stop */ 57 | SYSTEM_EVENT_ETH_CONNECTED, /*!< ESP32 ethernet phy link up */ 58 | SYSTEM_EVENT_ETH_DISCONNECTED, /*!< ESP32 ethernet phy link down */ 59 | SYSTEM_EVENT_ETH_GOT_IP, /*!< ESP32 ethernet got IP from connected AP */ 60 | SYSTEM_EVENT_MAX /*!< Number of members in this enum */ 61 | } system_event_id_t; 62 | 63 | /* add this macro define for compatible with old IDF version */ 64 | #ifndef SYSTEM_EVENT_AP_STA_GOT_IP6 65 | #define SYSTEM_EVENT_AP_STA_GOT_IP6 SYSTEM_EVENT_GOT_IP6 66 | #endif 67 | 68 | 69 | /** Argument structure of SYSTEM_EVENT_STA_WPS_ER_FAILED event */ 70 | typedef wifi_event_sta_wps_fail_reason_t system_event_sta_wps_fail_reason_t; 71 | 72 | /** Argument structure of SYSTEM_EVENT_SCAN_DONE event */ 73 | typedef wifi_event_sta_scan_done_t system_event_sta_scan_done_t; 74 | 75 | /** Argument structure of SYSTEM_EVENT_STA_CONNECTED event */ 76 | typedef wifi_event_sta_connected_t system_event_sta_connected_t; 77 | 78 | /** Argument structure of SYSTEM_EVENT_STA_DISCONNECTED event */ 79 | typedef wifi_event_sta_disconnected_t system_event_sta_disconnected_t; 80 | 81 | /** Argument structure of SYSTEM_EVENT_STA_AUTHMODE_CHANGE event */ 82 | typedef wifi_event_sta_authmode_change_t system_event_sta_authmode_change_t; 83 | 84 | /** Argument structure of SYSTEM_EVENT_STA_WPS_ER_PIN event */ 85 | typedef wifi_event_sta_wps_er_pin_t system_event_sta_wps_er_pin_t; 86 | 87 | /** Argument structure of SYSTEM_EVENT_STA_WPS_ER_PIN event */ 88 | typedef wifi_event_sta_wps_er_success_t system_event_sta_wps_er_success_t; 89 | 90 | /** Argument structure of event */ 91 | typedef wifi_event_ap_staconnected_t system_event_ap_staconnected_t; 92 | 93 | /** Argument structure of event */ 94 | typedef wifi_event_ap_stadisconnected_t system_event_ap_stadisconnected_t; 95 | 96 | /** Argument structure of event */ 97 | typedef wifi_event_ap_probe_req_rx_t system_event_ap_probe_req_rx_t; 98 | 99 | /** Argument structure of SYSTEM_EVENT_FTM_REPORT event */ 100 | typedef wifi_event_ftm_report_t system_event_ftm_report_t; 101 | 102 | /** Argument structure of event */ 103 | 104 | /** Argument structure of event */ 105 | 106 | /** Argument structure of event */ 107 | 108 | /** Union of all possible system_event argument structures */ 109 | typedef union { 110 | system_event_sta_connected_t connected; /*!< ESP32 station connected to AP */ 111 | system_event_sta_disconnected_t disconnected; /*!< ESP32 station disconnected to AP */ 112 | system_event_sta_scan_done_t scan_done; /*!< ESP32 station scan (APs) done */ 113 | system_event_sta_authmode_change_t auth_change; /*!< the auth mode of AP ESP32 station connected to changed */ 114 | system_event_sta_wps_er_pin_t sta_er_pin; /*!< ESP32 station WPS enrollee mode PIN code received */ 115 | system_event_sta_wps_fail_reason_t sta_er_fail_reason; /*!< ESP32 station WPS enrollee mode failed reason code received */ 116 | system_event_sta_wps_er_success_t sta_er_success; /*!< ESP32 station WPS enrollee success */ 117 | system_event_ap_staconnected_t sta_connected; /*!< a station connected to ESP32 soft-AP */ 118 | system_event_ap_stadisconnected_t sta_disconnected; /*!< a station disconnected to ESP32 soft-AP */ 119 | system_event_ap_probe_req_rx_t ap_probereqrecved; /*!< ESP32 soft-AP receive probe request packet */ 120 | system_event_ftm_report_t ftm_report; /*!< Report of FTM procedure */ 121 | } system_event_info_t; 122 | 123 | /** Event, as a tagged enum */ 124 | typedef struct { 125 | system_event_id_t event_id; /*!< event ID */ 126 | system_event_info_t event_info; /*!< event information */ 127 | } system_event_t; 128 | 129 | /** Event handler function type */ 130 | typedef esp_err_t (*system_event_handler_t)(esp_event_base_t event_base, 131 | int32_t event_id, 132 | void* event_data, 133 | size_t event_data_size, 134 | TickType_t ticks_to_wait); 135 | 136 | /** 137 | * @brief Send a event to event task 138 | * 139 | * @note This API is part of the legacy event system. New code should use event library API in esp_event.h 140 | * 141 | * Other task/modules, such as the tcpip_adapter, can call this API to send an event to event task 142 | * 143 | * @param event Event to send 144 | * 145 | * @return ESP_OK : succeed 146 | * @return others : fail 147 | */ 148 | esp_err_t esp_event_send(system_event_t *event) __attribute__ ((deprecated)); 149 | 150 | /** 151 | * @brief Send a event to event task 152 | * 153 | * @note This API is used by WiFi Driver only. 154 | * 155 | * Other task/modules, such as the tcpip_adapter, can call this API to send an event to event task 156 | * 157 | * @param[in] event_base the event base that identifies the event 158 | * @param[in] event_id the event id that identifies the event 159 | * @param[in] event_data the data, specific to the event occurence, that gets passed to the handler 160 | * @param[in] event_data_size the size of the event data 161 | * @param[in] ticks_to_wait number of ticks to block on a full event queue 162 | * 163 | * @return ESP_OK : succeed 164 | * @return others : fail 165 | */ 166 | esp_err_t esp_event_send_internal(esp_event_base_t event_base, 167 | int32_t event_id, 168 | void* event_data, 169 | size_t event_data_size, 170 | TickType_t ticks_to_wait); 171 | 172 | /** 173 | * @brief Default event handler for system events 174 | * 175 | * @note This API is part of the legacy event system. New code should use event library API in esp_event.h 176 | * 177 | * This function performs default handling of system events. 178 | * When using esp_event_loop APIs, it is called automatically before invoking the user-provided 179 | * callback function. 180 | * 181 | * Applications which implement a custom event loop must call this function 182 | * as part of event processing. 183 | * 184 | * @param event pointer to event to be handled 185 | * @return ESP_OK if an event was handled successfully 186 | */ 187 | esp_err_t esp_event_process_default(system_event_t *event) __attribute__ ((deprecated)); 188 | 189 | /** 190 | * @brief Install default event handlers for Ethernet interface 191 | * 192 | * @note This API is part of the legacy event system. New code should use event library API in esp_event.h 193 | * 194 | */ 195 | void esp_event_set_default_eth_handlers(void); 196 | 197 | /** 198 | * @brief Install default event handlers for Wi-Fi interfaces (station and AP) 199 | * 200 | * @note This API is part of the legacy event system. New code should use event library API in esp_event.h 201 | */ 202 | void esp_event_set_default_wifi_handlers(void) __attribute__ ((deprecated)); 203 | 204 | /** 205 | * @brief Application specified event callback function 206 | * 207 | * @note This API is part of the legacy event system. New code should use event library API in esp_event.h 208 | * 209 | * 210 | * @param ctx reserved for user 211 | * @param event event type defined in this file 212 | * 213 | * @return 214 | * - ESP_OK: succeed 215 | * - others: fail 216 | */ 217 | typedef esp_err_t (*system_event_cb_t)(void *ctx, system_event_t *event); 218 | 219 | /** 220 | * @brief Initialize event loop 221 | * 222 | * @note This API is part of the legacy event system. New code should use event library API in esp_event.h 223 | * 224 | * Create the event handler and task 225 | * 226 | * @param cb application specified event callback, it can be modified by call esp_event_set_cb 227 | * @param ctx reserved for user 228 | * 229 | * @return 230 | * - ESP_OK: succeed 231 | * - others: fail 232 | */ 233 | esp_err_t esp_event_loop_init(system_event_cb_t cb, void *ctx) __attribute__ ((deprecated)); 234 | 235 | /** 236 | * @brief Set application specified event callback function 237 | * 238 | * @note This API is part of the legacy event system. New code should use event library API in esp_event.h 239 | * 240 | * @attention 1. If cb is NULL, means application don't need to handle 241 | * If cb is not NULL, it will be call when an event is received, after the default event callback is completed 242 | * 243 | * @param cb application callback function 244 | * @param ctx argument to be passed to callback 245 | * 246 | * 247 | * @return old callback 248 | */ 249 | system_event_cb_t esp_event_loop_set_cb(system_event_cb_t cb, void *ctx) __attribute__ ((deprecated)); 250 | 251 | #ifdef __cplusplus 252 | } 253 | #endif 254 | -------------------------------------------------------------------------------- /blobs/headers/esp_timer.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2017-2022 Espressif Systems (Shanghai) CO LTD 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | 7 | #pragma once 8 | 9 | /** 10 | * @file esp_timer.h 11 | * @brief microsecond-precision 64-bit timer API, replacement for ets_timer 12 | * 13 | * esp_timer APIs allow components to receive callbacks when a hardware timer 14 | * reaches certain value. The timer provides microsecond accuracy and 15 | * up to 64 bit range. Note that while the timer itself provides microsecond 16 | * accuracy, callbacks are dispatched from an auxiliary task. Some time is 17 | * needed to notify this task from timer ISR, and then to invoke the callback. 18 | * If more than one callback needs to be dispatched at any particular time, 19 | * each subsequent callback will be dispatched only when the previous callback 20 | * returns. Therefore, callbacks should not do much work; instead, they should 21 | * use RTOS notification mechanisms (queues, semaphores, event groups, etc.) to 22 | * pass information to other tasks. 23 | * 24 | * To be implemented: it should be possible to request the callback to be called 25 | * directly from the ISR. This reduces the latency, but has potential impact on 26 | * all other callbacks which need to be dispatched. This option should only be 27 | * used for simple callback functions, which do not take longer than a few 28 | * microseconds to run. 29 | * 30 | * Timer callbacks are called from a task running on the PRO CPU. 31 | */ 32 | 33 | #include 34 | #include 35 | #include 36 | #include "esp_err.h" 37 | #include "esp_etm.h" 38 | #include "sdkconfig.h" 39 | 40 | #ifdef __cplusplus 41 | extern "C" { 42 | #endif 43 | 44 | /** 45 | * @brief Opaque type representing a single esp_timer 46 | */ 47 | typedef struct esp_timer* esp_timer_handle_t; 48 | 49 | /** 50 | * @brief Timer callback function type 51 | * @param arg pointer to opaque user-specific data 52 | */ 53 | typedef void (*esp_timer_cb_t)(void* arg); 54 | 55 | 56 | /** 57 | * @brief Method for dispatching timer callback 58 | */ 59 | typedef enum { 60 | ESP_TIMER_TASK, //!< Callback is called from timer task 61 | #ifdef CONFIG_ESP_TIMER_SUPPORTS_ISR_DISPATCH_METHOD 62 | ESP_TIMER_ISR, //!< Callback is called from timer ISR 63 | #endif 64 | ESP_TIMER_MAX, //!< Count of the methods for dispatching timer callback 65 | } esp_timer_dispatch_t; 66 | 67 | /** 68 | * @brief Timer configuration passed to esp_timer_create 69 | */ 70 | typedef struct { 71 | esp_timer_cb_t callback; //!< Function to call when timer expires 72 | void* arg; //!< Argument to pass to the callback 73 | esp_timer_dispatch_t dispatch_method; //!< Call the callback from task or from ISR 74 | const char* name; //!< Timer name, used in esp_timer_dump function 75 | bool skip_unhandled_events; //!< Skip unhandled events for periodic timers 76 | } esp_timer_create_args_t; 77 | 78 | 79 | /** 80 | * @brief Minimal initialization of esp_timer 81 | * 82 | * @note This function is called from startup code. Applications do not need 83 | * to call this function before using other esp_timer APIs. 84 | * 85 | * This function can be called very early in startup process, after this call 86 | * only esp_timer_get_time function can be used. 87 | * 88 | * @return 89 | * - ESP_OK on success 90 | */ 91 | esp_err_t esp_timer_early_init(void); 92 | 93 | /** 94 | * @brief Initialize esp_timer library 95 | * 96 | * @note This function is called from startup code. Applications do not need 97 | * to call this function before using other esp_timer APIs. 98 | * Before calling this function, esp_timer_early_init must be called by the 99 | * startup code. 100 | * 101 | * This function will be called from startup code on every core 102 | * if CONFIG_ESP_TIMER_ISR_AFFINITY_NO_AFFINITY is enabled, 103 | * It allocates the timer ISR on MULTIPLE cores and 104 | * creates the timer task which can be run on any core. 105 | * 106 | * @return 107 | * - ESP_OK on success 108 | * - ESP_ERR_NO_MEM if allocation has failed 109 | * - ESP_ERR_INVALID_STATE if already initialized 110 | * - other errors from interrupt allocator 111 | */ 112 | esp_err_t esp_timer_init(void); 113 | 114 | /** 115 | * @brief De-initialize esp_timer library 116 | * 117 | * @note Normally this function should not be called from applications 118 | * 119 | * @return 120 | * - ESP_OK on success 121 | * - ESP_ERR_INVALID_STATE if not yet initialized 122 | */ 123 | esp_err_t esp_timer_deinit(void); 124 | 125 | /** 126 | * @brief Create an esp_timer instance 127 | * 128 | * @note When done using the timer, delete it with esp_timer_delete function. 129 | * 130 | * @param create_args Pointer to a structure with timer creation arguments. 131 | * Not saved by the library, can be allocated on the stack. 132 | * @param[out] out_handle Output, pointer to esp_timer_handle_t variable which 133 | * will hold the created timer handle. 134 | * 135 | * @return 136 | * - ESP_OK on success 137 | * - ESP_ERR_INVALID_ARG if some of the create_args are not valid 138 | * - ESP_ERR_INVALID_STATE if esp_timer library is not initialized yet 139 | * - ESP_ERR_NO_MEM if memory allocation fails 140 | */ 141 | esp_err_t esp_timer_create(const esp_timer_create_args_t* create_args, 142 | esp_timer_handle_t* out_handle); 143 | 144 | /** 145 | * @brief Start one-shot timer 146 | * 147 | * Timer should not be running when this function is called. 148 | * 149 | * @param timer timer handle created using esp_timer_create 150 | * @param timeout_us timer timeout, in microseconds relative to the current moment 151 | * @return 152 | * - ESP_OK on success 153 | * - ESP_ERR_INVALID_ARG if the handle is invalid 154 | * - ESP_ERR_INVALID_STATE if the timer is already running 155 | */ 156 | esp_err_t esp_timer_start_once(esp_timer_handle_t timer, uint64_t timeout_us); 157 | 158 | /** 159 | * @brief Start a periodic timer 160 | * 161 | * Timer should not be running when this function is called. This function will 162 | * start the timer which will trigger every 'period' microseconds. 163 | * 164 | * @param timer timer handle created using esp_timer_create 165 | * @param period timer period, in microseconds 166 | * @return 167 | * - ESP_OK on success 168 | * - ESP_ERR_INVALID_ARG if the handle is invalid 169 | * - ESP_ERR_INVALID_STATE if the timer is already running 170 | */ 171 | esp_err_t esp_timer_start_periodic(esp_timer_handle_t timer, uint64_t period); 172 | 173 | /** 174 | * @brief Restart a currently running timer 175 | * 176 | * If the given timer is a one-shot timer, the timer is restarted immediately and will timeout once in `timeout_us` microseconds. 177 | * If the given timer is a periodic timer, the timer is restarted immediately with a new period of `timeout_us` microseconds. 178 | * 179 | * @param timer timer Handle created using esp_timer_create 180 | * @param timeout_us Timeout, in microseconds relative to the current time. 181 | * In case of a periodic timer, also represents the new period. 182 | * @return 183 | * - ESP_OK on success 184 | * - ESP_ERR_INVALID_ARG if the handle is invalid 185 | * - ESP_ERR_INVALID_STATE if the timer is not running 186 | */ 187 | esp_err_t esp_timer_restart(esp_timer_handle_t timer, uint64_t timeout_us); 188 | 189 | /** 190 | * @brief Stop the timer 191 | * 192 | * This function stops the timer previously started using esp_timer_start_once 193 | * or esp_timer_start_periodic. 194 | * 195 | * @param timer timer handle created using esp_timer_create 196 | * @return 197 | * - ESP_OK on success 198 | * - ESP_ERR_INVALID_STATE if the timer is not running 199 | */ 200 | esp_err_t esp_timer_stop(esp_timer_handle_t timer); 201 | 202 | /** 203 | * @brief Delete an esp_timer instance 204 | * 205 | * The timer must be stopped before deleting. A one-shot timer which has expired 206 | * does not need to be stopped. 207 | * 208 | * @param timer timer handle allocated using esp_timer_create 209 | * @return 210 | * - ESP_OK on success 211 | * - ESP_ERR_INVALID_STATE if the timer is running 212 | */ 213 | esp_err_t esp_timer_delete(esp_timer_handle_t timer); 214 | 215 | /** 216 | * @brief Get time in microseconds since boot 217 | * @return number of microseconds since underlying timer has been started 218 | */ 219 | int64_t esp_timer_get_time(void); 220 | 221 | /** 222 | * @brief Get the timestamp when the next timeout is expected to occur 223 | * @return Timestamp of the nearest timer event, in microseconds. 224 | * The timebase is the same as for the values returned by esp_timer_get_time. 225 | */ 226 | int64_t esp_timer_get_next_alarm(void); 227 | 228 | /** 229 | * @brief Get the timestamp when the next timeout is expected to occur skipping those which have skip_unhandled_events flag 230 | * @return Timestamp of the nearest timer event, in microseconds. 231 | * The timebase is the same as for the values returned by esp_timer_get_time. 232 | */ 233 | int64_t esp_timer_get_next_alarm_for_wake_up(void); 234 | 235 | /** 236 | * @brief Get the period of a timer 237 | * 238 | * This function fetches the timeout period of a timer. 239 | * 240 | * @note The timeout period is the time interval with which a timer restarts after expiry. For one-shot timers, the 241 | * period is 0 as there is no periodicity associated with such timers. 242 | * 243 | * @param timer timer handle allocated using esp_timer_create 244 | * @param period memory to store the timer period value in microseconds 245 | * @return 246 | * - ESP_OK on success 247 | * - ESP_ERR_INVALID_ARG if the arguments are invalid 248 | */ 249 | esp_err_t esp_timer_get_period(esp_timer_handle_t timer, uint64_t *period); 250 | 251 | /** 252 | * @brief Get the expiry time of a one-shot timer 253 | * 254 | * This function fetches the expiry time of a one-shot timer. 255 | * 256 | * @note This API returns a valid expiry time only for a one-shot timer. It returns an error if the timer handle passed 257 | * to the function is for a periodic timer. 258 | * 259 | * @param timer timer handle allocated using esp_timer_create 260 | * @param expiry memory to store the timeout value in microseconds 261 | * @return 262 | * - ESP_OK on success 263 | * - ESP_ERR_INVALID_ARG if the arguments are invalid 264 | * - ESP_ERR_NOT_SUPPORTED if the timer type is periodic 265 | */ 266 | esp_err_t esp_timer_get_expiry_time(esp_timer_handle_t timer, uint64_t *expiry); 267 | 268 | /** 269 | * @brief Dump the list of timers to a stream 270 | * 271 | * If CONFIG_ESP_TIMER_PROFILING option is enabled, this prints the list of all 272 | * the existing timers. Otherwise, only the list active timers is printed. 273 | * 274 | * The format is: 275 | * 276 | * name period alarm times_armed times_triggered total_callback_run_time 277 | * 278 | * where: 279 | * 280 | * name — timer name (if CONFIG_ESP_TIMER_PROFILING is defined), or timer pointer 281 | * period — period of timer, in microseconds, or 0 for one-shot timer 282 | * alarm - time of the next alarm, in microseconds since boot, or 0 if the timer 283 | * is not started 284 | * 285 | * The following fields are printed if CONFIG_ESP_TIMER_PROFILING is defined: 286 | * 287 | * times_armed — number of times the timer was armed via esp_timer_start_X 288 | * times_triggered - number of times the callback was called 289 | * total_callback_run_time - total time taken by callback to execute, across all calls 290 | * 291 | * @param stream stream (such as stdout) to dump the information to 292 | * @return 293 | * - ESP_OK on success 294 | * - ESP_ERR_NO_MEM if can not allocate temporary buffer for the output 295 | */ 296 | esp_err_t esp_timer_dump(FILE* stream); 297 | 298 | #if CONFIG_ESP_TIMER_SUPPORTS_ISR_DISPATCH_METHOD || defined __DOXYGEN__ 299 | /** 300 | * @brief Requests a context switch from a timer callback function. 301 | * 302 | * This only works for a timer that has an ISR dispatch method. 303 | * The context switch will be called after all ISR dispatch timers have been processed. 304 | */ 305 | void esp_timer_isr_dispatch_need_yield(void); 306 | #endif // CONFIG_ESP_TIMER_SUPPORTS_ISR_DISPATCH_METHOD || defined __DOXYGEN__ 307 | 308 | /** 309 | * @brief Returns status of a timer, active or not 310 | * 311 | * This function is used to identify if the timer is still active or not. 312 | * 313 | * @param timer timer handle created using esp_timer_create 314 | * @return 315 | * - 1 if timer is still active 316 | * - 0 if timer is not active. 317 | */ 318 | bool esp_timer_is_active(esp_timer_handle_t timer); 319 | 320 | /** 321 | * @brief Get the ETM event handle of esp_timer underlying alarm event 322 | * 323 | * @note The created ETM event object can be deleted later by calling `esp_etm_del_event` 324 | * 325 | * @note The ETM event is generated by the underlying hardware -- systimer, 326 | * therefore, if the esp_timer is not clocked by systimer, then no ETM event will be generated. 327 | * 328 | * @param[out] out_event Returned ETM event handle 329 | * @return 330 | * - ESP_OK Success 331 | * - ESP_ERR_INVALID_ARG Parameter error 332 | */ 333 | esp_err_t esp_timer_new_etm_alarm_event(esp_etm_event_handle_t *out_event); 334 | 335 | #ifdef __cplusplus 336 | } 337 | #endif 338 | -------------------------------------------------------------------------------- /blobs/headers/esp_wpa2.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2019-2021 Espressif Systems (Shanghai) CO LTD 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | 7 | #ifndef _ESP_WPA2_H 8 | #define _ESP_WPA2_H 9 | 10 | #pragma message("esp_wpa2.h is deprecated. Use esp_eap_client.h instead.") 11 | 12 | #include "esp_eap_client.h" 13 | 14 | /** 15 | * @brief Enable wpa2 enterprise authentication. 16 | * 17 | * @deprecated This function is deprecated and will be removed in the future. 18 | * Please use `esp_wifi_sta_enterprise_enable()` instead. 19 | * 20 | * @attention 1. wpa2 enterprise authentication can only be used when station mode is enabled. 21 | * @attention 2. wpa2 enterprise authentication supports EAP-FAST, TLS, PEAP, TTLS(EAP, MSCHAPv2, MSCHAP, PAP, CHAP) methods. 22 | * 23 | * @return 24 | * - ESP_OK: succeed. 25 | * - ESP_ERR_NO_MEM: fail(internal memory malloc fail) 26 | */ 27 | __attribute__((deprecated("Use 'esp_wifi_sta_enterprise_enable' instead"))) 28 | esp_err_t esp_wifi_sta_wpa2_ent_enable(void); 29 | 30 | /** 31 | * @brief Disable wpa2 enterprise authentication. 32 | * 33 | * @deprecated This function is deprecated and will be removed in the future. 34 | * Please use `esp_wifi_sta_enterprise_disable()` instead. 35 | * 36 | * @attention 1. wpa2 enterprise authentication can only be used when station mode is enabled. 37 | * @attention 2. wpa2 enterprise authentication supports EAP-FAST, TLS, PEAP, TTLS(EAP, MSCHAPv2, MSCHAP, PAP, CHAP) methods. 38 | * 39 | * @return 40 | * - ESP_OK: succeed. 41 | */ 42 | __attribute__((deprecated("Use 'esp_wifi_sta_enterprise_disable' instead"))) 43 | esp_err_t esp_wifi_sta_wpa2_ent_disable(void); 44 | 45 | /** 46 | * @brief Set identity for PEAP/TTLS method. 47 | * 48 | * @deprecated This function is deprecated and will be removed in the future. 49 | * Please use `esp_eap_client_set_identity` instead. 50 | * 51 | * @attention The API only passes the parameter identity to the global pointer variable in wpa2 enterprise module. 52 | * 53 | * @param identity: point to address where stores the identity; 54 | * @param len: length of identity, limited to 1~127 55 | * 56 | * @return 57 | * - ESP_OK: succeed 58 | * - ESP_ERR_INVALID_ARG: fail(len <= 0 or len >= 128) 59 | * - ESP_ERR_NO_MEM: fail(internal memory malloc fail) 60 | */ 61 | __attribute__((deprecated("Use 'esp_eap_client_set_identity' instead"))) 62 | esp_err_t esp_wifi_sta_wpa2_ent_set_identity(const unsigned char *identity, int len); 63 | 64 | /** 65 | * @brief Clear identity for PEAP/TTLS method. 66 | * 67 | * @deprecated This function is deprecated and will be removed in the future. 68 | * Please use `esp_eap_client_clear_identity` instead. 69 | * 70 | */ 71 | __attribute__((deprecated("Use 'esp_eap_client_clear_identity' instead"))) 72 | void esp_wifi_sta_wpa2_ent_clear_identity(void); 73 | 74 | /** 75 | * @brief Set username for PEAP/TTLS method. 76 | * 77 | * @deprecated This function is deprecated and will be removed in the future. 78 | * Please use `esp_eap_client_set_username` instead. 79 | * 80 | * @param username: point to address where stores the username; 81 | * @param len: length of username, limited to 1~127 82 | * 83 | * @return 84 | * - ESP_OK: succeed 85 | * - ESP_ERR_INVALID_ARG: fail(len <= 0 or len >= 128) 86 | * - ESP_ERR_NO_MEM: fail(internal memory malloc fail) 87 | */ 88 | __attribute__((deprecated("Use 'esp_eap_client_set_username' instead"))) 89 | esp_err_t esp_wifi_sta_wpa2_ent_set_username(const unsigned char *username, int len); 90 | 91 | /** 92 | * @brief Clear username for PEAP/TTLS method. 93 | * @deprecated This function is deprecated and will be removed in the future. 94 | * Please use `esp_eap_client_clear_username` instead. 95 | * 96 | */ 97 | __attribute__((deprecated("Use 'esp_eap_client_clear_username' instead"))) 98 | void esp_wifi_sta_wpa2_ent_clear_username(void); 99 | 100 | /** 101 | * @brief Set password for PEAP/TTLS method.. 102 | * 103 | * @deprecated This function is deprecated and will be removed in the future. 104 | * Please use `esp_eap_client_set_password` instead. 105 | * 106 | * @param password: point to address where stores the password; 107 | * @param len: length of password(len > 0) 108 | * 109 | * @return 110 | * - ESP_OK: succeed 111 | * - ESP_ERR_INVALID_ARG: fail(len <= 0) 112 | * - ESP_ERR_NO_MEM: fail(internal memory malloc fail) 113 | */ 114 | __attribute__((deprecated("Use 'esp_eap_client_set_password' instead"))) 115 | esp_err_t esp_wifi_sta_wpa2_ent_set_password(const unsigned char *password, int len); 116 | 117 | /** 118 | * @brief Clear password for PEAP/TTLS method.. 119 | * 120 | * @deprecated This function is deprecated and will be removed in the future. 121 | * Please use `esp_eap_client_clear_password` instead. 122 | */ 123 | __attribute__((deprecated("Use 'esp_eap_client_clear_password' instead"))) 124 | void esp_wifi_sta_wpa2_ent_clear_password(void); 125 | 126 | /** 127 | * @brief Set new password for MSCHAPv2 method.. 128 | * 129 | * @deprecated This function is deprecated and will be removed in the future. 130 | * Please use `esp_eap_client_set_new_password` instead. 131 | * 132 | * @attention 1. The new password is used to substitute the old password when eap-mschapv2 failure request message with error code ERROR_PASSWD_EXPIRED is received. 133 | * 134 | * @param new_password: point to address where stores the password; 135 | * @param len: length of password 136 | * 137 | * @return 138 | * - ESP_OK: succeed 139 | * - ESP_ERR_INVALID_ARG: fail(len <= 0) 140 | * - ESP_ERR_NO_MEM: fail(internal memory malloc fail) 141 | */ 142 | __attribute__((deprecated("Use 'esp_eap_client_set_new_password' instead"))) 143 | esp_err_t esp_wifi_sta_wpa2_ent_set_new_password(const unsigned char *new_password, int len); 144 | 145 | /** 146 | * @brief Clear new password for MSCHAPv2 method.. 147 | * 148 | * @deprecated This function is deprecated and will be removed in the future. 149 | * Please use `esp_eap_client_clear_new_password` instead. 150 | * 151 | */ 152 | __attribute__((deprecated("Use 'esp_eap_client_clear_new_password' instead"))) 153 | void esp_wifi_sta_wpa2_ent_clear_new_password(void); 154 | 155 | /** 156 | * @brief Set CA certificate for PEAP/TTLS method. 157 | * 158 | * @deprecated This function is deprecated and will be removed in the future. 159 | * Please use `esp_eap_client_set_ca_cert` instead. 160 | * 161 | * @attention 1. The API only passes the parameter ca_cert to the global pointer variable in wpa2 enterprise module. 162 | * @attention 2. The ca_cert should be zero terminated. 163 | * 164 | * @param ca_cert: point to address where stores the CA certificate; 165 | * @param ca_cert_len: length of ca_cert 166 | * 167 | * @return 168 | * - ESP_OK: succeed 169 | */ 170 | __attribute__((deprecated("Use 'esp_eap_client_set_ca_cert' instead"))) 171 | esp_err_t esp_wifi_sta_wpa2_ent_set_ca_cert(const unsigned char *ca_cert, int ca_cert_len); 172 | 173 | /** 174 | * @brief Clear CA certificate for PEAP/TTLS method. 175 | * 176 | * @deprecated This function is deprecated and will be removed in the future. 177 | * Please use `esp_eap_client_clear_ca_cert` instead. 178 | * 179 | */ 180 | __attribute__((deprecated("Use 'esp_eap_client_clear_ca_cert' instead"))) 181 | void esp_wifi_sta_wpa2_ent_clear_ca_cert(void); 182 | 183 | /** 184 | * @brief Set client certificate and key. 185 | * 186 | * @deprecated This function is deprecated and will be removed in the future. 187 | * Please use `esp_eap_client_set_certificate_and_key` instead. 188 | * 189 | * @attention 1. The API only passes the parameter client_cert, private_key and private_key_passwd to the global pointer variable in wpa2 enterprise module. 190 | * @attention 2. The client_cert, private_key and private_key_passwd should be zero terminated. 191 | * 192 | * @param client_cert: point to address where stores the client certificate; 193 | * @param client_cert_len: length of client certificate; 194 | * @param private_key: point to address where stores the private key; 195 | * @param private_key_len: length of private key, limited to 1~2048; 196 | * @param private_key_password: point to address where stores the private key password; 197 | * @param private_key_password_len: length of private key password; 198 | * 199 | * @return 200 | * - ESP_OK: succeed 201 | */ 202 | __attribute__((deprecated("Use 'esp_eap_client_set_certificate_and_key' instead"))) 203 | esp_err_t esp_wifi_sta_wpa2_ent_set_cert_key(const unsigned char *client_cert, int client_cert_len, 204 | const unsigned char *private_key, int private_key_len, 205 | const unsigned char *private_key_passwd, int private_key_passwd_len); 206 | 207 | /** 208 | * @brief Clear client certificate and key. 209 | * 210 | * @deprecated This function is deprecated and will be removed in the future. 211 | * Please use `esp_eap_client_clear_certificate_and_key` instead. 212 | * 213 | */ 214 | __attribute__((deprecated("Use 'esp_eap_client_clear_certificate_and_key' instead"))) 215 | void esp_wifi_sta_wpa2_ent_clear_cert_key(void); 216 | 217 | /** 218 | * @brief Set wpa2 enterprise certs time check(disable or not). 219 | * 220 | * @deprecated This function is deprecated and will be removed in the future. 221 | * Please use `esp_eap_client_set_disable_time_check` instead. 222 | * 223 | * @param true: disable wpa2 enterprise certs time check 224 | * @param false: enable wpa2 enterprise certs time check 225 | * 226 | * @return 227 | * - ESP_OK: succeed 228 | */ 229 | __attribute__((deprecated("Use 'esp_eap_client_set_disable_time_check' instead"))) 230 | esp_err_t esp_wifi_sta_wpa2_ent_set_disable_time_check(bool disable); 231 | 232 | /** 233 | * @brief Get wpa2 enterprise certs time check(disable or not). 234 | * 235 | * @deprecated This function is deprecated and will be removed in the future. 236 | * Please use `esp_eap_client_get_disable_time_check` instead. 237 | * 238 | * @param disable: store disable value 239 | * 240 | * @return 241 | * - ESP_OK: succeed 242 | */ 243 | __attribute__((deprecated("Use 'esp_eap_client_get_disable_time_check' instead"))) 244 | esp_err_t esp_wifi_sta_wpa2_ent_get_disable_time_check(bool *disable); 245 | 246 | /** 247 | * @brief Set wpa2 enterprise ttls phase2 method 248 | * 249 | * @deprecated This function is deprecated and will be removed in the future. 250 | * Please use `esp_eap_client_set_ttls_phase2_method` instead. 251 | * 252 | * @param type: the type of phase 2 method to be used 253 | * 254 | * @return 255 | * - ESP_OK: succeed 256 | */ 257 | __attribute__((deprecated("Use 'esp_eap_client_set_ttls_phase2_method' instead"))) 258 | esp_err_t esp_wifi_sta_wpa2_ent_set_ttls_phase2_method(esp_eap_ttls_phase2_types type); 259 | 260 | /** 261 | * @brief enable/disable 192 bit suite b certification checks 262 | * 263 | * @deprecated This function is deprecated and will be removed in the future. 264 | * Please use `esp_eap_client_set_suiteb_192bit_certification` instead. 265 | * 266 | * @param enable: bool to enable/disable it. 267 | * 268 | * @return 269 | * - ESP_OK: succeed 270 | */ 271 | __attribute__((deprecated("Use 'esp_eap_client_set_suiteb_192bit_certification' instead"))) 272 | esp_err_t esp_wifi_sta_wpa2_set_suiteb_192bit_certification(bool enable); 273 | 274 | /** 275 | * @brief Set client pac file 276 | * 277 | * @deprecated This function is deprecated and will be removed in the future. 278 | * Please use `esp_eap_client_set_pac_file` instead. 279 | * 280 | * @attention 1. For files read from the file system, length has to be decremented by 1 byte. 281 | * @attention 2. Disabling the ESP_WIFI_MBEDTLS_TLS_CLIENT config is required to use EAP-FAST. 282 | * 283 | * @param pac_file: pointer to the pac file 284 | * pac_file_len: length of the pac file 285 | * 286 | * @return 287 | * - ESP_OK: succeed 288 | * - ESP_ERR_NO_MEM: fail(internal memory malloc fail) 289 | */ 290 | __attribute__((deprecated("Use 'esp_eap_client_set_pac_file' instead"))) 291 | esp_err_t esp_wifi_sta_wpa2_ent_set_pac_file(const unsigned char *pac_file, int pac_file_len); 292 | 293 | /** 294 | * @brief Set Phase 1 parameters for EAP-FAST 295 | * 296 | * @deprecated This function is deprecated and will be removed in the future. 297 | * Please use `esp_eap_client_set_fast_params` instead. 298 | * 299 | * @attention 1. Disabling the ESP_WIFI_MBEDTLS_TLS_CLIENT config is required to use EAP-FAST. 300 | * 301 | * @param config: eap fast phase 1 configuration 302 | * 303 | * @return 304 | * - ESP_OK: succeed 305 | * - ESP_ERR_INVALID_ARG: fail(out of bound arguments) 306 | * - ESP_ERR_NO_MEM: fail(internal memory malloc fail) 307 | */ 308 | __attribute__((deprecated("Use 'esp_eap_client_set_fast_params' instead"))) 309 | esp_err_t esp_wifi_sta_wpa2_ent_set_fast_phase1_params(esp_eap_fast_config config); 310 | 311 | /** 312 | * @brief Use default CA cert bundle for server validation 313 | * 314 | * @deprecated This function is deprecated and will be removed in the future. 315 | * Please use `esp_eap_client_use_default_cert_bundle` instead. 316 | * 317 | * @use_default_bundle : whether to use bundle or not 318 | * 319 | * @return 320 | * - ESP_OK: succeed 321 | * - ESP_FAIL: fail 322 | */ 323 | __attribute__((deprecated("Use 'esp_eap_client_use_default_cert_bundle' instead"))) 324 | esp_err_t esp_wifi_sta_wpa2_use_default_cert_bundle(bool use_default_bundle); 325 | 326 | #ifdef __cplusplus 327 | } 328 | #endif 329 | #endif 330 | -------------------------------------------------------------------------------- /blobs/include/esp_wifi_he_types.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | 7 | #pragma once 8 | 9 | #include 10 | #include 11 | #include "esp_err.h" 12 | 13 | #ifdef __cplusplus 14 | extern "C" { 15 | #endif 16 | 17 | /** 18 | * @brief Access category 19 | */ 20 | typedef enum { 21 | ESP_WIFI_ACI_VO, /**< voice traffic */ 22 | ESP_WIFI_ACI_VI, /**< video traffic */ 23 | ESP_WIFI_ACI_BE, /**< best effort traffic */ 24 | ESP_WIFI_ACI_BK, /**< background traffic */ 25 | ESP_WIFI_ACI_MAX, /**< the max value */ 26 | } esp_wifi_aci_t; 27 | 28 | /** 29 | * @brief Channel state information(CSI) HE STBC CSI selection 30 | */ 31 | enum { 32 | ESP_CSI_ACQUIRE_STBC_HELTF1, /**< HE STBC: select the first HE-LTF */ 33 | ESP_CSI_ACQUIRE_STBC_HELTF2, /**< HE STBC: select the second HE-LTF */ 34 | ESP_CSI_ACQUIRE_STBC_SAMPLE_HELTFS, /**< HE STBC: sample alternating scarier of HE-LTF1 and HE-LTF2 */ 35 | }; 36 | 37 | /** 38 | * @brief Channel state information(CSI) configuration type 39 | */ 40 | typedef struct { 41 | uint32_t enable : 1; /**< enable to acquire CSI */ 42 | uint32_t acquire_csi_legacy : 1; /**< enable to acquire L-LTF when receiving a 11g PPDU */ 43 | uint32_t acquire_csi_ht20 : 1; /**< enable to acquire HT-LTF when receiving an HT20 PPDU */ 44 | uint32_t acquire_csi_ht40 : 1; /**< enable to acquire HT-LTF when receiving an HT40 PPDU */ 45 | uint32_t acquire_csi_su : 1; /**< enable to acquire HE-LTF when receiving an HE20 SU PPDU */ 46 | uint32_t acquire_csi_mu : 1; /**< enable to acquire HE-LTF when receiving an HE20 MU PPDU */ 47 | uint32_t acquire_csi_dcm : 1; /**< enable to acquire HE-LTF when receiving an HE20 DCM applied PPDU */ 48 | uint32_t acquire_csi_beamformed : 1; /**< enable to acquire HE-LTF when receiving an HE20 Beamformed applied PPDU */ 49 | uint32_t acquire_csi_he_stbc : 2; /**< when receiving an STBC applied HE PPDU, 50 | 0- acquire the complete HE-LTF1, 51 | 1- acquire the complete HE-LTF2 52 | 2- sample evenly among the HE-LTF1 and HE-LTF2 */ 53 | uint32_t val_scale_cfg : 2; /**< value 0-3 */ 54 | uint32_t reserved : 20; /**< reserved */ 55 | } wifi_csi_acquire_config_t; 56 | 57 | /** 58 | * @brief HE variant HT Control field including UPH(UL power headroom) and OM(Operation mode) 59 | */ 60 | typedef struct { 61 | uint32_t id : 2; /**< HE Variant ID = 3 */ 62 | uint32_t uph_id : 4; /**< UPH control ID: 4 */ 63 | uint32_t ul_pw_headroom : 5; /**< the available UL power headroom for the current HE-MCS, unit: dB, value[0, 31] */ 64 | uint32_t min_tx_pw_flag : 1; /**< indicate that the min. transmit power for current HE-MCS is reached, set to 0 otherwise */ 65 | uint32_t rsvd : 2; /**< reserved */ 66 | uint32_t ctrl_id : 4; /**< OM control ID: 1 */ 67 | uint32_t rx_nss : 3; /**< the max. number of spatial streams for the reception, only accept 0. */ 68 | uint32_t bw : 2; /**< the operating channel width for both reception and transmission, only accept 0. */ 69 | uint32_t ul_mu_disable : 1; /**< disable UL MU operations */ 70 | uint32_t tx_nsts : 3; /**< the max. number of spatial streams for the transmission, only accept 0. */ 71 | uint32_t er_su_disable : 1; /**< disable the reception of 242-tone HE ER SU PPDU */ 72 | uint32_t dl_mu_mimo_resounding_recommendation : 1; /**< indicate the STA suggests the AP either resounding the channel or increase the channel sounding frequency with the STA */ 73 | uint32_t ul_mu_data_disable : 1; /**< disable UL MU data operations */ 74 | uint32_t padding : 2; /**< padding bits */ 75 | } esp_wifi_htc_omc_t; 76 | 77 | /** 78 | * @brief TWT setup commands 79 | */ 80 | typedef enum { 81 | TWT_REQUEST, /**< request to join a TWT without providing a set of TWT parameters */ 82 | TWT_SUGGEST, /**< request to join a TWT and offer a set of preferred TWT parameters but might accept alternative TWT parameters */ 83 | TWT_DEMAND, /**< request to join a TWT and currently accept only the indicated TWT parameters */ 84 | TWT_GROUPING, /**< for S1G STA */ 85 | TWT_ACCEPT, /**< accept the TWT request with the TWT parameters, also used in unsolicited TWT response */ 86 | TWT_ALTERNATE, /**< indicate a counter-offer of TWT parameters without creation of a TWT agreement */ 87 | TWT_DICTATE, /**< indicate no TWT agreement is created, but one is likely to be accepted only if the requesting STA transmits a new TWT setup request with the indicated TWT parameters */ 88 | TWT_REJECT, /**< indicate that the negotiation has ended in failure to crate a new TWT agreement */ 89 | } wifi_twt_setup_cmds_t; 90 | 91 | /** 92 | * @brief HE SU GI and LTF types 93 | */ 94 | typedef enum { 95 | HE_SU_ERSU_1_LTF_0_8_US_GI, /**< 1 LTF and 0.8 us GI */ 96 | HE_SU_ERSU_2_LTF_0_8_US_GI, /**< 2 LTF and 0.8 us GI */ 97 | HE_SU_ERSU_2_LTF_1_6_US_GI, /**< 2 LTF and 1.6 us GI */ 98 | HE_SU_ERSU_4_LTF_3_2_US_GI, /**< 4 LTF and 3.2 us GI */ 99 | } he_su_gi_and_ltf_type_t; 100 | 101 | /** 102 | * @brief Reception format 103 | */ 104 | typedef enum { 105 | RX_BB_FORMAT_11B = 0, /**< the reception frame is a 11b MPDU */ 106 | RX_BB_FORMAT_11G = 1, /**< the reception frame is a 11g MPDU */ 107 | RX_BB_FORMAT_HT = 2, /**< the reception frame is a HT MPDU */ 108 | RX_BB_FORMAT_VHT = 3, /**< the reception frame is a VHT MPDU */ 109 | RX_BB_FORMAT_HE_SU = 4, /**< the reception frame is a HE SU MPDU */ 110 | RX_BB_FORMAT_HE_MU = 5, /**< the reception frame is a HE MU MPDU */ 111 | RX_BB_FORMAT_HE_ERSU = 6, /**< the reception frame is a HE ER SU MPDU */ 112 | RX_BB_FORMAT_HE_TB = 7, /**< the reception frame is a HE TB MPDU */ 113 | } wifi_rx_bb_format_t; 114 | 115 | /** 116 | * @brief RxControl Info 117 | */ 118 | typedef struct { 119 | signed rssi : 8; /**< the RSSI of the reception frame */ 120 | unsigned rate : 5; /**< if cur_bb_format is RX_BB_FORMAT_11B, it's the transmission rate. otherwise it's Rate field of L-SIG */ 121 | unsigned : 1; /**< reserved */ 122 | unsigned : 2; /**< reserved */ 123 | unsigned : 12; /**< reserved */ 124 | unsigned rxmatch0 : 1; /**< indicate whether the reception frame is from interface 0 */ 125 | unsigned rxmatch1 : 1; /**< indicate whether the reception frame is from interface 1 */ 126 | unsigned rxmatch2 : 1; /**< indicate whether the reception frame is from interface 2 */ 127 | unsigned rxmatch3 : 1; /**< indicate whether the reception frame is from interface 3 */ 128 | uint32_t he_siga1; /**< HE-SIGA1 or HT-SIG */ 129 | unsigned rxend_state : 8; /**< reception state, 0: successful, others: failure */ 130 | uint16_t he_siga2; /**< HE-SIGA2 */ 131 | unsigned : 7; /**< reserved */ 132 | unsigned is_group : 1; /**< indicate whether the reception is a group addressed frame */ 133 | unsigned : 32; /**< reserved */ 134 | unsigned : 15; /**< reserved */ 135 | unsigned : 15; /**< reserved */ 136 | unsigned : 2; /**< reserved */ 137 | unsigned noise_floor : 8; /**< the noise floor of the reception frame */ 138 | signed data_rssi : 8; /**< the RSSI of the DATA field */ 139 | unsigned : 8; /**< reserved */ 140 | unsigned : 8; /**< reserved */ 141 | unsigned channel : 4; /**< the primary channel */ 142 | unsigned second : 4; /**< the second channel if in HT40 */ 143 | unsigned : 24; /**< reserved */ 144 | unsigned : 32; /**< reserved */ 145 | unsigned : 2; /**< reserved */ 146 | unsigned : 4; /**< reserved */ 147 | unsigned : 2; /**< reserved */ 148 | unsigned rx_channel_estimate_len : 10; /**< the length of the channel information */ 149 | unsigned rx_channel_estimate_info_vld : 1; /**< indicate the channel information is valid */ 150 | unsigned : 1; /**< reserved */ 151 | unsigned : 11; /**< reserved */ 152 | unsigned : 1; /**< reserved */ 153 | unsigned : 24; /**< reserved */ 154 | unsigned cur_bb_format : 4; /**< the format of the reception frame */ 155 | unsigned cur_single_mpdu : 1; /**< indicate whether the reception MPDU is a S-MPDU */ 156 | unsigned : 3; /**< reserved */ 157 | unsigned : 32; /**< reserved */ 158 | unsigned : 32; /**< reserved */ 159 | unsigned : 32; /**< reserved */ 160 | unsigned : 32; /**< reserved */ 161 | unsigned : 32; /**< reserved */ 162 | unsigned : 32; /**< reserved */ 163 | unsigned : 32; /**< reserved */ 164 | unsigned : 32; /**< reserved */ 165 | unsigned : 8; /**< reserved */ 166 | unsigned he_sigb_len : 6; /**< the length of HE-SIGB */ 167 | unsigned : 2; /**< reserved */ 168 | unsigned : 8; /**< reserved */ 169 | unsigned : 8; /**< reserved */ 170 | unsigned : 32; /**< reserved */ 171 | unsigned : 7; /**< reserved */ 172 | unsigned : 1; /**< reserved */ 173 | unsigned : 8; /**< reserved */ 174 | unsigned : 16; /**< reserved */ 175 | unsigned sig_len : 14; /**< the length of the reception MPDU */ 176 | unsigned : 2; /**< reserved */ 177 | unsigned dump_len : 14; /**< the length of the reception MPDU excluding the FCS */ 178 | unsigned : 2; /**< reserved */ 179 | unsigned rx_state : 8; /**< reception state, 0: successful, others: failure */ 180 | unsigned : 24; /**< reserved */ 181 | } __attribute__((packed)) esp_wifi_rxctrl_t; 182 | 183 | /** Argument structure for WIFI_EVENT_TWT_SET_UP event */ 184 | typedef struct { 185 | wifi_twt_setup_cmds_t setup_cmd; /**< TWT setup command */ 186 | uint8_t flow_id; /**< flow id */ 187 | uint8_t min_wake_dura; /**< the min. wake duration, unit: 256 us by default */ 188 | uint8_t wake_invl_expn; /**< the exponent of the TWT wake interval in microseconds, base 2 */ 189 | uint16_t wake_invl_mant; /**< the value of the mantissa of the TWT wake interval value in microseconds, base 2 */ 190 | bool trigger; /**< true: indicates a trigger-enabled TWT, false: indicates a non-trigger-enabled TWT */ 191 | uint8_t flow_type; /**< 0: indicate an announced TWT, 1: indicates an unannounced TWT */ 192 | } wifi_event_sta_itwt_setup_t; 193 | 194 | /** Argument structure for WIFI_EVENT_TWT_TEARDOWN event */ 195 | typedef struct { 196 | uint8_t flow_id; /**< flow id */ 197 | } wifi_event_sta_itwt_teardown_t; 198 | 199 | /** 200 | * @brief iTWT probe status 201 | */ 202 | typedef enum { 203 | ITWT_PROBE_FAIL, /**< station sends probe request fail */ 204 | ITWT_PROBE_SUCCESS, /**< 1) station receives beacon from AP; 2) station receives probe response from AP */ 205 | ITWT_PROBE_TIMEOUT, /**< 1) timeout of receiving ACK in response of previously probe request sending by station 206 | 2) timeout of receiving probe response in response of previously probe request sending by station */ 207 | ITWT_PROBE_STA_DISCONNECTED, /**< station is not connected */ 208 | } wifi_itwt_probe_status_t; 209 | 210 | /** Argument structure for WIFI_EVENT_ITWT_SEND_PROBE event */ 211 | typedef struct { 212 | wifi_itwt_probe_status_t status; /**< probe status */ 213 | uint8_t reason; /**< failure reason */ 214 | } wifi_event_sta_itwt_probe_t; 215 | 216 | /** Argument structure for WIFI_EVENT_ITWT_SUSPEND event */ 217 | typedef struct { 218 | esp_err_t status; /**< suspend status */ 219 | uint8_t flow_id_bitmap; /**< bitmap of the suspended flow id */ 220 | uint32_t actual_suspend_time_ms[8]; /**< the actual suspend time for each flow id, unit: ms */ 221 | } wifi_event_sta_itwt_suspend_t; 222 | 223 | #ifdef __cplusplus 224 | } 225 | #endif 226 | --------------------------------------------------------------------------------