1 /******************************************************************************
2 * Filename: chipinfo.h
3 * Revised: 2015-10-27 13:41:27 +0100 (Tue, 27 Oct 2015)
4 * Revision: 44843
5 *
6 * Description: Collection of functions returning chip information.
7 *
8 * Copyright (c) 2015, Texas Instruments Incorporated
9 * All rights reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions are met:
13 *
14 * 1) Redistributions of source code must retain the above copyright notice,
15 * this list of conditions and the following disclaimer.
16 *
17 * 2) Redistributions in binary form must reproduce the above copyright notice,
18 * this list of conditions and the following disclaimer in the documentation
19 * and/or other materials provided with the distribution.
20 *
21 * 3) Neither the name of the ORGANIZATION nor the names of its contributors may
22 * be used to endorse or promote products derived from this software without
23 * specific prior written permission.
24 *
25 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
26 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
28 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
29 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
30 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
31 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
32 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
33 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
34 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35 * POSSIBILITY OF SUCH DAMAGE.
36 *
37 ******************************************************************************/
38
39 //*****************************************************************************
40 //
41 //! \addtogroup system_control_group
42 //! @{
43 //! \addtogroup ChipInfo
44 //! @{
45 //
46 //*****************************************************************************
47
48 #ifndef __CHIP_INFO_H__
49 #define __CHIP_INFO_H__
50
51 //*****************************************************************************
52 //
53 // If building with a C++ compiler, make all of the definitions in this header
54 // have a C binding.
55 //
56 //*****************************************************************************
57 #ifdef __cplusplus
58 extern "C"
59 {
60 #endif
61
62 #include <stdint.h>
63 #include <stdbool.h>
64 #include <inc/hw_types.h>
65 #include <inc/hw_memmap.h>
66 #include <inc/hw_fcfg1.h>
67
68 //*****************************************************************************
69 //
70 //! \brief Enumeration identifying the protocols supported.
71 //!
72 //! \note
73 //! This is a bit vector enumeration that indicates supported protocols.
74 //! E.g: 0x06 means that the chip supports both BLE and IEEE 802.15.4
75 //
76 //*****************************************************************************
77 typedef enum {
78 PROTOCOL_Unknown = 0 , //!< None of the known protocols are supported.
79 PROTOCOLBIT_BLE = 0x02, //!< Bit[1] set, indicates that Bluetooth Low Energy is supported.
80 PROTOCOLBIT_IEEE_802_15_4 = 0x04, //!< Bit[2] set, indicates that IEEE 802.15.4 is supported.
81 PROTOCOLBIT_Proprietary = 0x08 //!< Bit[3] set, indicates that proprietary protocols are supported.
82 } ProtocolBitVector_t;
83
84 //*****************************************************************************
85 //
86 //! \brief Returns bit vector showing supported protocols.
87 //!
88 //! \return
89 //! Returns \ref ProtocolBitVector_t which is a bit vector indicating supported protocols.
90 //
91 //*****************************************************************************
92 extern ProtocolBitVector_t ChipInfo_GetSupportedProtocol_BV( void );
93
94
95 //*****************************************************************************
96 //
97 //! \brief Returns true if the chip supports the BLE protocol.
98 //!
99 //! \return
100 //! Returns \c true if supporting the BLE protocol, \c false otherwise.
101 //
102 //*****************************************************************************
103 __STATIC_INLINE bool
ChipInfo_SupportsBLE(void)104 ChipInfo_SupportsBLE( void )
105 {
106 return (( ChipInfo_GetSupportedProtocol_BV() & PROTOCOLBIT_BLE ) != 0 );
107 }
108
109 //*****************************************************************************
110 //
111 //! \brief Returns true if the chip supports the IEEE 802.15.4 protocol.
112 //!
113 //! \return
114 //! Returns \c true if supporting the IEEE 802.15.4 protocol, \c false otherwise.
115 //
116 //*****************************************************************************
117 __STATIC_INLINE bool
ChipInfo_SupportsIEEE_802_15_4(void)118 ChipInfo_SupportsIEEE_802_15_4( void )
119 {
120 return (( ChipInfo_GetSupportedProtocol_BV() & PROTOCOLBIT_IEEE_802_15_4 ) != 0 );
121 }
122
123 //*****************************************************************************
124 //
125 //! \brief Returns true if the chip supports propriatary protocols.
126 //!
127 //! \return
128 //! Returns \c true if supporting propriatary protocols, \c false otherwise.
129 //
130 //*****************************************************************************
131 __STATIC_INLINE bool
ChipInfo_SupportsPROPRIETARY(void)132 ChipInfo_SupportsPROPRIETARY( void )
133 {
134 return (( ChipInfo_GetSupportedProtocol_BV() & PROTOCOLBIT_Proprietary ) != 0 );
135 }
136
137
138 //*****************************************************************************
139 //
140 //! \brief Package type enumeration
141 //
142 //*****************************************************************************
143 typedef enum {
144 PACKAGE_Unknown = -1, //!< -1 means that current chip type is unknown.
145 PACKAGE_4x4 = 0, //!< 0 means that this is a 4x4mm chip.
146 PACKAGE_5x5 = 1, //!< 1 means that this is a 5x5mm chip.
147 PACKAGE_7x7 = 2 //!< 2 means that this is a 7x7mm chip.
148 } PackageType_t;
149
150 //*****************************************************************************
151 //
152 //! \brief Returns package type.
153 //!
154 //! \return
155 //! Returns \ref PackageType_t
156 //
157 //*****************************************************************************
158 extern PackageType_t ChipInfo_GetPackageType( void );
159
160 //*****************************************************************************
161 //
162 //! \brief Returns true if this is a 4x4mm chip.
163 //!
164 //! \return
165 //! Returns \c true if this is a 4x4mm chip, \c false otherwise.
166 //
167 //*****************************************************************************
168 __STATIC_INLINE bool
ChipInfo_PackageTypeIs4x4(void)169 ChipInfo_PackageTypeIs4x4( void )
170 {
171 return ( ChipInfo_GetPackageType() == PACKAGE_4x4 );
172 }
173
174 //*****************************************************************************
175 //
176 //! \brief Returns true if this is a 5x5mm chip.
177 //!
178 //! \return
179 //! Returns \c true if this is a 5x5mm chip, \c false otherwise.
180 //
181 //*****************************************************************************
182 __STATIC_INLINE bool
ChipInfo_PackageTypeIs5x5(void)183 ChipInfo_PackageTypeIs5x5( void )
184 {
185 return ( ChipInfo_GetPackageType() == PACKAGE_5x5 );
186 }
187
188 //*****************************************************************************
189 //
190 //! \brief Returns true if this is a 7x7mm chip.
191 //!
192 //! \return
193 //! Returns \c true if this is a 7x7mm chip, \c false otherwise.
194 //
195 //*****************************************************************************
196 __STATIC_INLINE bool
ChipInfo_PackageTypeIs7x7(void)197 ChipInfo_PackageTypeIs7x7( void )
198 {
199 return ( ChipInfo_GetPackageType() == PACKAGE_7x7 );
200 }
201
202
203 //*****************************************************************************
204 //
205 //! \brief Returns the internal chip HW revision code.
206 //!
207 //! \return
208 //! Returns the internal chip HW revision code (in range 0-15)
209 //*****************************************************************************
210 __STATIC_INLINE uint32_t
ChipInfo_GetDeviceIdHwRevCode(void)211 ChipInfo_GetDeviceIdHwRevCode( void )
212 {
213 // Returns HwRevCode = FCFG1_O_ICEPICK_DEVICE_ID[31:28]
214 return ( HWREG( FCFG1_BASE + FCFG1_O_ICEPICK_DEVICE_ID ) >> 28 );
215 }
216
217 //*****************************************************************************
218 //
219 //! \brief Returns minor hardware revision number
220 //!
221 //! The minor revision number is set to 0 for the first market released chip
222 //! and thereafter incremented by 1 for each minor hardware change.
223 //!
224 //! \return
225 //! Returns the minor hardware revision number (in range 0-127)
226 //
227 //*****************************************************************************
228 __STATIC_INLINE uint32_t
ChipInfo_GetMinorHwRev(void)229 ChipInfo_GetMinorHwRev( void )
230 {
231 uint32_t minorRev = (( HWREG( FCFG1_BASE + FCFG1_O_MISC_CONF_1 ) &
232 FCFG1_MISC_CONF_1_DEVICE_MINOR_REV_M ) >>
233 FCFG1_MISC_CONF_1_DEVICE_MINOR_REV_S ) ;
234
235 if ( minorRev >= 0x80 ) {
236 minorRev = 0;
237 }
238
239 return( minorRev );
240 }
241
242
243 //*****************************************************************************
244 //
245 //! \brief Chip family enumeration
246 //
247 //*****************************************************************************
248 typedef enum {
249 FAMILY_Unknown = -1, //!< -1 means that the chip's family member is unknown.
250 FAMILY_CC26xx = 0, //!< 0 means that the chip is a CC26xx family member.
251 FAMILY_CC13xx = 1, //!< 1 means that the chip is a CC13xx family member.
252 FAMILY_CC26xxLizard = 2, //!< 2 means that the chip is a CC26xxLizard family member.
253 FAMILY_CC26xxAgama = 3 //!< 3 means that the chip is a CC26xxAgama family member.
254 } ChipFamily_t;
255
256 //*****************************************************************************
257 //
258 //! \brief Returns chip family member.
259 //!
260 //! \return
261 //! Returns \ref ChipFamily_t
262 //
263 //*****************************************************************************
264 extern ChipFamily_t ChipInfo_GetChipFamily( void );
265
266 //*****************************************************************************
267 //
268 //! \brief Returns true if this chip is member of the CC26xx family.
269 //!
270 //! \return
271 //! Returns \c true if this chip is member of the CC26xx family, \c false otherwise.
272 //
273 //*****************************************************************************
274 __STATIC_INLINE bool
ChipInfo_ChipFamilyIsCC26xx(void)275 ChipInfo_ChipFamilyIsCC26xx( void )
276 {
277 return ( ChipInfo_GetChipFamily() == FAMILY_CC26xx );
278 }
279
280 //*****************************************************************************
281 //
282 //! \brief Returns true if this chip is member of the CC13xx family.
283 //!
284 //! \return
285 //! Returns \c true if this chip is member of the CC13xx family, \c false otherwise.
286 //
287 //*****************************************************************************
288 __STATIC_INLINE bool
ChipInfo_ChipFamilyIsCC13xx(void)289 ChipInfo_ChipFamilyIsCC13xx( void )
290 {
291 return ( ChipInfo_GetChipFamily() == FAMILY_CC13xx );
292 }
293
294 //*****************************************************************************
295 //
296 //! \brief Returns true if this chip is member of the CC26xxLizard family.
297 //!
298 //! \return
299 //! Returns \c true if this chip is member of the CC26xxLizard family, \c false otherwise.
300 //
301 //*****************************************************************************
302 __STATIC_INLINE bool
ChipInfo_ChipFamilyIsCC26xxLizard(void)303 ChipInfo_ChipFamilyIsCC26xxLizard( void )
304 {
305 return ( ChipInfo_GetChipFamily() == FAMILY_CC26xxLizard );
306 }
307
308 //*****************************************************************************
309 //
310 //! \brief Returns true if this chip is member of the CC26xxAgama family.
311 //!
312 //! \return
313 //! Returns \c true if this chip is member of the CC26xxAgama family, \c false otherwise.
314 //
315 //*****************************************************************************
316 __STATIC_INLINE bool
ChipInfo_ChipFamilyIsCC26xxAgama(void)317 ChipInfo_ChipFamilyIsCC26xxAgama( void )
318 {
319 return ( ChipInfo_GetChipFamily() == FAMILY_CC26xxAgama );
320 }
321
322 //*****************************************************************************
323 //
324 //! \brief HW revision enumeration.
325 //
326 //*****************************************************************************
327 typedef enum {
328 HWREV_Unknown = -1, //!< -1 means that the chip's HW revision is unknown.
329 HWREV_1_0 = 10, //!< 10 means that the chip's HW revision is 1.0
330 HWREV_2_0 = 20, //!< 20 means that the chip's HW revision is 2.0
331 HWREV_2_1 = 21, //!< 21 means that the chip's HW revision is 2.1
332 HWREV_2_2 = 22, //!< 22 means that the chip's HW revision is 2.2
333 HWREV_2_3 = 23 //!< 23 means that the chip's HW revision is 2.3
334 } HwRevision_t;
335
336 //*****************************************************************************
337 //
338 //! \brief Returns chip HW revision.
339 //!
340 //! \return
341 //! Returns \ref HwRevision_t
342 //
343 //*****************************************************************************
344 extern HwRevision_t ChipInfo_GetHwRevision( void );
345
346 //*****************************************************************************
347 //
348 //! \brief Returns true if HW revision for this chip is 1.0.
349 //!
350 //! \return
351 //! Returns \c true if HW revision for this chip is 1.0, \c false otherwise.
352 //
353 //*****************************************************************************
354 __STATIC_INLINE bool
ChipInfo_HwRevisionIs_1_0(void)355 ChipInfo_HwRevisionIs_1_0( void )
356 {
357 return ( ChipInfo_GetHwRevision() == HWREV_1_0 );
358 }
359
360 //*****************************************************************************
361 //
362 //! \brief Returns true if HW revision for this chip is 2.0 or greater.
363 //!
364 //! \return
365 //! Returns \c true if HW revision for this chip is 2.0 or greater, \c false otherwise.
366 //
367 //*****************************************************************************
368 __STATIC_INLINE bool
ChipInfo_HwRevisionIs_GTEQ_2_0(void)369 ChipInfo_HwRevisionIs_GTEQ_2_0( void )
370 {
371 return ( ChipInfo_GetHwRevision() >= HWREV_2_0 );
372 }
373
374 //*****************************************************************************
375 //
376 //! \brief Returns true if HW revision for this chip is 2.0.
377 //!
378 //! \return
379 //! Returns \c true if HW revision for this chip is 2.0, \c false otherwise.
380 //
381 //*****************************************************************************
382 __STATIC_INLINE bool
ChipInfo_HwRevisionIs_2_0(void)383 ChipInfo_HwRevisionIs_2_0( void )
384 {
385 return ( ChipInfo_GetHwRevision() == HWREV_2_0 );
386 }
387
388 //*****************************************************************************
389 //
390 //! \brief Returns true if HW revision for this chip is 2.1.
391 //!
392 //! \return
393 //! Returns \c true if HW revision for this chip is 2.1, \c false otherwise.
394 //
395 //*****************************************************************************
396 __STATIC_INLINE bool
ChipInfo_HwRevisionIs_2_1(void)397 ChipInfo_HwRevisionIs_2_1( void )
398 {
399 return ( ChipInfo_GetHwRevision() == HWREV_2_1 );
400 }
401
402 //*****************************************************************************
403 //
404 //! \brief Returns true if HW revision for this chip is 2.2.
405 //!
406 //! \return
407 //! Returns \c true if HW revision for this chip is 2.2, \c false otherwise.
408 //
409 //*****************************************************************************
410 __STATIC_INLINE bool
ChipInfo_HwRevisionIs_2_2(void)411 ChipInfo_HwRevisionIs_2_2( void )
412 {
413 return ( ChipInfo_GetHwRevision() == HWREV_2_2 );
414 }
415
416 //*****************************************************************************
417 //
418 //! \brief Returns true if HW revision for this chip is 2.2 or greater.
419 //!
420 //! \return
421 //! Returns \c true if HW revision for this chip is 2.2 or greater, \c false otherwise.
422 //
423 //*****************************************************************************
424 __STATIC_INLINE bool
ChipInfo_HwRevisionIs_GTEQ_2_2(void)425 ChipInfo_HwRevisionIs_GTEQ_2_2( void )
426 {
427 return ( ChipInfo_GetHwRevision() >= HWREV_2_2 );
428 }
429
430 //*****************************************************************************
431 //
432 //! \brief Returns true if HW revision for this chip is 2.3 or greater.
433 //!
434 //! \return
435 //! Returns \c true if HW revision for this chip is 2.3 or greater, \c false otherwise.
436 //
437 //*****************************************************************************
438 __STATIC_INLINE bool
ChipInfo_HwRevisionIs_GTEQ_2_3(void)439 ChipInfo_HwRevisionIs_GTEQ_2_3( void )
440 {
441 return ( ChipInfo_GetHwRevision() >= HWREV_2_3 );
442 }
443
444
445 //*****************************************************************************
446 //
447 //! \brief Verifies that curent chip is built for CC13xx HwRev 2.0 or later and never returns if violated.
448 //!
449 //! \return None
450 //
451 //*****************************************************************************
452 extern void ThisCodeIsBuiltForCC13xxHwRev20AndLater_HaltIfViolated( void );
453
454 //*****************************************************************************
455 //
456 // Mark the end of the C bindings section for C++ compilers.
457 //
458 //*****************************************************************************
459 #ifdef __cplusplus
460 }
461 #endif
462
463 #endif // __CHIP_INFO_H__
464
465 //*****************************************************************************
466 //
467 //! Close the Doxygen group.
468 //! @}
469 //! @}
470 //
471 //*****************************************************************************
472