1 //*****************************************************************************
2 //
3 //! @file am_util_id.h
4 //!
5 //! @brief Identification of the Ambiq Micro device.
6 //!
7 //! This module contains functions for run time identification of Ambiq Micro
8 //! devices.
9 //!
10 //! @addtogroup id ID - Identification
11 //! @ingroup utils
12 //! @{
13 //
14 //*****************************************************************************
15 
16 //*****************************************************************************
17 //
18 // Copyright (c) 2024, Ambiq Micro, Inc.
19 // All rights reserved.
20 //
21 // Redistribution and use in source and binary forms, with or without
22 // modification, are permitted provided that the following conditions are met:
23 //
24 // 1. Redistributions of source code must retain the above copyright notice,
25 // this list of conditions and the following disclaimer.
26 //
27 // 2. Redistributions in binary form must reproduce the above copyright
28 // notice, this list of conditions and the following disclaimer in the
29 // documentation and/or other materials provided with the distribution.
30 //
31 // 3. Neither the name of the copyright holder nor the names of its
32 // contributors may be used to endorse or promote products derived from this
33 // software without specific prior written permission.
34 //
35 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
36 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
37 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
38 // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
39 // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
40 // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
41 // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
42 // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
43 // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
44 // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
45 // POSSIBILITY OF SUCH DAMAGE.
46 //
47 // This is part of revision stable-c1f95ddf60 of the AmbiqSuite Development Package.
48 //
49 //*****************************************************************************
50 #ifndef AM_UTIL_ID_H
51 #define AM_UTIL_ID_H
52 
53 #include "am_mcu_apollo.h"
54 
55 #ifdef __cplusplus
56 extern "C"
57 {
58 #endif
59 
60 
61 //*****************************************************************************
62 //
63 // Define the devices to be included in identification.
64 // This is useful for limiting coding to the desired device.
65 //
66 //*****************************************************************************
67 //
68 // Define AM_ID_APOLLO_ALL to define all Apollo family
69 //
70 //#define AM_ID_APOLLO_ALL
71 
72 //
73 //! New defines to be used in am_util_id
74 //
75 #if defined(AM_PART_APOLLO)
76 #define AM_ID_APOLLO
77 #endif
78 #if defined(AM_PART_APOLLO2)
79 #define AM_ID_APOLLO2
80 #endif
81 #if defined(AM_PART_APOLLO3)
82 #define AM_ID_APOLLO3
83 #endif
84 #if defined(AM_PART_APOLLO3P)
85 #define AM_ID_APOLLO3P
86 #endif
87 #if defined(AM_PART_APOLLO4)
88 #define AM_ID_APOLLO4A
89 #endif
90 #if defined(AM_PART_APOLLO4B)
91 #define AM_ID_APOLLO4B
92 #endif
93 #if defined(AM_PART_APOLLO4P)
94 #define AM_ID_APOLLO4P
95 #endif
96 #if defined(AM_PART_APOLLO4L)
97 #define AM_ID_APOLLO4L
98 #endif
99 #if defined(AM_PART_APOLLO5A)
100 #define AM_ID_APOLLO5A
101 #endif
102 #if defined(AM_PART_APOLLO5B)
103 #define AM_ID_APOLLO5B
104 #endif // AM_PART_APOLLO5A
105 
106 
107 //
108 //! Handle AM_ID_APOLLO_ALL
109 //
110 #if defined(AM_ID_APOLLO_ALL)
111 #ifndef AM_ID_APOLLO
112 #define AM_ID_APOLLO
113 #endif
114 #ifndef AM_ID_APOLLO2
115 #define AM_ID_APOLLO2
116 #endif
117 #ifndef AM_ID_APOLLO3
118 #define AM_ID_APOLLO3
119 #endif
120 #ifndef AM_ID_APOLLO3P
121 #define AM_ID_APOLLO3P
122 #endif
123 #ifndef AM_ID_APOLLO4A
124 #define AM_ID_APOLLO4A
125 #endif
126 #ifndef AM_ID_APOLLO4B
127 #define AM_ID_APOLLO4B
128 #endif
129 #ifndef AM_ID_APOLLO4P
130 #define AM_ID_APOLLO4P
131 #endif
132 #ifndef AM_ID_APOLLO4L
133 #define AM_ID_APOLLO4L
134 #endif
135 #ifndef AM_ID_APOLLO5A
136 #define AM_ID_APOLLO5A
137 #endif
138 #ifndef AM_ID_APOLLO5B
139 #define AM_ID_APOLLO5B
140 #endif // AM_ID_APOLLO5A
141 #endif // AM_ID_APOLLO_ALL
142 
143 
144 //*****************************************************************************
145 //
146 //! ID structure
147 //
148 //*****************************************************************************
149 typedef struct
150 {
151     //
152     //! Contains the HAL hardware information about the device.
153     //
154     am_hal_mcuctrl_device_t sMcuCtrlDevice;
155 
156     //
157     //! Contains the HAL hardware information about the device.
158     //
159     am_hal_mcuctrl_feature_t sMcuCtrlFeature;
160 
161     //
162     //! Device type (derived value, not a hardware value)
163     //
164     uint32_t ui32Device;
165 
166     //
167     //! Vendor name from the MCUCTRL VENDORID register and stringized here.
168     //
169     const uint8_t *pui8VendorName;
170 
171     //
172     //! Device name (derived value, not a hardware value)
173     //
174     const uint8_t *pui8DeviceName;
175 
176     //
177     //! Major chip revision (e.g. char 'A' or 'B')
178     //
179     uint8_t ui8ChipRevMaj;
180 
181     //
182     //! Minor chip revision (e.g. char '0', '1', ' ')
183     //
184     uint8_t ui8ChipRevMin;
185 
186     //
187     //! Package Type (defined at factory)
188     //
189     const uint8_t *pui8PackageType;
190 
191     //
192     //! Temperature Range
193     //
194     const uint8_t *pui8TempRange;
195 
196 }
197 am_util_id_t;
198 
199 //*****************************************************************************
200 //
201 //! @name Macros for MCUCTRL CHIP INFO field.
202 //! @note these macros are derived from CHIPPN definitions.
203 //! @{
204 //
205 //*****************************************************************************
206 #define AM_UTIL_MCUCTRL_CHIP_INFO_PARTNUM_APOLLO5B    0x10000000
207 #define AM_UTIL_MCUCTRL_CHIP_INFO_PARTNUM_APOLLO5A    0x10000000
208 #define AM_UTIL_MCUCTRL_CHIP_INFO_PARTNUM_APOLLO4L    0x09000000
209 #define AM_UTIL_MCUCTRL_CHIP_INFO_PARTNUM_APOLLO4     0x08000000
210 #define AM_UTIL_MCUCTRL_CHIP_INFO_PARTNUM_APOLLO3P    0x07000000
211 #define AM_UTIL_MCUCTRL_CHIP_INFO_PARTNUM_APOLLO3     0x06000000
212 #define AM_UTIL_MCUCTRL_CHIP_INFO_PARTNUM_APOLLOBL    0x05000000
213 #define AM_UTIL_MCUCTRL_CHIP_INFO_PARTNUM_VOYAGER     0x04000000
214 #define AM_UTIL_MCUCTRL_CHIP_INFO_PARTNUM_APOLLO2     0x03000000
215 #define AM_UTIL_MCUCTRL_CHIP_INFO_PARTNUM_APOLLOHC    0x02000000
216 #define AM_UTIL_MCUCTRL_CHIP_INFO_PARTNUM_APOLLO      0x01000000
217 #define AM_UTIL_MCUCTRL_CHIP_INFO_PARTNUM_PN_M        0xFF000000
218 //! @}
219 
220 //*****************************************************************************
221 //
222 //! @name Macros for silicon identification
223 //! @{
224 //
225 //*****************************************************************************
226 #define AM_UTIL_ID_UNKNOWN      0
227 #define AM_UTIL_ID_APOLLO       0x0001
228 #define AM_UTIL_ID_APOLLO2      0x0002
229 #define AM_UTIL_ID_APOLLO3      0x0003      // Apollo3 Blue
230 #define AM_UTIL_ID_APOLLO3P     0x0103      // Apollo3 Blue Plus
231 #define AM_UTIL_ID_APOLLO4      0x0004      // Apollo4
232 #define AM_UTIL_ID_APOLLO4P     0x0104      // Apollo4 Plus
233 #define AM_UTIL_ID_APOLLO4L     0x0204      // Apollo4 Lite
234 #define AM_UTIL_ID_APOLLO5A     0x0005      // Apollo5 revA
235 #define AM_UTIL_ID_APOLLO5B     0x0105      // Apollo5 revB
236 //! @}
237 
238 //*****************************************************************************
239 //
240 // External function definitions
241 //
242 //*****************************************************************************
243 //*****************************************************************************
244 //
245 //! @brief Device identification.
246 //!
247 //! @param psIDDevice - ptr to a device ID structure (am_util_id_t*) to be
248 //! filled in by the function.
249 //!
250 //! This function provides additional information about the currently running
251 //! Ambiq Micro MCU device.
252 //!
253 //! @returns The ui32Device value, which is a value corresponding to the
254 //! device type.
255 //
256 //*****************************************************************************
257 extern uint32_t am_util_id_device(am_util_id_t *psIDDevice);
258 
259 #ifdef __cplusplus
260 }
261 #endif
262 
263 #endif // AM_UTIL_ID_H
264 
265 //*****************************************************************************
266 //
267 // End Doxygen group.
268 //! @}
269 //
270 //*****************************************************************************
271 
272