1 /*---------------------------------------------------------------------------*
2   Project:  TwlSDK - WM - include
3   File:     wm_api.h
4 
5   Copyright 2003-2008 Nintendo. All rights reserved.
6 
7   These coded instructions, statements, and computer programs contain
8   proprietary information of Nintendo of America Inc. and/or Nintendo
9   Company Ltd., and are protected by Federal copyright law. They may
10   not be disclosed to third parties or copied or duplicated in any form,
11   in whole or in part, without the prior written consent of Nintendo.
12 
13   $Date::            $
14   $Rev:$
15   $Author:$
16  *---------------------------------------------------------------------------*/
17 
18 #ifndef NITRO_WM_ARM9_WM_API_H_
19 #define NITRO_WM_ARM9_WM_API_H_
20 
21 #ifdef __cplusplus
22 extern "C" {
23 #endif
24 
25 /*===========================================================================*/
26 
27 /*---------------------------------------------------------------------------*
28     Constant Definitions
29  *---------------------------------------------------------------------------*/
30 #define     WM_DEFAULT_BEACON_PERIOD    200     // ms
31 #define     WM_DEFAULT_SCAN_PERIOD      30      // ms
32 #define     WM_MAX_MP_PACKET_TIME       5600    // US
33 
34 
35 /*---------------------------------------------------------------------------*
36     Function Definitions
37  *---------------------------------------------------------------------------*/
38 
39 /*---------------------------------------------------------------------------*
40   Name:         WM_Init
41 
42   Description:  Performs the initialization process for the WM library.
43                 Synchronous function that only performs initialization on the ARM9 side.
44 
45   Arguments:    wmSysBuf    -   Pointer to the buffer allocated by the caller.
46                                 Only as much as WM_SYSTEM_BUF_SIZE is required for buffer size.
47                 dmaNo       -   DMA number used by WM
48 
49   Returns:      WMErrCode   -   Returns the processing result.
50  *---------------------------------------------------------------------------*/
51 WMErrCode WM_Init(void *wmSysBuf, u16 dmaNo);
52 
53 /*---------------------------------------------------------------------------*
54   Name:         WM_Finish
55 
56   Description:  Performs termination processing for the WM library. Synchronous function.
57                 Restores the state before WM_Init function was called.
58 
59   Arguments:    None.
60 
61   Returns:      WMErrCode   -   Returns the processing result.
62  *---------------------------------------------------------------------------*/
63 WMErrCode WM_Finish(void);
64 
65 /*---------------------------------------------------------------------------*
66   Name:         WM_Enable
67 
68   Description:  Puts the wireless hardware into a usable state.
69                 Internal state changes from READY state to STOP state.
70 
71   Arguments:    callback    -   Callback function that is called when the asynchronous process completes.
72 
73   Returns:      WMErrCode   -   Returns the processing result. Returns WM_ERRCODE_OPERATING if asynchronous processing started successfully. Afterwards, the asynchronous processing results will be passed to the callback.
74 
75 
76  *---------------------------------------------------------------------------*/
77 WMErrCode WM_Enable(WMCallbackFunc callback);
78 
79 /*---------------------------------------------------------------------------*
80   Name:         WM_EnableForListening
81 
82   Description:  Puts the wireless hardware into a usable state.
83                 Internal state changes from READY state to STOP state.
84                 Operations that require sending radio signals are not available.
85 
86   Arguments:    callback    -   Callback function that is called when the asynchronous process completes.
87                 blink       -   Whether to flash the LED
88 
89   Returns:      WMErrCode   -   Returns the processing result.
90                                 Returns WM_ERRCODE_OPERATING if asynchronous processing started successfully. Afterwards, the asynchronous processing results will be passed to the callback.
91 
92  *---------------------------------------------------------------------------*/
93 WMErrCode WM_EnableForListening(WMCallbackFunc callback, BOOL blink);
94 
95 /*---------------------------------------------------------------------------*
96   Name:         WMi_EnableEx
97 
98   Description:  Puts the wireless hardware into a usable state.
99                 Internal state changes from READY state to STOP state.
100 
101   Arguments:    callback    -   Callback function that is called when the asynchronous process completes.
102                 miscFlags   -   Flags during initialization
103 
104   Returns:      WMErrCode   -   Returns the processing result.
105                                 Returns WM_ERRCODE_OPERATING if asynchronous processing started successfully. Afterwards, the asynchronous processing results will be passed to the callback.
106 
107  *---------------------------------------------------------------------------*/
108 WMErrCode WMi_EnableEx(WMCallbackFunc callback, u32 miscFlags);
109 
110 /*---------------------------------------------------------------------------*
111   Name:         WM_Disable
112 
113   Description:  Changes the wireless hardware to a use prohibited state.
114                 Internal state changes from STOP state to READY state.
115 
116   Arguments:    callback    -   Callback function that is called when the asynchronous process completes.
117 
118   Returns:      WMErrCode   -   Returns the processing result. Returns WM_ERRCODE_OPERATING if asynchronous processing started successfully. Afterwards, the asynchronous processing results will be passed to the callback.
119 
120 
121  *---------------------------------------------------------------------------*/
122 WMErrCode WM_Disable(WMCallbackFunc callback);
123 
124 /*---------------------------------------------------------------------------*
125   Name:         WM_PowerOn
126 
127   Description:  Starts up the wireless hardware.
128                 Internal state changes from STOP state to IDLE state.
129 
130   Arguments:    callback    -   Callback function that is called when the asynchronous process completes.
131 
132   Returns:      WMErrCode   -   Returns the processing result. Returns WM_ERRCODE_OPERATING if asynchronous processing started successfully. Afterwards, the asynchronous processing results will be passed to the callback.
133 
134 
135  *---------------------------------------------------------------------------*/
136 WMErrCode WM_PowerOn(WMCallbackFunc callback);
137 
138 /*---------------------------------------------------------------------------*
139   Name:         WM_PowerOff
140 
141   Description:  Shuts down the wireless hardware.
142                 Internal state changes from IDLE state to STOP state.
143 
144   Arguments:    callback    -   Callback function that is called when the asynchronous process completes.
145 
146   Returns:      WMErrCode   -   Returns the processing result. Returns WM_ERRCODE_OPERATING if asynchronous processing started successfully. Afterwards, the asynchronous processing results will be passed to the callback.
147 
148 
149  *---------------------------------------------------------------------------*/
150 WMErrCode WM_PowerOff(WMCallbackFunc callback);
151 
152 /*---------------------------------------------------------------------------*
153   Name:         WM_Initialize
154 
155   Description:  Performs the WM initialization process.
156 
157   Arguments:    wmSysBuf    -   Pointer to the buffer allocated by the caller.
158                                 Only as much as WM_SYSTEM_BUF_SIZE is required for buffer size.
159                 callback    -   Callback function that is called when the asynchronous process completes.
160                 dmaNo       -   DMA number used by WM
161 
162   Returns:      WMErrCode   -   Returns the processing result. Returns WM_ERRCODE_OPERATING if asynchronous processing started successfully. Afterwards, the asynchronous processing results will be passed to the callback.
163 
164 
165  *---------------------------------------------------------------------------*/
166 WMErrCode WM_Initialize(void *wmSysBuf, WMCallbackFunc callback, u16 dmaNo);
167 
168 /*---------------------------------------------------------------------------*
169   Name:         WM_InitializeForListening
170 
171   Description:  Performs the WM initialization process.
172                 Only scanning communications can be performed.
173 
174   Arguments:    wmSysBuf    -   Pointer to the buffer allocated by the caller.
175                                 Only as much as WM_SYSTEM_BUF_SIZE is required for buffer size.
176                 callback    -   Callback function that is called when the asynchronous process completes.
177                 dmaNo       -   DMA number used by WM
178                 blink       -   Whether to blink the LED
179 
180   Returns:      WMErrCode   -   Returns the processing result.
181                                 Returns WM_ERRCODE_OPERATING if asynchronous processing started successfully. Afterwards, the asynchronous processing results will be passed to the callback.
182 
183  *---------------------------------------------------------------------------*/
184 WMErrCode WM_InitializeForListening(void *wmSysBuf, WMCallbackFunc callback, u16 dmaNo, BOOL blink);
185 
186 /*---------------------------------------------------------------------------*
187   Name:         WMi_InitializeEx
188 
189   Description:  Performs the WM initialization process.
190 
191   Arguments:    wmSysBuf    -   Pointer to the buffer allocated by the caller.
192                                 Only as much as WM_SYSTEM_BUF_SIZE is required for buffer size.
193                 callback    -   Callback function that is called when the asynchronous process completes.
194                 dmaNo       -   DMA number used by WM
195                 miscFlags   -   Flags during initialization
196 
197   Returns:      WMErrCode   -   Returns the processing result.
198                                 Returns WM_ERRCODE_OPERATING if asynchronous processing started successfully. Afterwards, the asynchronous processing results will be passed to the callback.
199 
200  *---------------------------------------------------------------------------*/
201 WMErrCode WMi_InitializeEx(void *wmSysBuf, WMCallbackFunc callback, u16 dmaNo, u32 miscFlags);
202 
203 /*---------------------------------------------------------------------------*
204   Name:         WM_SetIndCallback
205 
206   Description:  Sets a function that is called to the status notification from WM7.
207                 This function itself is a synchronous function.
208 
209   Arguments:    callback    -   Specifies the callback function called during status notification from the wireless firmware.
210 
211 
212   Returns:      WMErrCode   -   Returns the processing result.
213  *---------------------------------------------------------------------------*/
214 WMErrCode WM_SetIndCallback(WMCallbackFunc callback);
215 
216 /*---------------------------------------------------------------------------*
217   Name:         WM_SetPortCallback
218 
219   Description:  Sets a function that is called for the communication frame reception notification from WM7.
220 
221   Arguments:    port        -   Port number
222                 callback: Callback function that will be invoked when a receive notification occurs
223                 arg         -   Argument passed to the callback function as WMPortRecvCallback.arg
224 
225 
226   Returns:      WMErrCode   -   Returns the processing result.
227  *---------------------------------------------------------------------------*/
228 WMErrCode WM_SetPortCallback(u16 port, WMCallbackFunc callback, void *arg);
229 
230 /*---------------------------------------------------------------------------*
231   Name:         WM_Reset
232 
233   Description:  Resets the wireless library, and restores the state immediately after the initialization.
234 
235   Arguments:    callback    -   Callback function that is called when the asynchronous process completes.
236 
237   Returns:      WMErrCode   -   Returns the processing result. Returns WM_ERRCODE_OPERATING if asynchronous processing started successfully. Afterwards, the asynchronous processing results will be passed to the callback.
238 
239 
240  *---------------------------------------------------------------------------*/
241 WMErrCode WM_Reset(WMCallbackFunc callback);
242 
243 /*---------------------------------------------------------------------------*
244   Name:         WM_End
245 
246   Description:  Closes the wireless library.
247 
248   Arguments:    callback    -   Callback function that is called when the asynchronous process completes.
249 
250   Returns:      WMErrCode   -   Returns the processing result. Returns WM_ERRCODE_OPERATING if asynchronous processing started successfully. Afterwards, the asynchronous processing results will be passed to the callback.
251 
252 
253  *---------------------------------------------------------------------------*/
254 WMErrCode WM_End(WMCallbackFunc callback);
255 
256 /*---------------------------------------------------------------------------*
257   Name:         WM_ReadStatus
258 
259   Description:  Obtains the structure that indicates the status of the wireless library. Synchronous function.
260 
261   Arguments:    statusBuf   -   Pointer to the variable that obtains the status.
262 
263   Returns:      WMErrCode   -   Returns the processing result.
264  *---------------------------------------------------------------------------*/
265 WMErrCode WM_ReadStatus(WMStatus *statusBuf);
266 
267 /*---------------------------------------------------------------------------*
268   Name:         WM_SetParentParameter
269 
270   Description:  Sets the parent device information.
271 
272   Arguments:    callback    -   Callback function that is called when the asynchronous process completes.
273                 pparaBuf    -   Pointer to the structure that indicates the parent information.
274                                 Note that the pparaBuf and pparaBuf->userGameInfo objects will be forcibly stored in the cache.
275 
276 
277   Returns:      WMErrCode   -   Returns the processing result. Returns WM_ERRCODE_OPERATING if asynchronous processing started successfully. Afterwards, the asynchronous processing results will be passed to the callback.
278 
279 
280  *---------------------------------------------------------------------------*/
281 WMErrCode WM_SetParentParameter(WMCallbackFunc callback, const WMParentParam *pparaBuf);
282 
283 /*---------------------------------------------------------------------------*
284   Name:         WMi_StartParent
285 
286   Description:  Starts communication as the parent device.
287 
288   Arguments:    callback    -   Callback function that is called when the asynchronous process completes.
289                 powerSave   -   When using power save mode, TRUE. When not using it, FALSE.
290 
291   Returns:      WMErrCode   -   Returns the processing result. Returns WM_ERRCODE_OPERATING if asynchronous processing started successfully. Afterwards, the asynchronous processing results will be passed to the callback.
292 
293 
294  *---------------------------------------------------------------------------*/
295 WMErrCode WMi_StartParentEx(WMCallbackFunc callback, BOOL powerSave);
296 
297 /*---------------------------------------------------------------------------*
298   Name:         WM_StartParent
299 
300   Description:  Starts communication as the parent device.
301 
302   Arguments:    callback    -   Callback function that is called when the asynchronous process completes.
303 
304   Returns:      WMErrCode   -   Returns the processing result. Returns WM_ERRCODE_OPERATING if asynchronous processing started successfully. Afterwards, the asynchronous processing results will be passed to the callback.
305 
306 
307  *---------------------------------------------------------------------------*/
308 WMErrCode WM_StartParent(WMCallbackFunc callback);
309 
310 /*---------------------------------------------------------------------------*
311   Name:         WM_EndParent
312 
313   Description:  Stops communication as the parent device.
314 
315   Arguments:    callback    -   Callback function that is called when the asynchronous process completes.
316 
317   Returns:      WMErrCode   -   Returns the processing result. Returns WM_ERRCODE_OPERATING if asynchronous processing started successfully. Afterwards, the asynchronous processing results will be passed to the callback.
318 
319 
320  *---------------------------------------------------------------------------*/
321 WMErrCode WM_EndParent(WMCallbackFunc callback);
322 
323 /*---------------------------------------------------------------------------*
324   Name:         WM_StartScan
325 
326   Description:  As a child device, starts scanning for a parent device.
327                 Obtains one device's parent information with each call.
328                 It can be called repeatedly without calling WM_EndScan.
329 
330   Arguments:    callback    -   Callback function that is called when the asynchronous process completes.
331                 param       -   Pointer to the structure that shows the scan information.
332                                 The ARM7 directly writes scan result information to param->scanBuf, so it must match the cache line.
333 
334 
335   Returns:      WMErrCode   -   Returns the processing result. Returns WM_ERRCODE_OPERATING if asynchronous processing started successfully. Afterwards, the asynchronous processing results will be passed to the callback.
336 
337 
338  *---------------------------------------------------------------------------*/
339 WMErrCode WM_StartScan(WMCallbackFunc callback, const WMScanParam *param);
340 
341 /*---------------------------------------------------------------------------*
342   Name:         WM_StartScanEx
343 
344   Description:  As a child device, starts scanning for a parent device.
345                 Obtains multiple devices' parent information with one call.
346                 It can be called repeatedly without calling WM_EndScan.
347 
348   Arguments:    callback    -   Callback function that is called when the asynchronous process completes.
349                 param       -   Pointer to the structure that shows the scan information.
350                            The ARM7 directly writes scan result information to param->scanBuf, so it must match the cache line.
351 
352 
353   Returns:      int:       Returns WM_ERRCODE_* type processing results.
354  *---------------------------------------------------------------------------*/
355 WMErrCode WM_StartScanEx(WMCallbackFunc callback, const WMScanExParam *param);
356 
357 /*---------------------------------------------------------------------------*
358   Name:         WM_EndScan
359 
360   Description:  Stops the scan process as a child device.
361 
362   Arguments:    callback    -   Callback function that is called when the asynchronous process completes.
363 
364   Returns:      WMErrCode   -   Returns the processing result. Returns WM_ERRCODE_OPERATING if asynchronous processing started successfully. Afterwards, the asynchronous processing results will be passed to the callback.
365 
366 
367  *---------------------------------------------------------------------------*/
368 WMErrCode WM_EndScan(WMCallbackFunc callback);
369 
370 /*---------------------------------------------------------------------------*
371   Name:         WM_StartConnectEx
372 
373   Description:  Starts the connection to the parent as a child device.
374 
375   Arguments:    callback    -   Callback function that is called when the asynchronous process completes.
376                 pInfo       -   Information of the parent to connect to.
377                                 Specifies the structure obtained with WM_StartScan.
378                                 Note that this structure is forcibly stored in the cache.
379 
380                 ssid        -   Child information to notify to the parent (24Byte(WM_SIZE_CHILD_SSID) fixed size)
381                 powerSave   -   When using power save mode, TRUE. When not using it, FALSE.
382                 authMode    -   Authentication mode selection.
383                                   WM_AUTHMODE_OPEN_SYSTEM: OPEN SYSTEM mode
384                                   WM_AUTHMODE_SHARED_KEY: SHARED KEY mode
385 
386   Returns:      WMErrCode   -   Returns the processing result. Returns WM_ERRCODE_OPERATING if asynchronous processing started successfully. Afterwards, the asynchronous processing results will be passed to the callback.
387 
388 
389  *---------------------------------------------------------------------------*/
390 WMErrCode WM_StartConnectEx(WMCallbackFunc callback, const WMBssDesc *pInfo, const u8 *ssid,
391                             BOOL powerSave, u16 authMode);
392 
393 /*---------------------------------------------------------------------------*
394   Name:         WM_StartConnect
395 
396   Description:  Starts the connection to the parent as a child device.
397 
398   Arguments:    callback    -   Callback function that is called when the asynchronous process completes.
399                 pInfo       -   Information of the parent to connect to. Specifies the structure obtained with WM_StartScan.
400                                  Note that this structure is forcibly stored in the cache.
401 
402                 ssid        -   Child information to notify to the parent (24Byte(WM_SIZE_CHILD_SSID) fixed size)
403 
404   Returns:      WMErrCode   -   Returns the processing result. Returns WM_ERRCODE_OPERATING if asynchronous processing started successfully. Afterwards, the asynchronous processing results will be passed to the callback.
405 
406 
407  *---------------------------------------------------------------------------*/
408 static inline WMErrCode
WM_StartConnect(WMCallbackFunc callback,const WMBssDesc * pInfo,const u8 * ssid)409 WM_StartConnect(WMCallbackFunc callback, const WMBssDesc *pInfo, const u8 *ssid)
410 {
411     return WM_StartConnectEx(callback, pInfo, ssid, TRUE, WM_AUTHMODE_OPEN_SYSTEM);
412 }
413 
414 /*---------------------------------------------------------------------------*
415   Name:         WM_Disconnect
416 
417   Description:  Cuts off the connection that has been established.
418 
419   Arguments:    callback    -   Callback function that is called when the asynchronous process completes.
420                 aid         -   AID of the communication partner to be disconnected.
421                                 In the parent's case, individually disconnects children having IDs 1 - 15.
422                                 In the child's case, ends communication with the parent having ID 0.
423 
424   Returns:      WMErrCode   -   Returns the processing result.
425                                 Returns WM_ERRCODE_OPERATING if asynchronous processing started successfully. Afterwards, the asynchronous processing results will be passed to the callback.
426 
427  *---------------------------------------------------------------------------*/
428 WMErrCode WM_Disconnect(WMCallbackFunc callback, u16 aid);
429 
430 /*---------------------------------------------------------------------------*
431   Name:         WM_DisconnectChildren
432 
433   Description:  Disconnects the respective children with which the connection has been established. Function exclusively for parent use.
434 
435   Arguments:    callback    -   Callback function that is called when the asynchronous process completes.
436                 aidBitmap   -   AID bitfield of the children to be disconnected.
437                                 The least significant bit will be ignored. Bits 1-15 indicate AIDs 1-15, respectively.
438                                 Bits that indicate unconnected child devices will be ignored, so specify 0xFFFF to disconnect all children regardless of their connection state.
439 
440 
441 
442   Returns:      WMErrCode   -   Returns the processing result.
443                                 Returns WM_ERRCODE_OPERATING if asynchronous processing started successfully. Afterwards, the asynchronous processing results will be passed to the callback.
444 
445  *---------------------------------------------------------------------------*/
446 WMErrCode WM_DisconnectChildren(WMCallbackFunc callback, u16 aidBitmap);
447 
448 /*---------------------------------------------------------------------------*
449   Name:         WM_GetMPSendBufferSize
450 
451   Description:  Calculates MP communication send buffer size from the current WM state.
452 
453   Arguments:    None.
454 
455   Returns:      int      - Send buffer size to be passed to WM_StartMP.
456  *---------------------------------------------------------------------------*/
457 int     WM_GetMPSendBufferSize(void);
458 
459 /*---------------------------------------------------------------------------*
460   Name:         WM_GetMPReceiveBufferSize
461 
462   Description:  Calculates the MP communication receive buffer size from the current WM state.
463 
464   Arguments:    None.
465 
466   Returns:      int      - Receive buffer size to be passed to WM_StartMP.
467  *---------------------------------------------------------------------------*/
468 int     WM_GetMPReceiveBufferSize(void);
469 
470 /*---------------------------------------------------------------------------*
471   Name:         WM_StartMPEx
472 
473   Description:  Starts MP communication. It's possible to specify detailed operation mode. Function that is common to parent and child.
474 
475   Arguments:    callback    -   Callback function that is called when the asynchronous process completes.
476                 recvBuf     -   Receive data storage buffer.
477                                     Pay attention to the cache, because the ARM7 writes out data directly.
478                 recvBufSize -   Size of the receive data storage buffer.
479                                     It must be larger than the return value of WM_GetReceiveBufferSize().
480                 sendBuf     -   Buffer that stores the send data.
481                                     Pay attention to the cache, because the ARM7 writes out data directly.
482                 sendBufSize -   Size of the send data storage buffer.
483                                     It must be larger than the return value of WM_GetSendBufferSize().
484                 mpFreq      -   How many times MP communication is performed in one frame.
485                                     0 is continuous send mode. This carries a meaning only for the parent.
486                 defaultRetryCount - The standard number of retries when data fails to be sent on ports 0-7.
487                                      Specify 0 to not retry.
488                 minPollBmpMode - An operating mode that constrains the pollBitmap during MP communications to the minimum set of packet addressees.
489 
490                 singlePacketMode - A special operating mode that sends only one packet for each MP transmission.
491 
492                 fixFreqMode     -   Special operation mode that prohibits the increase of the MP communication by retries.
493                                     The number of times for MP communication in a frame is fixed to exactly mpFreq.
494 
495                 ignoreFatalError -  No longer perform AutoDisconnect when a FatalError is generated.
496 
497   Returns:      WMErrCode   -   Returns the processing result.
498                                 Returns WM_ERRCODE_OPERATING if asynchronous processing started successfully. Afterwards, the asynchronous processing results will be passed to the callback.
499 
500  *---------------------------------------------------------------------------*/
501 WMErrCode WM_StartMPEx(WMCallbackFunc callback,
502                        u16 *recvBuf,
503                        u16 recvBufSize,
504                        u16 *sendBuf,
505                        u16 sendBufSize,
506                        u16 mpFreq,
507                        u16 defaultRetryCount,
508                        BOOL minPollBmpMode,
509                        BOOL singlePacketMode, BOOL fixFreqMode, BOOL ignoreFatalError);
510 
511 /*---------------------------------------------------------------------------*
512   Name:         WM_StartMP
513 
514   Description:  Starts MP communication. Function that is common to parent and child.
515 
516   Arguments:    callback    -   Callback function that is called when the asynchronous process completes.
517                 recvBuf     -   Receive data storage buffer.
518                                 Pay attention to the cache, because the ARM7 writes out data directly.
519                 recvBufSize -   Size of the receive data storage buffer.
520                                 It must be larger than the return value of WM_GetReceiveBufferSize().
521                 sendBuf     -   Buffer that stores the send data.
522                                 Pay attention to the cache, because the ARM7 writes out data directly.
523                 sendBufSize -   Size of the send data storage buffer.
524                                 It must be larger than the return value of WM_GetSendBufferSize().
525                 mpFreq      -   How many times MP communication is performed in one frame.
526                                 0 is continuous send mode. This carries a meaning only for the parent.
527 
528   Returns:      WMErrCode   -   Returns the processing result. Returns WM_ERRCODE_OPERATING if asynchronous processing started successfully. Afterwards, the asynchronous processing results will be passed to the callback.
529 
530 
531  *---------------------------------------------------------------------------*/
532 WMErrCode WM_StartMP(WMCallbackFunc callback,
533                      u16 *recvBuf, u16 recvBufSize, u16 *sendBuf, u16 sendBufSize, u16 mpFreq);
534 
535 /*---------------------------------------------------------------------------*
536   Name:         WM_SetMPParameter
537 
538   Description:  Configures the different parameters for MP communications
539 
540   Arguments:    callback    -   Callback function that is called when the asynchronous process completes.
541                 param       -   Pointer to the structure where the parameters for MP communications are stored
542 
543   Returns:      WMErrCode   -   Returns the processing result. Returns WM_ERRCODE_OPERATING if asynchronous processing started successfully. Afterwards, the asynchronous processing results will be passed to the callback.
544 
545 
546  *---------------------------------------------------------------------------*/
547 WMErrCode WM_SetMPParameter(WMCallbackFunc callback, const WMMPParam * param);
548 
549 /*---------------------------------------------------------------------------*
550   Name:         WM_SetMPChildSize
551 
552   Description:  Sets the number of bytes a child can send in one MP communication.
553 
554   Arguments:    callback    -   Callback function that is called when the asynchronous process completes.
555                 childSize   -   Number of send bytes for a child
556 
557   Returns:      WMErrCode   -   Returns the processing result. Returns WM_ERRCODE_OPERATING if asynchronous processing started successfully. Afterwards, the asynchronous processing results will be passed to the callback.
558 
559 
560  *---------------------------------------------------------------------------*/
561 WMErrCode WM_SetMPChildSize(WMCallbackFunc callback, u16 childSize);
562 
563 /*---------------------------------------------------------------------------*
564   Name:         WM_SetMPParentSize
565 
566   Description:  Sets the number of bytes a parent can send in one MP communication.
567 
568   Arguments:    callback    -   Callback function that is called when the asynchronous process completes.
569                 childSize   -   Number of send bytes for a parent.
570 
571   Returns:      WMErrCode   -   Returns the processing result. Returns WM_ERRCODE_OPERATING if asynchronous processing started successfully. Afterwards, the asynchronous processing results will be passed to the callback.
572 
573 
574  *---------------------------------------------------------------------------*/
575 WMErrCode WM_SetMPParentSize(WMCallbackFunc callback, u16 parentSize);
576 
577 /*---------------------------------------------------------------------------*
578   Name:         WM_SetMPFrequency
579 
580   Description:  Switches how many times to perform the MP communication in one frame. Function for parent device.
581 
582   Arguments:    callback    -   Callback function that is called when the asynchronous process completes.
583                 mpFreq      -   How many times MP communication is performed in one frame.
584                                 0 is continuous send mode.
585 
586   Returns:      WMErrCode   -   Returns the processing result. Returns WM_ERRCODE_OPERATING if asynchronous processing started successfully. Afterwards, the asynchronous processing results will be passed to the callback.
587 
588 
589  *---------------------------------------------------------------------------*/
590 WMErrCode WM_SetMPFrequency(WMCallbackFunc callback, u16 mpFreq);
591 
592 /*---------------------------------------------------------------------------*
593   Name:         WM_SetMPInterval
594 
595   Description:  Sets the interval in which a connection can be made and MP communications carried out in one frame.
596 
597   Arguments:    callback    -   Callback function that is called when the asynchronous process completes.
598                 parentInterval - The interval in which a connection can be made and MP communications carried out by a parent in one frame (ms)
599                 childInterval  - The interval in which a connection can be made and MP communications carried out by a child in one frame (ms)
600 
601   Returns:      WMErrCode   -   Returns the processing result. Returns WM_ERRCODE_OPERATING if asynchronous processing started successfully. Afterwards, the asynchronous processing results will be passed to the callback.
602 
603 
604  *---------------------------------------------------------------------------*/
605 WMErrCode WM_SetMPInterval(WMCallbackFunc callback, u16 parentInterval, u16 childInterval);
606 
607 /*---------------------------------------------------------------------------*
608   Name:         WM_SetMPTiming
609 
610   Description:  Sets the preparation start timing for MP communications when in frame synchronous communication mode.
611 
612   Arguments:    callback    -   Callback function that is called when the asynchronous process completes.
613                 parentVCount -  The parent operation start V Count when in frame simultaneous communications
614                 childVCount -  The child operation start V Count when in frame simultaneous communications
615 
616   Returns:      WMErrCode   -   Returns the processing result. Returns WM_ERRCODE_OPERATING if asynchronous processing started successfully. Afterwards, the asynchronous processing results will be passed to the callback.
617 
618 
619  *---------------------------------------------------------------------------*/
620 WMErrCode WM_SetMPTiming(WMCallbackFunc callback, u16 parentVCount, u16 childVCount);
621 
622 /*---------------------------------------------------------------------------*
623   Name:         WM_SetMPDataToPortEx
624 
625   Description:  Reserves data with MP communication. Function that is common to parent and child.
626 
627   Arguments:    callback    -   Callback function that is called when the asynchronous process completes.
628                 arg         -   Argument to be passed to callback
629                 sendData    -   Pointer to the data to reserve send.
630                                 Note that an instance of this data is forcibly stored in the cache.
631                 sendDataSize -  Size of the data to reserve send.
632                 destBitmap  -   Specifies an aid bitmap that indicates the send destination child.
633                 port        -   Port number to send
634                 prio        -   Priority (0: highest -- 3: lowest)
635 
636   Returns:      WMErrCode   -   Returns the processing result.
637                                 Returns WM_ERRCODE_OPERATING if asynchronous processing started successfully. Afterwards, the asynchronous processing results will be passed to the callback.
638 
639  *---------------------------------------------------------------------------*/
640 WMErrCode WM_SetMPDataToPortEx(WMCallbackFunc callback,
641                                void *arg,
642                                const u16 *sendData,
643                                u16 sendDataSize, u16 destBitmap, u16 port, u16 prio);
644 
645 /*---------------------------------------------------------------------------*
646   Name:         WM_SetMPDataToPort
647 
648   Description:  Reserves data with MP communication. Function that is common to parent and child.
649 
650   Arguments:    callback    -   Callback function that is called when the asynchronous process completes.
651                 sendData    -   Pointer to the data to reserve send.
652                                 Note that an instance of this data is forcibly stored in the cache.
653                 sendDataSize -  Size of the data to reserve send.
654                 destBitmap  -   Specifies an aid bitmap that indicates the send destination child.
655                 port        -   Port number to send
656                 prio        -   Priority (0: highest -- 3: lowest)
657 
658   Returns:      WMErrCode   -   Returns the processing result.
659                                 Returns WM_ERRCODE_OPERATING if asynchronous processing started successfully. Afterwards, the asynchronous processing results will be passed to the callback.
660 
661  *---------------------------------------------------------------------------*/
662 static inline WMErrCode
WM_SetMPDataToPort(WMCallbackFunc callback,const u16 * sendData,u16 sendDataSize,u16 destBitmap,u16 port,u16 prio)663 WM_SetMPDataToPort(WMCallbackFunc callback, const u16 *sendData, u16 sendDataSize, u16 destBitmap,
664                    u16 port, u16 prio)
665 {
666     return WM_SetMPDataToPortEx(callback, NULL, sendData, sendDataSize, destBitmap, port, prio);
667 }
668 
669 /*---------------------------------------------------------------------------*
670   Name:         WM_SetMPData
671 
672   Description:  Reserves data with MP communication. Function that is common to parent and child.
673 
674   Arguments:    callback    -   Callback function that is called when the asynchronous process completes.
675                 sendData    -   Pointer to the data to reserve send.
676                                 Note that an instance of this data is forcibly stored in the cache.
677                 sendDataSize -  Size of the data to reserve send.
678                 tmptt       -   In continuous send mode, this specifies MP packet send time.
679                                 (Only valid for parent. ) (ignored as of 2004/07/26)
680                 pollbmp     -   In continuous send mode, this specifies a Poll map that indicates the send destination child(ren).
681 
682   Returns:      WMErrCode   -   Returns the processing result. Returns WM_ERRCODE_OPERATING if asynchronous processing started successfully. Afterwards, the asynchronous processing results will be passed to the callback.
683 
684 
685  *---------------------------------------------------------------------------*/
686 static inline WMErrCode
WM_SetMPData(WMCallbackFunc callback,const u16 * sendData,u16 sendDataSize,u16 tmptt,u16 pollbmp)687 WM_SetMPData(WMCallbackFunc callback, const u16 *sendData, u16 sendDataSize, u16 tmptt, u16 pollbmp)
688 {
689 #pragma unused( tmptt )
690     return WM_SetMPDataToPortEx(callback, NULL, sendData, sendDataSize, pollbmp, WM_PORT_RAWDATA,
691                                 WM_PRIORITY_NORMAL);
692 }
693 
694 /*---------------------------------------------------------------------------*
695   Name:         WM_EndMP
696 
697   Description:  Stops MP communication. Function that is common to parent and child.
698 
699   Arguments:    callback    -   Callback function that is called when the asynchronous process completes.
700 
701   Returns:      WMErrCode   -   Returns the processing result. Returns WM_ERRCODE_OPERATING if asynchronous processing started successfully. Afterwards, the asynchronous processing results will be passed to the callback.
702 
703 
704  *---------------------------------------------------------------------------*/
705 WMErrCode WM_EndMP(WMCallbackFunc callback);
706 
707 /*---------------------------------------------------------------------------*
708   Name:         WM_StartDCF
709 
710   Description:  Starts infrastructure-mode communications.
711 
712   Arguments:    callback    -   Callback function that is called when the asynchronous process completes.
713                 recvBuf     -   Pointer to the data receive buffer.
714                                 Pay attention to the cache, because the ARM7 writes out data directly.
715                 recvBufSize -   Size of data receive buffer.
716 
717   Returns:      WMErrCode   -   Returns the processing result. Returns WM_ERRCODE_OPERATING if asynchronous processing started successfully. Afterwards, the asynchronous processing results will be passed to the callback.
718 
719 
720  *---------------------------------------------------------------------------*/
721 WMErrCode WM_StartDCF(WMCallbackFunc callback, WMDcfRecvBuf *recvBuf, u16 recvBufSize);
722 
723 /*---------------------------------------------------------------------------*
724   Name:         WM_SetDCFData
725 
726   Description:  Reserves data for sending by infrastructure-mode communication.
727 
728   Arguments:    callback    -   Callback function that is called when the asynchronous process completes.
729                 destAdr     -   Pointer to the buffer that shows the MAC address of the communication partner.
730                 sendData    -   Pointer to the data to reserve send.
731                                 NOTE: The instance of the data reserved for sending is forcibly stored in the cache.
732 
733                 sendDataSize -  Size of the data to reserve send.
734 
735   Returns:      WMErrCode   -   Returns the processing result. Returns WM_ERRCODE_OPERATING if asynchronous processing started successfully. Afterwards, the asynchronous processing results will be passed to the callback.
736 
737 
738  *---------------------------------------------------------------------------*/
739 WMErrCode WM_SetDCFData(WMCallbackFunc callback,
740                         const u8 *destAdr, const u16 *sendData, u16 sendDataSize);
741 
742 /*---------------------------------------------------------------------------*
743   Name:         WM_EndDCF
744 
745   Description:  Stops infrastructure-mode communications.
746 
747   Arguments:    callback    -   Callback function that is called when the asynchronous process completes.
748 
749   Returns:      WMErrCode   -   Returns the processing result. Returns WM_ERRCODE_OPERATING if asynchronous processing started successfully. Afterwards, the asynchronous processing results will be passed to the callback.
750 
751 
752  *---------------------------------------------------------------------------*/
753 WMErrCode WM_EndDCF(WMCallbackFunc callback);
754 
755 /*---------------------------------------------------------------------------*
756   Name:         WM_SetWEPKey
757 
758   Description:  Sets encryption functionality and the encryption key.
759 
760   Arguments:    callback    -   Callback function that is called when the asynchronous process completes.
761                 wepmode     -   0: No encryption feature.
762                                 1: RC4 (40-bit) encryption mode.
763                                 2: RC4 (104-bit) encryption mode.
764                                 3: RC4 (128-bit) encryption mode.
765                 wepkey      -   Pointer to the encryption key data (80 bytes).
766                                 Key data consists of 4 pieces of data, each 20 bytes long.
767                                 Of each 20 byte piece, in 40-bit mode 5 bytes are used, in 104-bit mode 13 bytes are used, and in 128-bit mode 16 bytes are used.
768 
769 
770 
771 
772                                 The data instance is forcibly stored in the cache.
773 
774   Returns:      WMErrCode   -   Returns the processing result. Returns WM_ERRCODE_OPERATING if asynchronous processing started successfully. Afterwards, the asynchronous processing results will be passed to the callback.
775 
776 
777  *---------------------------------------------------------------------------*/
778 WMErrCode WM_SetWEPKey(WMCallbackFunc callback, u16 wepmode, const u16 *wepkey);
779 
780 /*---------------------------------------------------------------------------*
781   Name:         WM_SetWEPKeyEx
782 
783   Description:  Sets encryption functionality, encryption key, and encryption key ID.
784 
785   Arguments:    callback    -   Callback function that is called when the asynchronous process completes.
786                 wepmode     -   0: No encryption feature.
787                                 1: RC4 (40-bit) encryption mode.
788                                 2: RC4 (104-bit) encryption mode.
789                                 3: RC4 (128-bit) encryption mode.
790                 wepkeyid    -   Selects which of 4 specified wepkeys to use.
791                                 Specify using 0-3.
792                 wepkey      -   Pointer to the encryption key data (80 bytes).
793                                 Key data consists of 4 pieces of data, each 20 bytes long.
794                                 Of each 20 bytes,
795                                  5 bytes in 40-bit mode
796                                 13 bytes in 104-bit mode
797                                 and 16 bytes in 128-bit mode
798                                 are used.
799                                 The data instance is forcibly stored in the cache.
800 
801   Returns:      WMErrCode   -   Returns the processing result.
802                                 Returns WM_ERRCODE_OPERATING if asynchronous processing started successfully. Afterwards, the asynchronous processing results will be passed to the callback.
803 
804  *---------------------------------------------------------------------------*/
805 WMErrCode WM_SetWEPKeyEx(WMCallbackFunc callback, u16 wepmode, u16 wepkeyid, const u8 *wepkey);
806 
807 /*---------------------------------------------------------------------------*
808   Name:         WM_ReadMPData
809 
810   Description:  Extracts only the data of the specified child from all of the received data. Synchronous function.
811 
812   Arguments:    header      -   Pointer that indicates the entire body of received data.
813                 aid         -   AID of the child for which to extract data.
814 
815   Returns:      WMMpRecvData* - Returns a pointer to the data received from the corresponding child.
816                                 Returns NULL if extraction fails.
817  *---------------------------------------------------------------------------*/
818 WMMpRecvData *WM_ReadMPData(const WMMpRecvHeader *header, u16 aid);
819 
820 /*---------------------------------------------------------------------------*
821   Name:         WM_StartDataSharing
822 
823   Description:  Enables the data sharing feature. Synchronous function.
824                 By performing MP communication after enabling the feature, data sharing communications will be carried out by piggybacking on the MP communications.
825 
826 
827   Arguments:    dsInfo      -   WMDataSharingInfo structure.
828                 port:         Number of the port to use.
829                 aidBitmap:     AIDs of the data sharing partners.
830                 dataLength:     Data length of shared memory. (Specify an even number of bytes.)
831                 doubleMode:     Specify TRUE if using WM_StepDataSharing in every frame.
832 
833   Returns:      WMErrCode   -   Returns the processing result. Returns WM_ERRCODE_OPERATING if asynchronous processing started successfully. Afterwards, the asynchronous processing results will be passed to the callback.
834 
835 
836  *---------------------------------------------------------------------------*/
837 WMErrCode WM_StartDataSharing(WMDataSharingInfo *dsInfo,
838                               u16 port, u16 aidBitmap, u16 dataLength, BOOL doubleMode);
839 
840 /*---------------------------------------------------------------------------*
841   Name:         WM_EndDataSharing
842 
843   Description:  Disables the data sharing feature. Synchronous function.
844 
845   Arguments:    dsInfo      -   WMDataSharingInfo structure.
846 
847   Returns:      WMErrCode   -   Returns the processing result.
848  *---------------------------------------------------------------------------*/
849 WMErrCode WM_EndDataSharing(WMDataSharingInfo *dsInfo);
850 
851 /*---------------------------------------------------------------------------*
852   Name:         WM_StepDataSharing
853 
854   Description:  Advances data sharing by one synchronization. Synchronous function.
855 
856   Arguments:    dsInfo      -   WMDataSharingInfo structure.
857                 sendData    -   The send data to be shared.
858                 receiveData -   The received shared data.
859 
860   Returns:      WMErrCode   -   Returns the processing result.
861                          *_SUCCESS: Shared data send/receive successful.
862                          *_NO_DATASET: Shared data not yet received.
863  *---------------------------------------------------------------------------*/
864 WMErrCode WM_StepDataSharing(WMDataSharingInfo *dsInfo,
865                              const u16 *sendData, WMDataSet *receiveData);
866 
867 /*---------------------------------------------------------------------------*
868   Name:         WM_GetSharedDataAddress
869 
870   Description:  Acquires the address of a particular AID that is contained in data received through data sharing.
871                 Synchronous function.
872 
873   Arguments:    dsInfo      -   WMDataSharingInfo structure.
874                 receiveData -   The received shared data.
875                 aid:           AID.
876 
877   Returns:      u16* :     The address of the received data. If it does not exist, returns NULL.
878  *---------------------------------------------------------------------------*/
879 u16    *WM_GetSharedDataAddress(WMDataSharingInfo *dsInfo, WMDataSet *receiveData, u16 aid);
880 
881 /*---------------------------------------------------------------------------*
882   Name:         WM_StartKeySharing
883 
884   Description:  Enables the key sharing feature.
885                 By performing MP communication after enabling the feature, key sharing communications will be carried out by piggybacking on the MP communications.
886 
887 
888   Arguments:    buf         -   Pointer to the buffer that stores the key information.
889                                 Its instance is a pointer to a WMDataSharingInfo structure.
890                 port:        Number of port to use.
891 
892   Returns:      WMErrCode   -   Returns the processing result.
893  *---------------------------------------------------------------------------*/
894 WMErrCode WM_StartKeySharing(WMKeySetBuf *buf, u16 port);
895 
896 /*---------------------------------------------------------------------------*
897   Name:         WM_EndKeySharing
898 
899   Description:  Disables the key sharing feature.
900 
901   Arguments:    buf         -   Pointer to the buffer that stores the key information.
902                                 Its instance is a pointer to a WMDataSharingInfo structure.
903 
904   Returns:      WMErrCode   -   Returns the processing result. Returns WM_ERRCODE_OPERATING if asynchronous processing started successfully. Afterwards, the asynchronous processing results will be passed to the callback.
905 
906 
907  *---------------------------------------------------------------------------*/
908 WMErrCode WM_EndKeySharing(WMKeySetBuf *buf);
909 
910 /*---------------------------------------------------------------------------*
911   Name:         WM_GetKeySet
912 
913   Description:  Loads one key set data that has been key shared.
914 
915   Arguments:    buf         -   Pointer to the buffer that stores the key information.
916                                 Its instance is a pointer to a WMDataSharingInfo structure.
917                 keySet      -   Pointer to the buffer that reads out the key set.
918                                 Specify a buffer other than the one provided by WM_StartKeySharing.
919 
920 
921   Returns:      MWErrCode   -   Returns process results.
922  *---------------------------------------------------------------------------*/
923 WMErrCode WM_GetKeySet(WMKeySetBuf *buf, WMKeySet *keySet);
924 
925 /*---------------------------------------------------------------------------*
926   Name:         WM_SetGameInfo
927 
928   Description:  Sets the game information. Initial value is set by WM_SetParentParameter. Use this function to change the game information.
929 
930 
931   Arguments:    callback    -   Callback function that is called when the asynchronous process completes.
932                 userGameInfo     - Pointer to the user game information.
933                 userGameInfoSize - Size of the user game information.
934                 ggid        -   Game group ID
935                 tgid        -   Temporary group ID
936                 attr        -   Flag group. Sets the OR of the following flags.
937                                     WM_ATTR_FLAG_ENTRY - Entry permitted
938                                     WM_ATTR_FLAG_MB    - Accepting multiboot
939                                     WM_ATTR_FLAG_KS    - Key sharing
940                                     WM_ATTR_FLAG_CS    - Continuous transfer mode
941   Returns:      WMErrCode   -   Returns the processing result. Returns WM_ERRCODE_OPERATING if asynchronous processing started successfully. Afterwards, the asynchronous processing results will be passed to the callback.
942 
943 
944  *---------------------------------------------------------------------------*/
945 WMErrCode WM_SetGameInfo(WMCallbackFunc callback,
946                          const u16 *userGameInfo, u16 userGameInfoSize,
947                          u32 ggid, u16 tgid, u8 attr);
948 
949 /*---------------------------------------------------------------------------*
950   Name:         WM_SetBeaconIndication
951 
952   Description:  Switches the beacon send/receive indication between enabled/disabled.
953 
954   Arguments:    callback    -   Callback function that is called when the asynchronous process completes.
955                 flag        -   0: Disabled
956                                 1: Enabled
957 
958   Returns:      WMErrCode   -   Returns the processing result. Returns WM_ERRCODE_OPERATING if asynchronous processing started successfully. Afterwards, the asynchronous processing results will be passed to the callback.
959 
960 
961  *---------------------------------------------------------------------------*/
962 WMErrCode WM_SetBeaconIndication(WMCallbackFunc callback, u16 flag);
963 
964 #ifdef  WM_ENABLE_TESTMODE
965 /*---------------------------------------------------------------------------*
966   Name:         WM_StartTestMode
967 
968   Description:  Starts communication in test mode.
969 
970   Arguments:    callback    -   Callback function that is called when the asynchronous process completes.
971                 signal      -   0: No modulation (data=0)
972                                 1: No modulation (data=1)
973                                 2: PN15-stage
974                                 3: 01 pattern (with scramble)
975                                 4: 01 pattern (without scramble)
976                 rate        -   1: 1Mbps
977                                 2: 2Mbps
978                 channel     -   Specifies the channel to send data (1 to 14).
979 
980   Returns:      WMErrCode   -   Returns the processing result.
981                                 Returns WM_ERRCODE_OPERATING if asynchronous processing started successfully. Afterwards, the asynchronous processing results will be passed to the callback.
982 
983  *---------------------------------------------------------------------------*/
984 WMErrCode WM_StartTestMode(WMCallbackFunc callback, u16 signal, u16 rate, u16 channel);
985 
986 /*---------------------------------------------------------------------------*
987   Name:         WM_StopTestMode
988 
989   Description:  Stops communication in test mode.
990 
991   Arguments:    callback    -   Callback function that is called when the asynchronous process completes.
992 
993   Returns:      WMErrCode   -   Returns the processing result. Returns WM_ERRCODE_OPERATING if asynchronous processing started successfully. Afterwards, the asynchronous processing results will be passed to the callback.
994 
995 
996  *---------------------------------------------------------------------------*/
997 WMErrCode WM_StopTestMode(WMCallbackFunc callback);
998 
999 /*---------------------------------------------------------------------------*
1000   Name:         WM_StartTestRxMode
1001 
1002   Description:  Starts receiving data in test mode.
1003 
1004   Arguments:    callback    -   Callback function that is called when the asynchronous process completes.
1005                 channel     -   Specifies the channel for receiving data (1 to 14).
1006 
1007   Returns:      WMErrCode   -   Returns the processing result.
1008                                 Returns WM_ERRCODE_OPERATING if asynchronous processing started successfully. Afterwards, the asynchronous processing results will be passed to the callback.
1009 
1010  *---------------------------------------------------------------------------*/
1011 WMErrCode WM_StartTestRxMode(WMCallbackFunc callback, u16 channel);
1012 
1013 /*---------------------------------------------------------------------------*
1014   Name:         WM_StopTestRxMode
1015 
1016   Description:  Stops receiving data in test mode.
1017 
1018   Arguments:    callback    -   Callback function that is called when the asynchronous process completes.
1019 
1020   Returns:      WMErrCode   -   Returns the processing result. Returns WM_ERRCODE_OPERATING if asynchronous processing started successfully. Afterwards, the asynchronous processing results will be passed to the callback.
1021 
1022 
1023  *---------------------------------------------------------------------------*/
1024 WMErrCode WM_StopTestRxMode(WMCallbackFunc callback);
1025 
1026 #endif
1027 
1028 /*---------------------------------------------------------------------------*
1029   Name:         WM_SetLifeTime
1030 
1031   Description:  Sets the lifetime.
1032 
1033   Arguments:    callback    -   Callback function that is called when the asynchronous process completes.
1034                 tableNumber -   Number of CAM table that sets the lifetime.
1035                                 (With 0xFFFF, all tables)
1036                 camLifeTime:     CAM lifetime. (in 100-ms units: disable with 0xFFFF)
1037                 frameLifeTime:   Beacon interval of the lifetime of the frame to be set.
1038                                 (in 100-ms units: disable with 0xFFFF)
1039                 camLifeTime:    Lifetime of the MP communication. (in 100-ms units: disable with 0xFFFF)
1040 
1041   Returns:      WMErrCode   -   Returns the processing result. Returns WM_ERRCODE_OPERATING if asynchronous processing started successfully. Afterwards, the asynchronous processing results will be passed to the callback.
1042 
1043 
1044  *---------------------------------------------------------------------------*/
1045 WMErrCode WM_SetLifeTime(WMCallbackFunc callback,
1046                          u16 tableNumber, u16 camLifeTime, u16 frameLifeTime, u16 mpLifeTime);
1047 
1048 /*---------------------------------------------------------------------------*
1049   Name:         WM_MeasureChannel
1050 
1051   Description:  Measures the usage status of a channel.
1052 
1053   Arguments:    callback    -   Callback function that is called when the asynchronous process completes.
1054                 ccaMode     -   CCA operation mode.
1055                                 0: Carrier sense only. ED threshold value is ignored.
1056                                 1: Valid with ED threshold value only.
1057                                 2: AND of carrier sense and ED threshold value.
1058                                 3: OR of carrier sense and ED threshold value.
1059                 EDThreshold -   ED threshold (0 thru 61): -60dBm thru -80dBm
1060                 channel     -   Channel to investigate.
1061                                 (Only one channel with one call of MeasureChannel)
1062                 measureTime -   Time to investigate.
1063 
1064   Returns:      WMErrCode   -   Returns the processing result.
1065                                 Returns WM_ERRCODE_OPERATING if asynchronous processing started successfully. Afterwards, the asynchronous processing results will be passed to the callback.
1066 
1067  *---------------------------------------------------------------------------*/
1068 WMErrCode WM_MeasureChannel(WMCallbackFunc callback,
1069                             u16 ccaMode, u16 edThreshold, u16 channel, u16 measureTime);
1070 
1071 /*---------------------------------------------------------------------------*
1072   Name:         WM_InitWirelessCounter
1073 
1074   Description:  Initializes WirelessCounter.
1075 
1076   Arguments:    callback    -   Callback function that is called when the asynchronous process completes.
1077 
1078   Returns:      WMErrCode   -   Returns the processing result. Returns WM_ERRCODE_OPERATING if asynchronous processing started successfully. Afterwards, the asynchronous processing results will be passed to the callback.
1079 
1080 
1081  *---------------------------------------------------------------------------*/
1082 WMErrCode WM_InitWirelessCounter(WMCallbackFunc callback);
1083 
1084 /*---------------------------------------------------------------------------*
1085   Name:         WM_GetWirelessCounter
1086 
1087   Description:  Obtains the Wireless NIC send/receive frame count and send/receive error frame count.
1088 
1089   Arguments:    callback    -   Callback function that is called when the asynchronous process completes.
1090 
1091   Returns:      WMErrCode   -   Returns the processing result. Returns WM_ERRCODE_OPERATING if asynchronous processing started successfully. Afterwards, the asynchronous processing results will be passed to the callback.
1092 
1093 
1094  *---------------------------------------------------------------------------*/
1095 WMErrCode WM_GetWirelessCounter(WMCallbackFunc callback);
1096 
1097 /*---------------------------------------------------------------------------*
1098   Name:         WM_GetAllowedChannel
1099 
1100   Description:  Obtains the channel that was permitted to use for the communication. Synchronous function.
1101 
1102   Arguments:    None.
1103 
1104   Returns:      u16 -   Returns the bit field of the permitted channel.
1105                         The least significant bit indicates channel 1, and the most significant bit indicates channel 16.
1106                         If a channel's corresponding bit is set to 1, it is usable; otherwise, its use is prohibited.
1107                         Typically, a value is returned with several of the bits corresponding to channels 1-13 set to 1.
1108                         If 0x0000 is returned, no channels can be used and wireless features are therefore prohibited.
1109 
1110                         Also, in case the function failed, such as when it is not yet initialized, 0x8000 is returned.
1111  *---------------------------------------------------------------------------*/
1112 u16     WM_GetAllowedChannel(void);
1113 
1114 #ifdef  WM_PRECALC_ALLOWEDCHANNEL
1115 /*---------------------------------------------------------------------------*
1116   Name:         WM_IsExistAllowedChannel
1117 
1118   Description:  Checks if the channel that was permitted to be used for communication actually exists.
1119                 Possible to determine it properly even before the initialization of WM library.
1120 
1121   Arguments:    None.
1122 
1123   Returns:      BOOL: Returns TRUE if you are permitted to use some channels, and FALSE otherwise.
1124 
1125  *---------------------------------------------------------------------------*/
1126 BOOL    WM_IsExistAllowedChannel(void);
1127 #endif
1128 
1129 /*---------------------------------------------------------------------------*
1130   Name:         WM_SetEntry
1131 
1132   Description:  Switches between accepting and refusing a connection from a child as a parent.
1133 
1134   Arguments:    callback    -   Callback function that is called when the asynchronous process completes.
1135                 enabled:        Entry permitted / not permitted flag. TRUE: permitted, FALSE: not permitted.
1136 
1137   Returns:      WMErrCode   -   Returns the processing result. Returns WM_ERRCODE_OPERATING if asynchronous processing started successfully. Afterwards, the asynchronous processing results will be passed to the callback.
1138 
1139 
1140  *---------------------------------------------------------------------------*/
1141 WMErrCode WM_SetEntry(WMCallbackFunc callback, BOOL enabled);
1142 
1143 /*---------------------------------------------------------------------------*
1144   Name:         WM_GetLinkLevel
1145 
1146   Description:  Gets link level during communication. Synchronous function.
1147 
1148   Arguments:    None.
1149 
1150   Returns:      WMLinkLevel -   Returns the link level rated in four levels.
1151  *---------------------------------------------------------------------------*/
1152 WMLinkLevel WM_GetLinkLevel(void);
1153 
1154 
1155 /*---------------------------------------------------------------------------*
1156   Name:         WMi_SetBeaconPeriod
1157 
1158   Description:  Changes the beacon period.
1159 
1160   Arguments:    callback    -   Callback function that is called when the asynchronous process completes.
1161                 beaconPeriod -  Beacon period (10 to 1000 TU (1024 microseconds))
1162 
1163   Returns:      WMErrCode   -   Returns the processing result.
1164                                 Returns WM_ERRCODE_OPERATING if asynchronous processing started successfully. Afterwards, the asynchronous processing results will be passed to the callback.
1165 
1166  *---------------------------------------------------------------------------*/
1167 WMErrCode WMi_SetBeaconPeriod(WMCallbackFunc callback, u16 beaconPeriod);
1168 /* As of 2004/10/18, this function was changed to undisclosed due to the problem found when the beacon period was changed while communicating.
1169     */
1170 
1171 
1172 /*---------------------------------------------------------------------------*
1173   Name:         WM_GetDispersionBeaconPeriod
1174 
1175   Description:  Obtains the beacon period value that should be set when operating as a parent.
1176                 Synchronous function.
1177 
1178   Arguments:    None.
1179 
1180   Returns:      u16 -   Beacon period value that should be set (ms).
1181  *---------------------------------------------------------------------------*/
1182 u16     WM_GetDispersionBeaconPeriod(void);
1183 
1184 /*---------------------------------------------------------------------------*
1185   Name:         WM_GetDispersionScanPeriod
1186 
1187   Description:  Obtains the search limit time that should be set for a child to search for a parent.
1188                 Synchronous function.
1189 
1190   Arguments:    None.
1191 
1192   Returns:      u16 -   Search limit time that should be set (ms).
1193  *---------------------------------------------------------------------------*/
1194 u16     WM_GetDispersionScanPeriod(void);
1195 
1196 /*---------------------------------------------------------------------------*
1197   Name:         WM_GetOtherElements
1198 
1199   Description:  Gets the extended elements in the beacon.
1200                 Synchronous function.
1201 
1202   Arguments:    bssDesc - Parent information structure.
1203                           Specifies the structure obtained with WM_StartScan(Ex).
1204 
1205   Returns:      WMOtherElements - Extended element structure.
1206  *---------------------------------------------------------------------------*/
1207 WMOtherElements WM_GetOtherElements(WMBssDesc *bssDesc);
1208 
1209 /*---------------------------------------------------------------------------*
1210   Name:         WM_GetNextTgid
1211 
1212   Description:  Gets the automatically generated, unique TGID value.
1213                 Synchronous function.
1214                 This function internally calls RTC_Init().
1215 
1216   Arguments:    None.
1217 
1218   Returns:      The first time it is called, it returns a TGID that was generated based on the RTC; thereafter, it returns the value returned the previous time incremented by 1.
1219 
1220  *---------------------------------------------------------------------------*/
1221 u16     WM_GetNextTgid(void);
1222 
1223 /*---------------------------------------------------------------------------*
1224   Name:         WM_SetPowerSaveMode()
1225 
1226   Description:  Changes the power save mode.
1227 
1228   Arguments:    callback    -   Callback function that is called when the asynchronous process completes.
1229                 powerSave   -   When using power save mode, TRUE. When not using it, FALSE.
1230 
1231   Returns:      WMErrCode   -   Returns the processing result. Returns WM_ERRCODE_OPERATING if asynchronous processing started successfully. Afterwards, the asynchronous processing results will be passed to the callback.
1232 
1233 
1234  *---------------------------------------------------------------------------*/
1235 WMErrCode WM_SetPowerSaveMode(WMCallbackFunc callback, BOOL powerSave);
1236 
1237 /*---------------------------------------------------------------------------*
1238   Name:         WMi_IsMP
1239 
1240   Description:  Gets current MP communication state.
1241 
1242   Arguments:    None.
1243 
1244   Returns:      TRUE if in MP communication state.
1245  *---------------------------------------------------------------------------*/
1246 BOOL    WMi_IsMP(void);
1247 
1248 /*---------------------------------------------------------------------------*
1249   Name:         WM_GetAID
1250 
1251   Description:  Gets current AID.
1252                 Returns a valid value only when the state is one of PARENT, MP_PARENT, CHILD, or MP_CHILD.
1253 
1254 
1255   Arguments:    None.
1256 
1257   Returns:      AID
1258  *---------------------------------------------------------------------------*/
1259 u16     WM_GetAID(void);
1260 
1261 /*---------------------------------------------------------------------------*
1262   Name:         WM_GetConnectedAIDs
1263 
1264   Description:  Gets the currently connected partners in bitmap format.
1265                 Returns a valid value only when the state is one of PARENT, MP_PARENT, CHILD, or MP_CHILD.
1266 
1267                 For a child device, returns 0x0001 when the child is connected to a parent.
1268 
1269   Arguments:    None.
1270 
1271   Returns:      Bitmap of AIDs of connected partners.
1272  *---------------------------------------------------------------------------*/
1273 u16     WM_GetConnectedAIDs(void);
1274 
1275 /*---------------------------------------------------------------------------*
1276   Name:         WMi_GetMPReadyAIDs
1277 
1278   Description:  From among the currently connected parties, gets a list in bitmap format of the AIDs of parties which can receive MP.
1279 
1280                 Returns a valid value only when the state is one of PARENT, MP_PARENT, CHILD, or MP_CHILD.
1281 
1282                 For a child device, returns 0x0001 when the child is connected to a parent.
1283 
1284   Arguments:    None.
1285 
1286   Returns:      Bitmap of the AIDs of partners with which MP is starting.
1287  *---------------------------------------------------------------------------*/
1288 u16     WMi_GetMPReadyAIDs(void);
1289 
1290 /*---------------------------------------------------------------------------*
1291   Name:         WM_GetWirelessCommFlag
1292 
1293   Description:  Checks whether wireless communications are currently in a usable state.
1294 
1295   Arguments:    None.
1296 
1297   Returns:      WM_WIRELESS_COMM_FLAG_OFF: Wireless communications are not permitted
1298                 WM_WIRELESS_COMM_FLAG_ON: Wireless communications are permitted
1299                 WM_WIRELESS_COMM_FLAG_UNKNOWN: Indeterminate because the program is running on a DS
1300  *---------------------------------------------------------------------------*/
1301 u8      WM_GetWirelessCommFlag(void);
1302 
1303 // for debugging
1304 void    WMi_DebugPrintSendQueue(WMPortSendQueue *queue);
1305 void    WMi_DebugPrintAllSendQueue(void);
1306 const WMStatus *WMi_GetStatusAddress(void);
1307 BOOL    WMi_CheckMpPacketTimeRequired(u16 parentSize, u16 childSize, u8 childs);
1308 
1309 
1310 /*===========================================================================*/
1311 
1312 /*---------------------------------------------------------------------------*
1313   Name:         WM_SIZE_MP_PARENT_RECEIVE_BUFFER
1314 
1315   Description:  Calculates parent receive buffer size.
1316 
1317   Arguments:    childMaxSize:   Maximum number of bytes of data you want to receive from a child.
1318                 maxEntry:      Number of children you want to have connected.
1319                 ksFlag:        Boolean value for whether to perform key sharing.
1320 
1321   Returns:      int:       Size of the receive buffer that must be passed to the WM_StartMP.
1322  *---------------------------------------------------------------------------*/
1323 #define WM_SIZE_MP_PARENT_RECEIVE_BUFFER( childMaxSize, maxEntry, ksFlag ) \
1324             (((sizeof( WMMpRecvHeader ) - sizeof( WMMpRecvData ) + \
1325             ( ( sizeof( WMMpRecvData ) + (childMaxSize) + WM_HEADER_CHILD_MAX_SIZE - 2 + 2/*MACBUG*/ + ((ksFlag) ? WM_SIZE_KS_CHILD_DATA + WM_SIZE_MP_CHILD_PADDING : 0) ) * (maxEntry) ) \
1326              + 31) & ~0x1f) * 2)
1327 
1328 /*---------------------------------------------------------------------------*
1329   Name:         WM_SIZE_MP_CHILD_RECEIVE_BUFFER
1330 
1331   Description:  Calculates the size of the child receive buffer.
1332 
1333   Arguments:    parentMaxSize:   Maximum number of bytes of data you want to receive from the parent.
1334                 ksFlag:        Boolean value for whether to perform key sharing.
1335 
1336   Returns:      int:       Size of the receive buffer that must be passed to the WM_StartMP.
1337  *---------------------------------------------------------------------------*/
1338 #define WM_SIZE_MP_CHILD_RECEIVE_BUFFER( parentMaxSize, ksFlag ) \
1339             (((sizeof( WMMpRecvBuf ) + (parentMaxSize) + WM_HEADER_PARENT_MAX_SIZE - 4 + ((ksFlag) ? WM_SIZE_KS_PARENT_DATA + WM_SIZE_MP_PARENT_PADDING : 0) + 31) & ~0x1f) * 2)
1340 
1341 /*---------------------------------------------------------------------------*
1342   Name:         WM_SIZE_MP_PARENT_SEND_BUFFER
1343 
1344   Description:  Calculates the size of the parent send buffer.
1345 
1346   Arguments:    parentMaxSize:   Maximum number of bytes of data you want to send.
1347                 ksFlag:        Boolean value for whether to perform key sharing.
1348 
1349   Returns:      int:      Size of send buffer that must be passed to WM_StartMP.
1350  *---------------------------------------------------------------------------*/
1351 #define WM_SIZE_MP_PARENT_SEND_BUFFER( parentMaxSize, ksFlag ) \
1352             (((parentMaxSize) + WM_HEADER_PARENT_MAX_SIZE + ((ksFlag) ? WM_SIZE_KS_PARENT_DATA + WM_SIZE_MP_PARENT_PADDING : 0) + 31) & ~0x1f)
1353 
1354 /*---------------------------------------------------------------------------*
1355   Name:         WM_SIZE_MP_CHILD_SEND_BUFFER
1356 
1357   Description:  Calculates the size of the child send buffer.
1358 
1359   Arguments:    childMaxSize:   Maximum number of bytes of data you want to send.
1360                 ksFlag:        Boolean value for whether to perform key sharing.
1361 
1362   Returns:      int:      Size of send buffer that must be passed to WM_StartMP.
1363  *---------------------------------------------------------------------------*/
1364 #define WM_SIZE_MP_CHILD_SEND_BUFFER( childMaxSize, ksFlag ) \
1365             (((childMaxSize) + WM_HEADER_CHILD_MAX_SIZE + ((ksFlag) ? WM_SIZE_KS_CHILD_DATA + WM_SIZE_MP_CHILD_PADDING : 0) + 31) & ~0x1f)
1366 
1367 /*---------------------------------------------------------------------------*
1368   Name:         WM_SIZE_DCF_CHILD_SEND_BUFFER
1369 
1370   Description:  Calculates the size of the DCF child's send buffer.
1371 
1372   Arguments:    childMaxSize:   Maximum number of bytes of data you want to send.
1373 
1374   Returns:      int:      Size of send buffer that must be passed to WM_StartDCF.
1375  *---------------------------------------------------------------------------*/
1376 #define WM_SIZE_DCF_CHILD_SEND_BUFFER( childMaxSize ) \
1377             (((childMaxSize) + WM_SIZE_MADATA_HEADER + 31) & ~0x1f)
1378 
1379 #define WM_SIZE_CHILD_SEND_BUFFER WM_SIZE_MP_CHILD_SEND_BUFFER
1380 #define WM_SIZE_CHILD_RECEIVE_BUFFER WM_SIZE_MP_CHILD_RECEIVE_BUFFER
1381 #define WM_SIZE_PARENT_SEND_BUFFER WM_SIZE_MP_PARENT_SEND_BUFFER
1382 #define WM_SIZE_PARENT_RECEIVE_BUFFER WM_SIZE_MP_PARENT_RECEIVE_BUFFER
1383 
1384 
1385 /*===========================================================================*/
1386 
1387 /*---------------------------------------------------------------------------*
1388   Name:         WM_ConvGgid32to16
1389 
1390   Description:  Converts game group ID from "32-bit type" to "16-bit x 2 type."
1391 
1392   Arguments:    src:        Pointer to the conversion source GGID expressed in 32 bits.
1393                 dest:      Pointer to the buffer that will store the converted GGID.
1394                             A 4-byte piece of data will be written beginning from this address.
1395 
1396   Returns:      None.
1397  *---------------------------------------------------------------------------*/
WM_ConvGgid32to16(u32 * src,u16 * dst)1398 static inline void WM_ConvGgid32to16(u32 *src, u16 *dst)
1399 {
1400     dst[0] = (u16)(*src & 0x0000ffff);
1401     dst[1] = (u16)(*src >> 16);
1402 }
1403 
1404 /*---------------------------------------------------------------------------*
1405   Name:         WM_ConvGgid16to32
1406 
1407   Description:  Converts game group ID from 16-bit x 2 type to 32-bit type.
1408 
1409   Arguments:    src:       Pointer to the conversion source GGID that is expressed by 16-bit arrays.
1410                 dest:      Pointer to the buffer that will store the converted GGID.
1411                             A 4-byte piece of data will be written beginning from this address.
1412 
1413   Returns:      None.
1414  *---------------------------------------------------------------------------*/
WM_ConvGgid16to32(u16 * src,u32 * dst)1415 static inline void WM_ConvGgid16to32(u16 *src, u32 *dst)
1416 {
1417     *dst = ((u32)src[1] << 16) | src[0];
1418 }
1419 
1420 /*---------------------------------------------------------------------------*
1421   Name:         WM_IsBssidEqual
1422 
1423   Description:  Checks whether 2 BSSIDs are equivalent.
1424 
1425   Arguments:    idp1:       Pointer to a BSSID that will be compared.
1426                 idp2:       Pointer to a BSSID that will be compared.
1427 
1428   Returns:      Returns TRUE if they are equivalent.
1429                 Returns FALSE if they differ.
1430  *---------------------------------------------------------------------------*/
WM_IsBssidEqual(const u8 * idp1,const u8 * idp2)1431 static inline BOOL WM_IsBssidEqual(const u8 *idp1, const u8 *idp2)
1432 {
1433     return ((*idp1 == *idp2) &&
1434             (*(idp1 + 1) == *(idp2 + 1)) &&
1435             (*(idp1 + 2) == *(idp2 + 2)) &&
1436             (*(idp1 + 3) == *(idp2 + 3)) &&
1437             (*(idp1 + 4) == *(idp2 + 4)) && (*(idp1 + 5) == *(idp2 + 5)));
1438 }
1439 
1440 
1441 /*---------------------------------------------------------------------------*
1442   Name:         WM_IsBssidEqual16
1443 
1444   Description:  Checks whether 2 BSSIDs are equivalent, in 2-byte chunks.
1445 
1446   Arguments:    idp1:       Pointer to a BSSID that will be compared. Must be two-byte aligned.
1447                 idp2:       Pointer to a BSSID that will be compared. Must be two-byte aligned.
1448 
1449   Returns:      Returns TRUE if they are equivalent.
1450                 Returns FALSE if they differ.
1451  *---------------------------------------------------------------------------*/
WM_IsBssidEqual16(const u8 * idp1,const u8 * idp2)1452 static inline BOOL WM_IsBssidEqual16(const u8 *idp1, const u8 *idp2)
1453 {
1454     SDK_ALIGN2_ASSERT(idp1);
1455     SDK_ALIGN2_ASSERT(idp2);
1456 
1457     return ((*(u16 *)idp1 == *(u16 *)idp2) &&
1458             (*(u16 *)(idp1 + 2) == *(u16 *)(idp2 + 2)) &&
1459             (*(u16 *)(idp1 + 4) == *(u16 *)(idp2 + 4)));
1460 }
1461 
1462 /*---------------------------------------------------------------------------*
1463   Name:         WM_CopyBssid
1464 
1465   Description:  Copies a BSSID.
1466 
1467   Arguments:    src:        Pointer to the BSSID copy source.
1468                 dest:       Pointer to the BSSID copy destination.
1469 
1470   Returns:      None.
1471  *---------------------------------------------------------------------------*/
WM_CopyBssid(const u8 * src,u8 * dst)1472 static inline void WM_CopyBssid(const u8 *src, u8 *dst)
1473 {
1474     *dst = *src;
1475     *(dst + 1) = *(src + 1);
1476     *(dst + 2) = *(src + 2);
1477     *(dst + 3) = *(src + 3);
1478     *(dst + 4) = *(src + 4);
1479     *(dst + 5) = *(src + 5);
1480 }
1481 
1482 /*---------------------------------------------------------------------------*
1483   Name:         WM_CopyBssid16
1484 
1485   Description:  Copies a BSSID in 2-byte chunks.
1486 
1487   Arguments:    src:        Pointer to the BSSID copy source. Must be two-byte aligned.
1488                 dest:       Pointer to the BSSID copy destination. Must be two-byte aligned.
1489 
1490   Returns:      None.
1491  *---------------------------------------------------------------------------*/
WM_CopyBssid16(const u8 * src,u8 * dst)1492 static inline void WM_CopyBssid16(const u8 *src, u8 *dst)
1493 {
1494     SDK_ALIGN2_ASSERT(src);
1495     SDK_ALIGN2_ASSERT(dst);
1496 
1497     *(u16 *)dst = *(u16 *)src;
1498     *(u16 *)(dst + 2) = *(u16 *)(src + 2);
1499     *(u16 *)(dst + 4) = *(u16 *)(src + 4);
1500 }
1501 
1502 /*---------------------------------------------------------------------------*
1503   Name:         WM_IsValidGameInfo
1504 
1505   Description:  Checks whether a GameInfo is supported.
1506 
1507   Arguments:    gameInfo:   Pointer to WMGameInfo structure.
1508                 gameInfoLength:   Length of data at location specified by gameInfo.
1509 
1510   Returns:      Returns TRUE if the GameInfo is supported.
1511  *---------------------------------------------------------------------------*/
WM_IsValidGameInfo(const WMGameInfo * gameInfo,u16 gameInfoLength)1512 static inline BOOL WM_IsValidGameInfo(const WMGameInfo *gameInfo, u16 gameInfoLength)
1513 {
1514     return (gameInfoLength >= WM_GAMEINFO_LENGTH_MIN
1515             && gameInfo->magicNumber == WM_GAMEINFO_MAGIC_NUMBER);
1516 }
1517 
1518 /*---------------------------------------------------------------------------*
1519   Name:         WM_IsValidGameBeacon
1520 
1521   Description:  Checks whether a beacon is from a parent device for DS wireless play.
1522 
1523   Arguments:    bssDesc:   Pointer to WMBssDesc structure that contains the beacon information.
1524 
1525   Returns:      If the beacon is from a DS wireless play parent, TRUE.
1526  *---------------------------------------------------------------------------*/
WM_IsValidGameBeacon(const WMBssDesc * bssDesc)1527 static inline BOOL WM_IsValidGameBeacon(const WMBssDesc *bssDesc)
1528 {
1529     return WM_IsValidGameInfo(&bssDesc->gameInfo, bssDesc->gameInfoLength);
1530 }
1531 
1532 /*---------------------------------------------------------------------------*
1533   Name:         WMi_IsDisconnectReasonFromMyself
1534 
1535   Description:  Determines whether the reason for WM_STATECODE_DISCONNECTED is that the unit initiated the disconnection itself.
1536 
1537 
1538   Arguments:    reason:   The reason member of WMStartParentCallback or WMPortRecvCallback.
1539 
1540   Returns:      True if this device caused disconnection itself by calling a WM function; FALSE if it was disconnected by the other party or was disconnected due to a communication error.
1541 
1542  *---------------------------------------------------------------------------*/
WMi_IsDisconnectReasonFromMyself(u16 reason)1543 static inline BOOL WMi_IsDisconnectReasonFromMyself(u16 reason)
1544 {
1545     return (reason >= WM_DISCONNECT_REASON_FROM_MYSELF);
1546 }
1547 
1548 
1549 /*===========================================================================*/
1550 
1551 #ifdef  __cplusplus
1552 }       /* extern "C" */
1553 #endif
1554 
1555 #endif /* NITRO_WM_ARM9_WM_API_H_ */
1556 
1557 /*---------------------------------------------------------------------------*
1558   End of file
1559  *---------------------------------------------------------------------------*/
1560