|
1 /* |
|
2 * freq.c |
|
3 * |
|
4 * Copyright(c) 1998 - 2010 Texas Instruments. All rights reserved. |
|
5 * All rights reserved. |
|
6 * |
|
7 * This program and the accompanying materials are made available under the |
|
8 * terms of the Eclipse Public License v1.0 or BSD License which accompanies |
|
9 * this distribution. The Eclipse Public License is available at |
|
10 * http://www.eclipse.org/legal/epl-v10.html and the BSD License is as below. |
|
11 * |
|
12 * Redistribution and use in source and binary forms, with or without |
|
13 * modification, are permitted provided that the following conditions |
|
14 * are met: |
|
15 * |
|
16 * * Redistributions of source code must retain the above copyright |
|
17 * notice, this list of conditions and the following disclaimer. |
|
18 * * Redistributions in binary form must reproduce the above copyright |
|
19 * notice, this list of conditions and the following disclaimer in |
|
20 * the documentation and/or other materials provided with the |
|
21 * distribution. |
|
22 * * Neither the name Texas Instruments nor the names of its |
|
23 * contributors may be used to endorse or promote products derived |
|
24 * from this software without specific prior written permission. |
|
25 * |
|
26 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
|
27 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
|
28 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
|
29 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
|
30 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
|
31 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
|
32 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
|
33 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
|
34 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
|
35 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
|
36 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
|
37 */ |
|
38 |
|
39 /** \file freq.c |
|
40 * \brief frequency to channel (and vice versa) conversion implementation |
|
41 * |
|
42 * \see freq.h |
|
43 */ |
|
44 |
|
45 |
|
46 #define __FILE_ID__ FILE_ID_126 |
|
47 #include "osTIType.h" |
|
48 |
|
49 #define CHAN_FREQ_TABLE_SIZE (sizeof(ChanFreq) / sizeof(CHAN_FREQ)) |
|
50 |
|
51 typedef struct { |
|
52 TI_UINT8 chan; |
|
53 TI_UINT32 freq; |
|
54 } CHAN_FREQ; |
|
55 |
|
56 static CHAN_FREQ ChanFreq[] = { |
|
57 {1, 2412000}, |
|
58 {2, 2417000}, |
|
59 {3, 2422000}, |
|
60 {4, 2427000}, |
|
61 {5, 2432000}, |
|
62 {6, 2437000}, |
|
63 {7, 2442000}, |
|
64 {8, 2447000}, |
|
65 {9, 2452000}, |
|
66 {10, 2457000}, |
|
67 {11, 2462000}, |
|
68 {12, 2467000}, |
|
69 {13, 2472000}, |
|
70 {14, 2484000}, |
|
71 {34, 5170000}, |
|
72 {36, 5180000}, |
|
73 {38, 5190000}, |
|
74 {40, 5200000}, |
|
75 {42, 5210000}, |
|
76 {44, 5220000}, |
|
77 {46, 5230000}, |
|
78 {48, 5240000}, |
|
79 {52, 5260000}, |
|
80 {56, 5280000}, |
|
81 {60, 5300000}, |
|
82 {64, 5320000}, |
|
83 {100,5500000}, |
|
84 {104,5520000}, |
|
85 {108,5540000}, |
|
86 {112,5560000}, |
|
87 {116,5580000}, |
|
88 {120,5600000}, |
|
89 {124,5620000}, |
|
90 {128,5640000}, |
|
91 {132,5660000}, |
|
92 {136,5680000}, |
|
93 {140,5700000}, |
|
94 {149,5745000}, |
|
95 {153,5765000}, |
|
96 {157,5785000}, |
|
97 {161,5805000} |
|
98 }; |
|
99 |
|
100 TI_UINT8 Freq2Chan (TI_UINT32 freq) |
|
101 { |
|
102 TI_UINT32 i; |
|
103 |
|
104 for (i = 0; i < CHAN_FREQ_TABLE_SIZE; i++) |
|
105 { |
|
106 if (ChanFreq[ i ].freq == freq) |
|
107 { |
|
108 return ChanFreq[ i ].chan; |
|
109 } |
|
110 } |
|
111 |
|
112 return 0; |
|
113 } |
|
114 |
|
115 |
|
116 TI_UINT32 Chan2Freq (TI_UINT8 chan) |
|
117 { |
|
118 TI_UINT32 i; |
|
119 |
|
120 for (i = 0; i < CHAN_FREQ_TABLE_SIZE; i++) |
|
121 { |
|
122 if (ChanFreq[ i ].chan == chan) |
|
123 { |
|
124 return ChanFreq[ i ].freq; |
|
125 } |
|
126 } |
|
127 |
|
128 return 0; |
|
129 } |
|
130 |