1 /* 2 * SPDX-FileCopyrightText: 2023-2024 Espressif Systems (Shanghai) CO LTD 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 */ 6 7 #pragma once 8 9 #ifdef __cplusplus 10 extern "C" { 11 #endif 12 13 #include <stdint.h> 14 #include <stdbool.h> 15 16 typedef enum { 17 //11b 18 PHY_RATE_1M = 0x0, 19 PHY_RATE_2M = 0x1, 20 PHY_RATE_5M5 = 0x2, 21 PHY_RATE_11M = 0x3, 22 //11g 23 PHY_RATE_6M = 0xb, 24 PHY_RATE_9M = 0xf, 25 PHY_RATE_12M = 0xa, 26 PHY_RATE_18M = 0xe, 27 PHY_RATE_24M = 0x9, 28 PHY_RATE_36M = 0xd, 29 PHY_RATE_48M = 0x8, 30 PHY_RATE_54M = 0xc, 31 //11n 32 PHY_RATE_MCS0 = 0x10, 33 PHY_RATE_MCS1 = 0x11, 34 PHY_RATE_MCS2 = 0x12, 35 PHY_RATE_MCS3 = 0x13, 36 PHY_RATE_MCS4 = 0x14, 37 PHY_RATE_MCS5 = 0x15, 38 PHY_RATE_MCS6 = 0x16, 39 PHY_RATE_MCS7 = 0x17, 40 PHY_WIFI_RATE_MAX 41 } esp_phy_wifi_rate_t; 42 43 typedef enum { 44 PHY_BLE_RATE_1M = 0, 45 PHY_BLE_RATE_2M, 46 PHY_BLE_RATE_125K, 47 PHY_BLE_RATE_500k, 48 PHY_BLE_RATE_MAX 49 } esp_phy_ble_rate_t; 50 51 typedef enum { 52 PHY_BLE_TYPE_1010 = 0, 53 PHY_BLE_TYPE_00001111 = 1, 54 PHY_BLE_TYPE_prbs9 = 2, 55 PHY_BLE_TYPE_00111100 = 4, 56 PHY_BLE_TYPE_MAX 57 } esp_phy_ble_type_t; 58 59 /** 60 * @brief Structure holding PHY RX result 61 */ 62 typedef struct { 63 uint32_t phy_rx_correct_count; /*!< The number of desired packets received */ 64 int phy_rx_rssi; /*!< Average RSSI of desired packets */ 65 uint32_t phy_rx_total_count; /*!< The number of total packets received */ 66 uint32_t phy_rx_result_flag; /*!< 0 means no RX info; 1 means the latest Wi-Fi RX info; 2 means the latest BLE RX info. */ 67 } esp_phy_rx_result_t; 68 69 /** 70 * @brief Wifi power domain power on 71 */ 72 void esp_wifi_power_domain_on(void); 73 74 /** 75 * @brief Wifi power domain power off 76 */ 77 void esp_wifi_power_domain_off(void); 78 79 /** 80 * @brief Environment variable configuration 81 * 82 * @param conf: 83 * Set to 1 to enter RF test mode. 84 */ 85 void esp_phy_rftest_config(uint8_t conf); 86 87 /** 88 * @brief RF initialization configuration 89 */ 90 void esp_phy_rftest_init(void); 91 92 /** 93 * @brief TX Continuous mode 94 * 95 * @param contin_en: 96 * Set to true for continuous packet sending, which can be used for certification testing; 97 * Set to false to cancel continuous mode, which is the default mode and can be used for WLAN tester. 98 */ 99 void esp_phy_tx_contin_en(bool contin_en); 100 101 /** 102 * @brief HT40/HT20 mode selection 103 * 104 * @param en: 105 * Set to false to enter 11n HT20 mode; 106 * Set to true to enter 11n HT40 mode; 107 **/ 108 void esp_phy_cbw40m_en(bool en); 109 110 /** 111 * @brief Wi-Fi TX command 112 * 113 * @param chan: channel setting, 1~14; 114 * @param rate: rate setting; 115 * @param backoff: Transmit power attenuation, unit is 0.25dB. For example, 4 means that the power is attenuated by 1dB; 116 * @param length_byte: TX packet length configuration, indicating PSDU Length, unit is byte; 117 * @param packet_delay: TX packet interval configuration, unit is us; 118 * @param packet_num: The number of packets sent, 0 means sending packets continuously, other values represent the number of packets to send. 119 */ 120 void esp_phy_wifi_tx(uint32_t chan, esp_phy_wifi_rate_t rate, int8_t backoff, uint32_t length_byte, uint32_t packet_delay, uint32_t packet_num); 121 122 /** 123 * @brief Test start/stop command, used to stop transmitting or receiving state. 124 * 125 * @param value: 126 * Value should be set to 3 before TX/RX. 127 * Set value to 0 to end TX/RX state. 128 */ 129 void esp_phy_test_start_stop(uint8_t value); 130 131 /** 132 * @brief Wi-Fi RX command 133 * 134 * @param chan: channel setting, 1~14; 135 * @param rate: rate setting; 136 * 137 */ 138 void esp_phy_wifi_rx(uint32_t chan, esp_phy_wifi_rate_t rate); 139 140 /** 141 * @brief Wi-Fi Carrier Wave(CW) TX command 142 * 143 * @param start: enable CW, 1 means transmit, 0 means stop transmitting; 144 * @param chan: CW channel setting, 1~14; 145 * @param backoff: CW power attenuation parameter, unit is 0.25dB. 4 indicates the power is attenuated by 1dB. 146 * 147 */ 148 void esp_phy_wifi_tx_tone(uint32_t start, uint32_t chan, uint32_t backoff); 149 150 /** 151 * @brief BLE TX command 152 * 153 * @param txpwr: Transmit power level. Tx power is about (level-8)*3 dBm, step is 3dB. Level 8 is around 0 dBm; 154 * @param chan: channel setting, range is 0~39, corresponding frequency = 2402+chan*2; 155 * @param len: Payload length setting, range is 0-255, unit is byte, 37 bytes is employed generally; 156 * @param data_type: Data type setting; 157 * @param syncw: Packet identification (need to be provided by the packet generator or instrument manufacturer), 0x71764129 is employed generally; 158 * @param rate: rate setting; 159 * @param tx_num_in: The number of packets sent, 0 means sending packets continuously, other values represent the number of packets to send. 160 */ 161 void esp_phy_ble_tx(uint32_t txpwr, uint32_t chan, uint32_t len, esp_phy_ble_type_t data_type, uint32_t syncw, esp_phy_ble_rate_t rate, uint32_t tx_num_in); 162 163 /** 164 * @brief BLE RX command 165 * 166 * @param chan: channel selection, range is 0-39; 167 * Channels 0, 1, 2~10 correspond to 2404MHz, 2406MHz, 2408MHz~2424MHz respectively; 168 * Channels 11, 12, 13~36 correspond to 2428MHz, 2430MHz, 2432MHz~2478MHz respectively; 169 * Channel 37: 2402MHz, Channel 38: 2426MHz, Channel 39: 2480MHz; 170 * @param syncw: Packet identification (need to be provided by the packet generator or instrument manufacturer), 0x71764129 is employed generally; 171 * @param rate: rate setting; 172 */ 173 void esp_phy_ble_rx(uint32_t chan, uint32_t syncw, esp_phy_ble_rate_t rate); 174 175 /** 176 * @brief BLE Carrier Wave(CW) TX command 177 * 178 * @param start: enable CW, 1 means transmit, 0 means stop transmitting; 179 * @param chan: Single carrier transmission channel selection, range is 0~39, corresponding frequency freq = 2402+chan*2; 180 * @param power: CW power attenuation parameter, unit is 0.25dB. 4 indicates the power is attenuated by 1dB. 181 */ 182 void esp_phy_bt_tx_tone(uint32_t start, uint32_t chan, uint32_t power); 183 184 /** 185 * @brief Get some RX information 186 * 187 * @param rx_result: This struct for storing RX information; 188 */ 189 void esp_phy_get_rx_result(esp_phy_rx_result_t *rx_result); 190 191 #ifdef __cplusplus 192 } 193 #endif 194