esp_wifi_internal.h 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. // Copyright 2015-2016 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. * All the APIs declared here are internal only APIs, it can only be used by
  15. * espressif internal modules, such as SSC, LWIP, TCPIP adapter etc, espressif
  16. * customers are not recommended to use them.
  17. *
  18. * If someone really want to use specified APIs declared in here, please contact
  19. * espressif AE/developer to make sure you know the limitations or risk of
  20. * the API, otherwise you may get unexpected behavior!!!
  21. *
  22. */
  23. #ifndef __ESP_WIFI_INTERNAL_H__
  24. #define __ESP_WIFI_INTERNAL_H__
  25. #include <stdint.h>
  26. #include <stdbool.h>
  27. #include "freertos/FreeRTOS.h"
  28. #include "freertos/queue.h"
  29. #include "rom/queue.h"
  30. #include "esp_err.h"
  31. #include "esp_wifi_types.h"
  32. #include "esp_event.h"
  33. #ifdef __cplusplus
  34. extern "C" {
  35. #endif
  36. /**
  37. * @brief Initialize Wi-Fi Driver
  38. * Alloc resource for WiFi driver, such as WiFi control structure, RX/TX buffer,
  39. * WiFi NVS structure among others.
  40. *
  41. * For the most part, you need not call this function directly. It gets called
  42. * from esp_wifi_init().
  43. *
  44. * This function may be called, if you only need to initialize the Wi-Fi driver
  45. * without having to use the network stack on top.
  46. *
  47. * @param config provide WiFi init configuration
  48. *
  49. * @return
  50. * - ESP_OK: succeed
  51. * - ESP_ERR_WIFI_NO_MEM: out of memory
  52. * - others: refer to error code esp_err.h
  53. */
  54. esp_err_t esp_wifi_init_internal(const wifi_init_config_t *config);
  55. /**
  56. * @brief get whether the wifi driver is allowed to transmit data or not
  57. *
  58. * @return
  59. * - true : upper layer should stop to transmit data to wifi driver
  60. * - false : upper layer can transmit data to wifi driver
  61. */
  62. bool esp_wifi_internal_tx_is_stop(void);
  63. /**
  64. * @brief free the rx buffer which allocated by wifi driver
  65. *
  66. * @param void* buffer: rx buffer pointer
  67. */
  68. void esp_wifi_internal_free_rx_buffer(void* buffer);
  69. /**
  70. * @brief transmit the buffer via wifi driver
  71. *
  72. * @param wifi_interface_t wifi_if : wifi interface id
  73. * @param void *buffer : the buffer to be tansmit
  74. * @param u16_t len : the length of buffer
  75. *
  76. * @return
  77. * - ERR_OK : Successfully transmit the buffer to wifi driver
  78. * - ERR_MEM : Out of memory
  79. * - ERR_IF : WiFi driver error
  80. * - ERR_ARG : Invalid argument
  81. */
  82. int esp_wifi_internal_tx(wifi_interface_t wifi_if, void *buffer, u16_t len);
  83. /**
  84. * @brief The WiFi RX callback function
  85. *
  86. * Each time the WiFi need to forward the packets to high layer, the callback function will be called
  87. */
  88. typedef esp_err_t (*wifi_rxcb_t)(void *buffer, uint16_t len, void *eb);
  89. /**
  90. * @brief Set the WiFi RX callback
  91. *
  92. * @attention 1. Currently we support only one RX callback for each interface
  93. *
  94. * @param wifi_interface_t ifx : interface
  95. * @param wifi_rxcb_t fn : WiFi RX callback
  96. *
  97. * @return
  98. * - ESP_OK : succeed
  99. * - others : fail
  100. */
  101. esp_err_t esp_wifi_internal_reg_rxcb(wifi_interface_t ifx, wifi_rxcb_t fn);
  102. /**
  103. * @brief Notify WIFI driver that the station got ip successfully
  104. *
  105. * @return
  106. * - ESP_OK : succeed
  107. * - others : fail
  108. */
  109. esp_err_t esp_wifi_internal_set_sta_ip(void);
  110. /**
  111. * @brief Allocate a chunk of memory for WiFi driver
  112. *
  113. * @attention This API is not used for DMA memory allocation.
  114. *
  115. * @param size_t size : Size, in bytes, of the amount of memory to allocate
  116. *
  117. * @return A pointer to the memory allocated on success, NULL on failure
  118. */
  119. void *wifi_malloc( size_t size );
  120. /**
  121. * @brief Reallocate a chunk of memory for WiFi driver
  122. *
  123. * @attention This API is not used for DMA memory allocation.
  124. *
  125. * @param void * ptr : Pointer to previously allocated memory, or NULL for a new allocation.
  126. * @param size_t size : Size, in bytes, of the amount of memory to allocate
  127. *
  128. * @return A pointer to the memory allocated on success, NULL on failure
  129. */
  130. void *wifi_realloc( void *ptr, size_t size );
  131. /**
  132. * @brief Callocate memory for WiFi driver
  133. *
  134. * @attention This API is not used for DMA memory allocation.
  135. *
  136. * @param size_t n : Number of continuing chunks of memory to allocate
  137. * @param size_t size : Size, in bytes, of the amount of memory to allocate
  138. *
  139. * @return A pointer to the memory allocated on success, NULL on failure
  140. */
  141. void *wifi_calloc( size_t n, size_t size );
  142. #ifdef __cplusplus
  143. }
  144. #endif
  145. #endif /* __ESP_WIFI_H__ */