Mistake on this page?
Report an issue in GitHub or email us
mx_wifi_conf_template.h
Go to the documentation of this file.
1 /**
2  ******************************************************************************
3  * @file mx_wifi_conf_template.h
4  * @author MCD Application Team
5  * @brief Header for mx_wifi_conf_template module
6  ******************************************************************************
7  * @attention
8  *
9  * Copyright (c) 2021 STMicroelectronics.
10  * All rights reserved.
11  *
12  * This software is licensed under terms that can be found in the LICENSE file
13  * in the root directory of this software component.
14  * If no LICENSE file comes with this software, it is provided AS-IS.
15  *
16  ******************************************************************************
17  */
18 
19 /* Define to prevent recursive inclusion -------------------------------------*/
20 #ifndef MX_WIFI_CONF_TEMPLATE_H
21 #define MX_WIFI_CONF_TEMPLATE_H
22 
23 #ifdef __cplusplus
24 extern "C" {
25 #endif /* __cplusplus */
26 
27 /* Includes ------------------------------------------------------------------*/
28 #include <stdint.h>
29 
30 int32_t mxwifi_probe(void **ll_drv_context);
31 
32 /* use SPI interface by default */
33 
34 #ifndef MX_WIFI_USE_SPI
35 #define MX_WIFI_USE_SPI (1)
36 #endif /* MX_WIFI_USE_SPI */
37 
38 /* do not use RTOS but bare metal approach by default */
39 #ifndef MX_WIFI_USE_CMSIS_OS
40 #define MX_WIFI_USE_CMSIS_OS (0)
41 #endif /* MX_WIFI_USE_CMSIS_OS */
42 
43 /* Use At command mode by default, TCP/IP stack is running on module */
44 #ifndef MX_WIFI_NETWORK_BYPASS_MODE
45 #define MX_WIFI_NETWORK_BYPASS_MODE (0)
46 #endif /* MX_WIFI_NETWORK_BYPASS_MODE */
47 
48 
49 /* Do not copy TX buffer */
50 #ifndef MX_WIFI_TX_BUFFER_NO_COPY
51 #define MX_WIFI_TX_BUFFER_NO_COPY (1)
52 #endif /* MX_WIFI_TX_BUFFER_NO_COPY */
53 
54 
55 /* DEBUG LOG */
56 /* #define MX_WIFI_API_DEBUG */
57 /* #define MX_WIFI_IPC_DEBUG */
58 /* #define MX_WIFI_HCI_DEBUG */
59 /* #define MX_WIFI_SLIP_DEBUG */
60 /* #define MX_WIFI_IO_DEBUG */
61 
62 /* check if OS primitive are already declared */
63 /* if not, include default declaration */
64 #ifndef LOCK_DECLARE
65 
66 #if (MX_WIFI_USE_CMSIS_OS == 1)
67 #include "mx_wifi_cmsis_os.h"
68 #define MX_WIFI_BARE_OS 0
69 #else
70 #if (MX_WIFI_USE_MBED_OS == 1)
71 #include "mx_wifi_mbed_os.h"
72 #define MX_WIFI_BARE_OS 0
73 #else
74 #include "mx_wifi_bare_os.h"
75 #define MX_WIFI_BARE_OS 1
76 #endif /* mx_wifi_mbed_os.h */
77 #endif /* MX_WIFI_USE_CMSIS_OS */
78 
79 #else
80 /* OS rempa are declared externally , so OS is present */
81 #define MX_WIFI_BARE_OS 0
82 #endif /* LOCK_DECLARE */
83 
84 
85 
86 #define MX_WIFI_PRODUCT_NAME ("MXCHIP-WIFI")
87 #define MX_WIFI_PRODUCT_ID ("EMW3080B")
88 
89 #ifndef MX_WIFI_USE_SPI
90 #define MX_WIFI_USE_SPI (0)
91 #endif /* MX_WIFI_USE_SPI */
92 
93 
94 #ifndef MX_WIFI_UART_BAUDRATE
95 #define MX_WIFI_UART_BAUDRATE (115200*2)
96 #endif /* MX_WIFI_UART_BAUDRATE */
97 
98 #ifndef MX_WIFI_MTU_SIZE
99 #define MX_WIFI_MTU_SIZE (1500)
100 #endif /* MX_WIFI_MTU_SIZE */
101 
102 #define MX_WIFI_BYPASS_HEADER_SIZE (28) /* MX_IPC_header(6) + sizeof(bypass_in_t)(22),
103  * set with PBUF_LINK_ENCAPSULATION_HLEN */
104 #define MX_WIFI_PBUF_LINK_HLEN (14) /* link header (PBUF_LINK_HLEN) set in lwip */
105 
106 #if (MX_WIFI_NETWORK_BYPASS_MODE==1)
107 /* Use lwip PBUF_POOL_BUFSIZE = TCP_MSS + 40 + PBUF_LINK_ENCAPSULATION_HLEN + PBUF_LINK_HLEN. */
108 #define MX_WIFI_BUFFER_SIZE \
109  (MX_WIFI_MTU_SIZE + MX_WIFI_BYPASS_HEADER_SIZE + MX_WIFI_PBUF_LINK_HLEN)
110 #else
111 #define MX_WIFI_BUFFER_SIZE (2500) /* bigger buffer size */
112 #endif /* (MX_WIFI_NETWORK_BYPASS_MODE==1) */
113 
114 /* MX_WIFI_BUFFER_SIZE - MX_IPC_header */
115 #define MX_WIFI_IPC_PAYLOAD_SIZE ((MX_WIFI_BUFFER_SIZE) - 6)
116 
117 /* MX_WIFI_IPC_PAYLOAD_SIZE - socket_api_params_header */
118 #define MX_WIFI_SOCKET_DATA_SIZE ((MX_WIFI_IPC_PAYLOAD_SIZE)-12)
119 
120 #ifndef MX_WIFI_CMD_TIMEOUT
121 #define MX_WIFI_CMD_TIMEOUT (10000)
122 #endif
123 #define MX_WIFI_MAX_SOCKET_NBR (8)
124 #define MX_WIFI_MAX_DETECTED_AP (10)
125 
126 #define MX_WIFI_MAX_SSID_NAME_SIZE 32
127 #define MX_WIFI_MAX_PSWD_NAME_SIZE 64
128 
129 #define MX_WIFI_PRODUCT_NAME_SIZE 32
130 #define MX_WIFI_PRODUCT_ID_SIZE 32
131 
132 #define MX_WIFI_FW_REV_SIZE 24
133 #ifndef MX_WIFI_SPI_THREAD_PRIORITY
134 #define MX_WIFI_SPI_THREAD_PRIORITY (OSPRIORITYREALTIME)
135 #endif /* MX_WIFI_SPI_THREAD_PRIORITY */
136 #ifndef MX_WIFI_SPI_THREAD_STACK_SIZE
137 #define MX_WIFI_SPI_THREAD_STACK_SIZE (1024)
138 #endif /* MX_WIFI_SPI_THREAD_STACK_SIZE */
139 
140 #ifndef MX_WIFI_UART_THREAD_PRIORITY
141 #define MX_WIFI_UART_THREAD_PRIORITY (OSPRIORITYREALTIME)
142 #endif /* MX_WIFI_UART_THREAD_PRIORITY */
143 #ifndef MX_WIFI_UART_THREAD_STACK_SIZE
144 #define MX_WIFI_UART_THREAD_STACK_SIZE (1024)
145 #endif /* MX_WIFI_UART_THREAD_STACK_SIZE */
146 
147 
148 #ifndef MX_WIFI_RECEIVED_THREAD_PRIORITY
149 #define MX_WIFI_RECEIVED_THREAD_PRIORITY (OSPRIORITYABOVENORMAL)
150 #endif /* MX_WIFI_RECEIVED_THREAD_PRIORITY */
151 
152 #ifndef MX_WIFI_RECEIVED_THREAD_STACK_SIZE
153 #define MX_WIFI_RECEIVED_THREAD_STACK_SIZE (1024)
154 #endif /* MX_WIFI_RECEIVED_THREAD_STACK_SIZE*/
155 
156 #ifndef MX_WIFI_TRANSMIT_THREAD_PRIORITY
157 #define MX_WIFI_TRANSMIT_THREAD_PRIORITY (OSPRIORITYABOVENORMAL)
158 #endif /* MX_WIFI_TRANSMIT_THREAD_PRIORITY */
159 
160 #ifndef MX_WIFI_TRANSMIT_THREAD_STACK_SIZE
161 #define MX_WIFI_TRANSMIT_THREAD_STACK_SIZE (1024)
162 #endif /* MX_WIFI_TRANSMIT_THREAD_STACK_SIZE */
163 
164 
165 /* Maximum number of RX buffer that can be queued by Hardware interface (SPI/UART) */
166 /* This is used to size internal queue, and avoid to block the IP thread if it can still push some buffers */
167 /* Impact on Memory foot print is weak , one single void* per place in the queue */
168 #ifndef MX_WIFI_MAX_RX_BUFFER_COUNT
169 #define MX_WIFI_MAX_RX_BUFFER_COUNT (2)
170 #endif /* MX_WIFI_MAX_RX_BUFFER_COUNT */
171 
172 
173 /* Maximum number of TX buffer that can be queued by IP stack (LwIP or Netx) without blocking the calling thread */
174 /* This is used to size internal queue, and avoid to block the IP thread if it can still push some buffers */
175 /* Impact on Memory foot print is one single void* per place in the queue, but it may lead to over allocation */
176 /* TCP/IP stack (LwIP for instance ) */
177 #ifndef MX_WIFI_MAX_TX_BUFFER_COUNT
178 #define MX_WIFI_MAX_TX_BUFFER_COUNT (4)
179 #endif /* MX_WIFI_MAX_TX_BUFFER_COUNT */
180 
181 
182 
183 /**
184  * For the TX buffer, by default no-copy feature is enabled, meaning that
185  * the IP buffer are used in the whole process and should come with
186  * available room in front of payload to accommodate transport header buffer.
187  * This is managed in interface between driver and IP stack
188  */
189 
190 /**
191  * For LwIP "PBUF_LINK_ENCAPSULATION_HLEN" must be defined as > MX_WIFI_MIN_TX_HEADER_SIZE,
192  * see net_mx_wifi/c file for implementation.
193  */
194 #define MX_WIFI_MIN_TX_HEADER_SIZE (28)
195 
196 #ifndef MX_WIFI_TX_BUFFER_NO_COPY
197 #define MX_WIFI_TX_BUFFER_NO_COPY (1)
198 #endif /* MX_WIFI_TX_BUFFER_NO_COPY */
199 
200 
201 /* Sizeof the circular buffer for Uart mode, when buffer is hlaf full data are transmitted to next stage */
202 #ifndef MX_CIRCULAR_UART_RX_BUFFER_SIZE
203 #define MX_CIRCULAR_UART_RX_BUFFER_SIZE (400)
204 #endif /* MX_CIRCULAR_UART_RX_BUFFER_SIZE */
205 
206 
207 
208 #ifndef MX_STAT_ON
209 #define MX_STAT_ON 0
210 #endif /* MX_STAT_ON */
211 
212 #if MX_STAT_ON == 1
213 typedef struct
214 {
215  uint32_t alloc;
216  uint32_t free;
217  uint32_t cmd_get_answer;
218  uint32_t callback;
219  uint32_t in_fifo;
220  uint32_t out_fifo;
221 } mx_stat_t;
222 
223 extern mx_stat_t mx_stat;
224 
225 #define MX_STAT_LOG() \
226  (void) printf("Number of allocated buffer for Rx and command answer %ld\n", mx_stat.alloc);\
227  (void) printf("Number of free buffer %ld\n",mx_stat.free);\
228  (void) printf("Number of command answer %ld , callback %ld, sum of both %ld (should match alloc && free)\n",\
229  mx_stat.cmd_get_answer,mx_stat.callback,mx_stat.cmd_get_answer+mx_stat.callback);\
230  (void) printf("Number of posted answer (callback + cmd answer) %ld, processed answer %ld\n",\
231  mx_stat.in_fifo,mx_stat.out_fifo);\
232 
233 #define MX_STAT_INIT() (void) memset((void*)&mx_stat, 0, sizeof(mx_stat))
234 #define MX_STAT(A) mx_stat.A++
235 #define MX_STAT_DECLARE() mx_stat_t mx_stat
236 
237 #else
238 
239 #define MX_STAT_INIT()
240 #define MX_STAT(A)
241 #define MX_STAT_LOG()
242 #define MX_STAT_DECLARE()
243 
244 #endif /* MX_STAT_ON */
245 
246 #ifdef __cplusplus
247 }
248 #endif /* __cplusplus */
249 
250 #endif /* MX_WIFI_CONF_TEMPLATE_H */
251 
Callback< R(ArgTs...)> callback(R(*func)(ArgTs...)=nullptr) noexcept
Create a callback class with type inferred from the arguments.
Definition: Callback.h:678
Important Information for this Arm website

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies. If you are not happy with the use of these cookies, please review our Cookie Policy to learn how they can be disabled. By disabling cookies, some features of the site will not work.