1 /*---------------------------------------------------------------------------*
2 Project: TwlSDK - WM - libraries
3 File: wm_etc.c
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:: 2008-09-18#$
14 $Rev: 8573 $
15 $Author: okubata_ryoma $
16 *---------------------------------------------------------------------------*/
17
18 #include <nitro/wm.h>
19 #include "wm_arm9_private.h"
20
21
22 /*---------------------------------------------------------------------------*
23 Constant Definitions
24 *---------------------------------------------------------------------------*/
25 #define WM_SIZE_TEMP_USR_GAME_INFO_BUF 128
26
27
28 /*---------------------------------------------------------------------------*
29 Internal Variable Definitions
30 *---------------------------------------------------------------------------*/
31 static u32 tmpUserGameInfoBuf[WM_SIZE_TEMP_USR_GAME_INFO_BUF / sizeof(u32)] ATTRIBUTE_ALIGN(32);
32
33
34 #ifdef WM_ENABLE_TESTMODE
35 /*---------------------------------------------------------------------------*
36 Name: WM_StartTestMode
37
38 Description: Starts communication in test mode.
39
40 Arguments: callback - Callback function that is called when the asynchronous process completes.
41 signal: 0: No modulation (data=0), 1: No modulation (data=1), 2: PN15 sequence, 3: 01 pattern (with scrambling), 4: 01 pattern (without scrambling)
42
43 rate: 1: 1Mbps, 2: 2Mbps
44 channel - Specifies the channel to send data (1 to 14).
45
46 Returns: WMErrCode - Returns the processing result.
47 Returns WM_ERRCODE_OPERATING if asynchronous processing started successfully. Afterwards, the asynchronous processing results will be passed to the callback.
48
49 *---------------------------------------------------------------------------*/
WM_StartTestMode(WMCallbackFunc callback,u16 signal,u16 rate,u16 channel)50 WMErrCode WM_StartTestMode(WMCallbackFunc callback, u16 signal, u16 rate, u16 channel)
51 {
52 WMErrCode result;
53
54 // Cannot execute if not in IDLE state.
55 result = WMi_CheckState(WM_STATE_IDLE);
56 WM_CHECK_RESULT(result);
57
58 // Register callback function
59 WMi_SetCallbackTable(WM_APIID_START_TESTMODE, callback);
60
61 // Notify ARM7 with FIFO
62 {
63 WMStartTestModeReq Req;
64
65 Req.apiid = WM_APIID_START_TESTMODE;
66 Req.signal = signal;
67 Req.rate = rate;
68 Req.channel = channel;
69
70 result = WMi_SendCommandDirect(&Req, sizeof(Req));
71 if (result != WM_ERRCODE_SUCCESS)
72 {
73 return result;
74 }
75 }
76
77 return WM_ERRCODE_OPERATING;
78 }
79
80 /*---------------------------------------------------------------------------*
81 Name: WM_StopTestMode
82
83 Description: Stops communication in test mode.
84
85 Arguments: callback - Callback function that is called when the asynchronous process completes.
86
87 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.
88
89
90 *---------------------------------------------------------------------------*/
WM_StopTestMode(WMCallbackFunc callback)91 WMErrCode WM_StopTestMode(WMCallbackFunc callback)
92 {
93 WMErrCode result;
94
95 // Cannot run unless state is TESTMODE
96 result = WMi_CheckState(WM_STATE_TESTMODE);
97 WM_CHECK_RESULT(result);
98
99 // Register callback function
100 WMi_SetCallbackTable(WM_APIID_STOP_TESTMODE, callback);
101
102 // Notify ARM7 with FIFO
103 result = WMi_SendCommand(WM_APIID_STOP_TESTMODE, 0);
104 WM_CHECK_RESULT(result);
105
106 return WM_ERRCODE_OPERATING;
107 }
108
109 /*---------------------------------------------------------------------------*
110 Name: WM_StartTestRxMode
111
112 Description: Starts receiving data in test mode.
113
114 Arguments: callback - Callback function that is called when the asynchronous process completes.
115 channel - Specifies the channel for receiving data (1 to 14).
116
117 Returns: WMErrCode - Returns the processing result.
118 Returns WM_ERRCODE_OPERATING if asynchronous processing started successfully. Afterwards, the asynchronous processing results will be passed to the callback.
119
120 *---------------------------------------------------------------------------*/
WM_StartTestRxMode(WMCallbackFunc callback,u16 channel)121 WMErrCode WM_StartTestRxMode(WMCallbackFunc callback, u16 channel)
122 {
123 WMErrCode result;
124
125 // Cannot execute if not in IDLE state.
126 result = WMi_CheckState(WM_STATE_IDLE);
127 WM_CHECK_RESULT(result);
128
129 // Register callback function
130 WMi_SetCallbackTable(WM_APIID_START_TESTRXMODE, callback);
131
132 // Notify ARM7 with FIFO
133 {
134 WMStartTestRxModeReq Req;
135
136 Req.apiid = WM_APIID_START_TESTRXMODE;
137 Req.channel = channel;
138
139 result = WMi_SendCommandDirect(&Req, sizeof(Req));
140 if (result != WM_ERRCODE_SUCCESS)
141 {
142 return result;
143 }
144 }
145
146 return WM_ERRCODE_OPERATING;
147 }
148
149 /*---------------------------------------------------------------------------*
150 Name: WM_StopTestRxMode
151
152 Description: Stops receiving data in test mode.
153
154 Arguments: callback - Callback function that is called when the asynchronous process completes.
155
156 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.
157
158
159 *---------------------------------------------------------------------------*/
WM_StopTestRxMode(WMCallbackFunc callback)160 WMErrCode WM_StopTestRxMode(WMCallbackFunc callback)
161 {
162 WMErrCode result;
163
164 // Cannot run unless state is TESTMODE
165 result = WMi_CheckState(WM_STATE_TESTMODE_RX);
166 WM_CHECK_RESULT(result);
167
168 // Register callback function
169 WMi_SetCallbackTable(WM_APIID_STOP_TESTRXMODE, callback);
170
171 // Notify ARM7 with FIFO
172 result = WMi_SendCommand(WM_APIID_STOP_TESTRXMODE, 0);
173 WM_CHECK_RESULT(result);
174
175 return WM_ERRCODE_OPERATING;
176 }
177 #endif
178
179 /*---------------------------------------------------------------------------*
180 Name: WM_SetWEPKey
181
182 Description: Sets the encryption feature and encryption key.
183
184 Arguments: callback - Callback function that is called when the asynchronous process completes.
185 wepmode - 0: No encryption feature.
186 1: RC4 (40bit) encryption mode.
187 2: RC4 (104bit) encryption mode.
188 3: RC4 (128bit) encryption mode.
189 wepkey - Pointer to the encryption key data (80 bytes).
190 Key data consists of 4 pieces of data, each 20 bytes long.
191 Of each 20 byte piece, in 40-bit mode 5 bytes are used, in 104-bit mode 13 bytes, and in 128-bit mode 16 bytes are used.
192
193
194
195
196 The data entity is forcibly stored in cache.
197
198 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.
199
200
201 *---------------------------------------------------------------------------*/
WM_SetWEPKey(WMCallbackFunc callback,u16 wepmode,const u16 * wepkey)202 WMErrCode WM_SetWEPKey(WMCallbackFunc callback, u16 wepmode, const u16 *wepkey)
203 {
204 WMErrCode result;
205
206 // Confirm that wireless hardware has started
207 result = WMi_CheckIdle();
208 WM_CHECK_RESULT(result);
209
210 // Check parameters
211 if (wepmode > 3)
212 {
213 WM_WARNING("Parameter \"wepmode\" must be less than %d.\n", 3);
214 return WM_ERRCODE_INVALID_PARAM;
215 }
216
217 if (wepmode != WM_WEPMODE_NO)
218 {
219 // Check parameters
220 if (wepkey == NULL)
221 {
222 WM_WARNING("Parameter \"wepkey\" must not be NULL.\n");
223 return WM_ERRCODE_INVALID_PARAM;
224 }
225 if ((u32)wepkey & 0x01f)
226 {
227 // Alignment check is a warning only, not an error
228 WM_WARNING("Parameter \"wepkey\" is not 32-byte aligned.\n");
229 }
230
231 // Write out the specified buffer's cache
232 DC_StoreRange((void *)wepkey, WM_SIZE_WEPKEY);
233 }
234
235 // Register callback function
236 WMi_SetCallbackTable(WM_APIID_SET_WEPKEY, callback);
237
238 // Notify ARM7 with FIFO
239 result = WMi_SendCommand(WM_APIID_SET_WEPKEY, 2, (u32)wepmode, (u32)wepkey);
240 WM_CHECK_RESULT(result);
241
242 return WM_ERRCODE_OPERATING;
243 }
244
245 /*---------------------------------------------------------------------------*
246 Name: WM_SetWEPKeyEx
247
248 Description: Sets encryption functionality, encryption key, and encryption key ID.
249
250 Arguments: callback - Callback function that is called when the asynchronous process completes.
251 wepmode - 0: No encryption feature.
252 1: RC4 (40bit) encryption mode.
253 2: RC4 (104bit) encryption mode.
254 3: RC4 (128bit) encryption mode.
255 wepkeyid - Selects which of 4 specified wepkeys to use.
256 Specify using 0-3.
257 wepkey - Pointer to the encryption key data (80 bytes).
258 Key data consists of 4 pieces of data, each 20 bytes long.
259 Of each 20-byte set, the following data will be used.
260 5 bytes in 40-bit mode
261 13 bytes in 104-bit mode
262 16 bytes in 128-bit mode
263
264 The data entity is forcibly stored in cache.
265
266 Returns: WMErrCode - Returns the processing result.
267 Returns WM_ERRCODE_OPERATING if asynchronous processing started successfully. Afterwards, the asynchronous processing results will be passed to the callback.
268
269 *---------------------------------------------------------------------------*/
WM_SetWEPKeyEx(WMCallbackFunc callback,u16 wepmode,u16 wepkeyid,const u8 * wepkey)270 WMErrCode WM_SetWEPKeyEx(WMCallbackFunc callback, u16 wepmode, u16 wepkeyid, const u8 *wepkey)
271 {
272 WMErrCode result;
273
274 // Confirm that wireless hardware has started
275 result = WMi_CheckIdle();
276 WM_CHECK_RESULT(result);
277
278 // Check parameters
279 if (wepmode > 3)
280 {
281 WM_WARNING("Parameter \"wepmode\" must be less than %d.\n", 3);
282 return WM_ERRCODE_INVALID_PARAM;
283 }
284
285 if (wepmode != WM_WEPMODE_NO)
286 {
287 // Check parameters
288 if (wepkey == NULL)
289 {
290 WM_WARNING("Parameter \"wepkey\" must not be NULL.\n");
291 return WM_ERRCODE_INVALID_PARAM;
292 }
293 if (wepkeyid > 3)
294 {
295 WM_WARNING("Parameter \"wepkeyid\" must be less than %d.\n", 3);
296 }
297 if ((u32)wepkey & 0x01f)
298 {
299 // Alignment check is a warning only, not an error
300 WM_WARNING("Parameter \"wepkey\" is not 32-byte aligned.\n");
301 }
302
303 // Write out the specified buffer's cache
304 DC_StoreRange((void *)wepkey, WM_SIZE_WEPKEY);
305 }
306
307 // Register callback function
308 WMi_SetCallbackTable(WM_APIID_SET_WEPKEY_EX, callback);
309
310 // Notify ARM7 with FIFO
311 result = WMi_SendCommand(WM_APIID_SET_WEPKEY_EX, 3, (u32)wepmode, (u32)wepkey, (u32)wepkeyid);
312 WM_CHECK_RESULT(result);
313
314 return WM_ERRCODE_OPERATING;
315 }
316
317 /*---------------------------------------------------------------------------*
318 Name: WM_SetGameInfo
319
320 Description: Sets the game information. Initial value is set by WM_SetParentParameter. Use this function to change the game information.
321
322
323 Arguments: callback - Callback function that is called when the asynchronous process completes.
324 userGameInfo - Pointer to the user game information.
325 userGameInfoSize - Size of the user game information.
326 ggid - Game group ID
327 tgid - Temporary group ID
328 attr - Flag group. Sets the logical sum of the following flags.
329 WM_ATTR_FLAG_ENTRY - Entry permitted
330 WM_ATTR_FLAG_MB - Accepting multiboot
331 WM_ATTR_FLAG_KS - Key sharing
332 WM_ATTR_FLAG_CS - Continuous transfer mode
333 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.
334
335
336 *---------------------------------------------------------------------------*/
337 WMErrCode
WM_SetGameInfo(WMCallbackFunc callback,const u16 * userGameInfo,u16 userGameInfoSize,u32 ggid,u16 tgid,u8 attr)338 WM_SetGameInfo(WMCallbackFunc callback, const u16 *userGameInfo, u16 userGameInfoSize,
339 u32 ggid, u16 tgid, u8 attr)
340 {
341 WMErrCode result;
342
343 // Confirm status as active parent
344 result = WMi_CheckStateEx(2, WM_STATE_PARENT, WM_STATE_MP_PARENT);
345 WM_CHECK_RESULT(result);
346
347 // Check parameters
348 if (userGameInfo == NULL)
349 {
350 WM_WARNING("Parameter \"userGameInfo\" must not be NULL.\n");
351 return WM_ERRCODE_INVALID_PARAM;
352 }
353 if (userGameInfoSize > WM_SIZE_USER_GAMEINFO)
354 {
355 WM_WARNING("Parameter \"userGameInfoSize\" must be less than %d.\n", WM_SIZE_USER_GAMEINFO);
356 return WM_ERRCODE_INVALID_PARAM;
357 }
358
359 // Temporarily save the specified buffer
360 MI_CpuCopy16((void *)userGameInfo, (void *)tmpUserGameInfoBuf, userGameInfoSize);
361 DC_StoreRange((void *)tmpUserGameInfoBuf, userGameInfoSize);
362
363 // Register callback function
364 WMi_SetCallbackTable(WM_APIID_SET_GAMEINFO, callback);
365
366 // Notify ARM7 with FIFO
367 result = WMi_SendCommand(WM_APIID_SET_GAMEINFO, 5,
368 (u32)tmpUserGameInfoBuf,
369 (u32)userGameInfoSize, (u32)ggid, (u32)tgid, (u32)attr);
370 if (result != WM_ERRCODE_SUCCESS)
371 {
372 return result;
373 }
374
375 return WM_ERRCODE_OPERATING;
376 }
377
378 /*---------------------------------------------------------------------------*
379 Name: WM_SetBeaconIndication
380
381 Description: Switches the beacon send/receive indication between enabled/disabled.
382
383 Arguments: callback - Callback function that is called when the asynchronous process completes.
384 flag - 0: Disabled
385 1: Enabled
386
387 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.
388
389
390 *---------------------------------------------------------------------------*/
WM_SetBeaconIndication(WMCallbackFunc callback,u16 flag)391 WMErrCode WM_SetBeaconIndication(WMCallbackFunc callback, u16 flag)
392 {
393 WMErrCode result;
394
395 // Confirm that wireless hardware has started
396 result = WMi_CheckIdle();
397 WM_CHECK_RESULT(result);
398
399 // Check parameters
400 if ((0 != flag) && (1 != flag))
401 {
402 WM_WARNING("Parameter \"flag\" must be \"0\" of \"1\".\n");
403 return WM_ERRCODE_INVALID_PARAM;
404 }
405
406 // Register callback function
407 WMi_SetCallbackTable(WM_APIID_SET_BEACON_IND, callback);
408
409 // Notify ARM7 with FIFO
410 result = WMi_SendCommand(WM_APIID_SET_BEACON_IND, 1, (u32)flag);
411 WM_CHECK_RESULT(result);
412
413 return WM_ERRCODE_OPERATING;
414 }
415
416 /*---------------------------------------------------------------------------*
417 Name: WM_SetLifeTime
418
419 Description: Sets the lifetime.
420
421 Arguments: callback - Callback function that is called when the asynchronous process completes.
422 tableNumber: CAM table number that sets lifetime (With 0xFFFF, all tables)
423 camLifeTime: CAM lifetime (in 100-ms units; invalid when it is 0xFFFF)
424 frameLifeTime: Beacon intervals for the configured frame lifetime (in 100-ms units; invalid when it is 0xFFFF)
425 mpLifeTime: MP communication lifetime (in 100-ms units; invalid when it is 0xFFFF)
426
427 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.
428
429
430 *---------------------------------------------------------------------------*/
431 WMErrCode
WM_SetLifeTime(WMCallbackFunc callback,u16 tableNumber,u16 camLifeTime,u16 frameLifeTime,u16 mpLifeTime)432 WM_SetLifeTime(WMCallbackFunc callback, u16 tableNumber, u16 camLifeTime, u16 frameLifeTime,
433 u16 mpLifeTime)
434 {
435 WMErrCode result;
436
437 // Confirm that wireless hardware has started
438 result = WMi_CheckIdle();
439 WM_CHECK_RESULT(result);
440
441 // Register callback function
442 WMi_SetCallbackTable(WM_APIID_SET_LIFETIME, callback);
443
444 // Notify ARM7 with FIFO
445 result = WMi_SendCommand(WM_APIID_SET_LIFETIME, 4,
446 (u32)tableNumber,
447 (u32)camLifeTime, (u32)frameLifeTime, (u32)mpLifeTime);
448 WM_CHECK_RESULT(result);
449
450 return WM_ERRCODE_OPERATING;
451 }
452
453 /*---------------------------------------------------------------------------*
454 Name: WM_MeasureChannel
455
456 Description: Measure channel usage status.
457
458 Arguments: callback - Callback function that is called when the asynchronous process completes.
459 ccaMode: CCA operation mode.
460 0: Carrier sense only. ED threshold value is ignored.
461 1: Valid with ED threshold value only.
462 2: Logical product of carrier sense and ED threshold value.
463 3: Logical sum of carrier sense and ED threshold value.
464 EDThreshold: ED threshold (0 thru 61), -60dBm thru -80dBm
465 channel: Channel to investigate (Only one channel per one cycle of MeasureChannel)
466 measureTime: Time to investigate.
467
468 Returns: WMErrCode - Returns the processing result.
469 Returns WM_ERRCODE_OPERATING if asynchronous processing started successfully. Afterwards, the asynchronous processing results will be passed to the callback.
470
471 *---------------------------------------------------------------------------*/
472 WMErrCode
WM_MeasureChannel(WMCallbackFunc callback,u16 ccaMode,u16 edThreshold,u16 channel,u16 measureTime)473 WM_MeasureChannel(WMCallbackFunc callback, u16 ccaMode, u16 edThreshold, u16 channel,
474 u16 measureTime)
475 {
476 WMErrCode result;
477 WMArm9Buf *p = WMi_GetSystemWork();
478
479 // Cannot execute if not in IDLE state.
480 result = WMi_CheckState(WM_STATE_IDLE);
481 WM_CHECK_RESULT(result);
482
483 // Register callback function
484 WMi_SetCallbackTable(WM_APIID_MEASURE_CHANNEL, callback);
485
486 // Notify ARM7 with FIFO
487 {
488 WMMeasureChannelReq Req;
489
490 Req.apiid = WM_APIID_MEASURE_CHANNEL;
491 Req.ccaMode = ccaMode;
492 Req.edThreshold = edThreshold;
493 Req.channel = channel;
494 Req.measureTime = measureTime;
495
496 result = WMi_SendCommandDirect(&Req, sizeof(Req));
497 WM_CHECK_RESULT(result);
498 }
499 return WM_ERRCODE_OPERATING;
500 }
501
502 /*---------------------------------------------------------------------------*
503 Name: WM_InitWirelessCounter
504
505 Description: Initializes WirelessCounter.
506
507 Arguments: callback - Callback function that is called when the asynchronous process completes.
508
509 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.
510
511
512 *---------------------------------------------------------------------------*/
WM_InitWirelessCounter(WMCallbackFunc callback)513 WMErrCode WM_InitWirelessCounter(WMCallbackFunc callback)
514 {
515 WMErrCode result;
516
517 // Confirm that wireless hardware has started
518 result = WMi_CheckIdle();
519 WM_CHECK_RESULT(result);
520
521 // Register callback function
522 WMi_SetCallbackTable(WM_APIID_INIT_W_COUNTER, callback);
523
524 // Notify ARM7 with FIFO
525 result = WMi_SendCommand(WM_APIID_INIT_W_COUNTER, 0);
526 WM_CHECK_RESULT(result);
527
528 return WM_ERRCODE_OPERATING;
529 }
530
531 /*---------------------------------------------------------------------------*
532 Name: WM_GetWirelessCounter
533
534 Description: Gets send/receive frame count and send/receive error frame count of Wireless NIC.
535
536 Arguments: callback - Callback function that is called when the asynchronous process completes.
537
538 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.
539
540
541 *---------------------------------------------------------------------------*/
WM_GetWirelessCounter(WMCallbackFunc callback)542 WMErrCode WM_GetWirelessCounter(WMCallbackFunc callback)
543 {
544 WMErrCode result;
545
546 // Confirm that wireless hardware has started
547 result = WMi_CheckIdle();
548 WM_CHECK_RESULT(result);
549
550 // Register callback function
551 WMi_SetCallbackTable(WM_APIID_GET_W_COUNTER, callback);
552
553 // Notify ARM7 with FIFO
554 result = WMi_SendCommand(WM_APIID_GET_W_COUNTER, 0);
555 WM_CHECK_RESULT(result);
556
557 return WM_ERRCODE_OPERATING;
558 }
559
560 /*---------------------------------------------------------------------------*
561 Name: WM_SetEntry
562
563 Description: Switches between accepting and refusing a connection from a child as a parent.
564
565 Arguments: callback - Callback function that is called when the asynchronous process completes.
566 enabled: Entry permitted / not permitted flag. TRUE: permitted, FALSE: not permitted.
567
568 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.
569
570
571 *---------------------------------------------------------------------------*/
WM_SetEntry(WMCallbackFunc callback,BOOL enabled)572 WMErrCode WM_SetEntry(WMCallbackFunc callback, BOOL enabled)
573 {
574 WMErrCode result;
575
576 // Only a parent can execute
577 result = WMi_CheckStateEx(2, WM_STATE_PARENT, WM_STATE_MP_PARENT);
578 WM_CHECK_RESULT(result);
579
580 // Register callback function
581 WMi_SetCallbackTable(WM_APIID_SET_ENTRY, callback);
582
583 // Notify ARM7 with FIFO
584 result = WMi_SendCommand(WM_APIID_SET_ENTRY, 1, (u32)enabled);
585 WM_CHECK_RESULT(result);
586
587 return WM_ERRCODE_OPERATING;
588 }
589
590 /*---------------------------------------------------------------------------*
591 Name: WMi_SetBeaconPeriod
592
593 Description: Changes the beacon intervals.
594
595 Arguments: callback - Callback function that is called when the asynchronous process completes.
596 beaconPeriod - Beacon interval (10 to 1000 TU (1024 microseconds))
597
598 Returns: WMErrCode - Returns the processing result.
599 Returns WM_ERRCODE_OPERATING if asynchronous processing started successfully. Afterwards, the asynchronous processing results will be passed to the callback.
600
601 *---------------------------------------------------------------------------*/
WMi_SetBeaconPeriod(WMCallbackFunc callback,u16 beaconPeriod)602 WMErrCode WMi_SetBeaconPeriod(WMCallbackFunc callback, u16 beaconPeriod)
603 {
604 WMErrCode result;
605
606 // Only a parent can execute
607 result = WMi_CheckStateEx(2, WM_STATE_PARENT, WM_STATE_MP_PARENT);
608 WM_CHECK_RESULT(result);
609
610 // Register callback function
611 WMi_SetCallbackTable(WM_APIID_SET_BEACON_PERIOD, callback);
612
613 // Notify ARM7 with FIFO
614 result = WMi_SendCommand(WM_APIID_SET_BEACON_PERIOD, 1, (u32)beaconPeriod);
615 WM_CHECK_RESULT(result);
616
617 return WM_ERRCODE_OPERATING;
618 }
619
620 /*---------------------------------------------------------------------------*
621 Name: WM_SetPowerSaveMode()
622
623 Description: Changes the PowerSaveMode.
624
625 Arguments: callback - Callback function that is called when the asynchronous process completes.
626 powerSave - When using power save mode, TRUE. When not using it, FALSE.
627
628 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.
629
630
631 *---------------------------------------------------------------------------*/
WM_SetPowerSaveMode(WMCallbackFunc callback,BOOL powerSave)632 WMErrCode WM_SetPowerSaveMode(WMCallbackFunc callback, BOOL powerSave)
633 {
634 WMErrCode result;
635
636 // This function cannot be executed except when in the DCF child state
637 result = WMi_CheckState(WM_STATE_DCF_CHILD);
638 WM_CHECK_RESULT(result);
639
640 // Register callback function
641 WMi_SetCallbackTable(WM_APIID_SET_PS_MODE, callback);
642
643 // Notify ARM7 with FIFO
644 result = WMi_SendCommand(WM_APIID_SET_PS_MODE, 1, (u32)powerSave);
645 WM_CHECK_RESULT(result);
646
647 return WM_ERRCODE_OPERATING;
648 }
649
650 /*---------------------------------------------------------------------------*
651 End of file
652 *---------------------------------------------------------------------------*/
653