1 /*---------------------------------------------------------------------------*
2   Project:  TwlSDK - WM - demos - wireless-all
3   File:     wh_measure.c
4 
5   Copyright 2006-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 #ifdef SDK_TWL
19 #include <twl.h>
20 #else
21 #include <nitro.h>
22 #endif
23 
24 #include "common.h"
25 #include "wh.h"
26 
27 
28 /*****************************************************************************/
29 /* Functions */
30 
31 /*---------------------------------------------------------------------------*
32   Name:         MeasureChannel
33 
34   Description:  Measures the wireless use rates for each useable channel.
35                 This can be used when the WH state is WH_SYSSTATE_IDLE.
36 
37   Arguments:    None.
38 
39   Returns:      The channel with the lowest rate of wireless use.
40  *---------------------------------------------------------------------------*/
MeasureChannel(void)41 u16 MeasureChannel(void)
42 {
43     SDK_ASSERT(WH_GetSystemState() == WH_SYSSTATE_IDLE);
44     /* Channel measurement begins */
45     (void)WH_StartMeasureChannel();
46     WaitWHState(WH_SYSSTATE_MEASURECHANNEL);
47     /* All channels measurement completed */
48     return WH_GetMeasureChannel();
49 }
50