2 * Copyright (c) 2014, Texas Instruments Incorporated
\r
3 * All rights reserved.
\r
5 * Redistribution and use in source and binary forms, with or without
\r
6 * modification, are permitted provided that the following conditions
\r
9 * * Redistributions of source code must retain the above copyright
\r
10 * notice, this list of conditions and the following disclaimer.
\r
12 * * Redistributions in binary form must reproduce the above copyright
\r
13 * notice, this list of conditions and the following disclaimer in the
\r
14 * documentation and/or other materials provided with the distribution.
\r
16 * * Neither the name of Texas Instruments Incorporated nor the names of
\r
17 * its contributors may be used to endorse or promote products derived
\r
18 * from this software without specific prior written permission.
\r
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
\r
21 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
\r
22 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
\r
23 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
\r
24 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
\r
25 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
\r
26 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
\r
27 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
\r
28 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
\r
29 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
\r
30 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
\r
32 //*****************************************************************************
\r
34 // tlv.h - Driver for the TLV Module.
\r
36 //*****************************************************************************
\r
38 #ifndef __MSP430WARE_TLV_H__
\r
39 #define __MSP430WARE_TLV_H__
\r
41 #include "inc/hw_memmap.h"
\r
43 #ifdef __MSP430_HAS_TLV__
\r
45 //*****************************************************************************
\r
47 // If building with a C++ compiler, make all of the definitions in this header
\r
48 // have a C binding.
\r
50 //*****************************************************************************
\r
56 #include "inc/hw_regaccess.h"
\r
57 //******************************************************************************
\r
61 //******************************************************************************
\r
62 struct s_TLV_Die_Record
\r
65 uint16_t die_x_position;
\r
66 uint16_t die_y_position;
\r
67 uint16_t test_results;
\r
70 struct s_TLV_ADC_Cal_Data
\r
72 uint16_t adc_gain_factor;
\r
74 uint16_t adc_ref15_30_temp;
\r
75 uint16_t adc_ref15_85_temp;
\r
76 uint16_t adc_ref20_30_temp;
\r
77 uint16_t adc_ref20_85_temp;
\r
78 uint16_t adc_ref25_30_temp;
\r
79 uint16_t adc_ref25_85_temp;
\r
82 struct s_TLV_Timer_D_Cal_Data
\r
84 uint16_t TDH0CTL1_64;
\r
85 uint16_t TDH0CTL1_128;
\r
86 uint16_t TDH0CTL1_200;
\r
87 uint16_t TDH0CTL1_256;
\r
90 struct s_TLV_REF_Cal_Data
\r
97 struct s_Peripheral_Memory_Data
\r
105 //*****************************************************************************
\r
107 // The following are values that can be passed to the tag parameter for
\r
108 // functions: TLV_getInfo().
\r
110 //*****************************************************************************
\r
111 #define TLV_TAG_LDTAG TLV_LDTAG
\r
112 #define TLV_TAG_PDTAG TLV_PDTAG
\r
113 #define TLV_TAG_Reserved3 TLV_Reserved3
\r
114 #define TLV_TAG_Reserved4 TLV_Reserved4
\r
115 #define TLV_TAG_BLANK TLV_BLANK
\r
116 #define TLV_TAG_Reserved6 TLV_Reserved6
\r
117 #define TLV_TAG_Reserved7 TLV_Reserved7
\r
118 #define TLV_TAG_TAGEND TLV_TAGEND
\r
119 #define TLV_TAG_TAGEXT TLV_TAGEXT
\r
120 #define TLV_TAG_TIMER_D_CAL TLV_TIMERDCAL
\r
121 #define TLV_DEVICE_ID_0 0x1A04
\r
122 #define TLV_DEVICE_ID_1 0x1A05
\r
123 #define TLV_TAG_DIERECORD TLV_DIERECORD
\r
124 #define TLV_TAG_ADCCAL TLV_ADCCAL
\r
125 #define TLV_TAG_ADC12CAL TLV_ADC12CAL
\r
126 #define TLV_TAG_ADC10CAL TLV_ADC10CAL
\r
127 #define TLV_TAG_REFCAL TLV_REFCAL
\r
129 //*****************************************************************************
\r
131 // The following are values that can be passed to the tag parameter for
\r
132 // functions: TLV_getPeripheral().
\r
134 //*****************************************************************************
\r
135 #define TLV_PID_NO_MODULE (0x00)
\r
136 #define TLV_PID_PORTMAPPING (0x10)
\r
137 #define TLV_PID_MSP430CPUXV2 (0x23)
\r
138 #define TLV_PID_JTAG (0x09)
\r
139 #define TLV_PID_SBW (0x0F)
\r
140 #define TLV_PID_EEM_XS (0x02)
\r
141 #define TLV_PID_EEM_S (0x03)
\r
142 #define TLV_PID_EEM_M (0x04)
\r
143 #define TLV_PID_EEM_L (0x05)
\r
144 #define TLV_PID_PMM (0x30)
\r
145 #define TLV_PID_PMM_FR (0x32)
\r
146 #define TLV_PID_FCTL (0x39)
\r
147 #define TLV_PID_CRC16 (0x3C)
\r
148 #define TLV_PID_CRC16_RB (0x3D)
\r
149 #define TLV_PID_WDT_A (0x40)
\r
150 #define TLV_PID_SFR (0x41)
\r
151 #define TLV_PID_SYS (0x42)
\r
152 #define TLV_PID_RAMCTL (0x44)
\r
153 #define TLV_PID_DMA_1 (0x46)
\r
154 #define TLV_PID_DMA_3 (0x47)
\r
155 #define TLV_PID_UCS (0x48)
\r
156 #define TLV_PID_DMA_6 (0x4A)
\r
157 #define TLV_PID_DMA_2 (0x4B)
\r
158 #define TLV_PID_PORT1_2 (0x51)
\r
159 #define TLV_PID_PORT3_4 (0x52)
\r
160 #define TLV_PID_PORT5_6 (0x53)
\r
161 #define TLV_PID_PORT7_8 (0x54)
\r
162 #define TLV_PID_PORT9_10 (0x55)
\r
163 #define TLV_PID_PORT11_12 (0x56)
\r
164 #define TLV_PID_PORTU (0x5E)
\r
165 #define TLV_PID_PORTJ (0x5F)
\r
166 #define TLV_PID_TA2 (0x60)
\r
167 #define TLV_PID_TA3 (0x61)
\r
168 #define TLV_PID_TA5 (0x62)
\r
169 #define TLV_PID_TA7 (0x63)
\r
170 #define TLV_PID_TB3 (0x65)
\r
171 #define TLV_PID_TB5 (0x66)
\r
172 #define TLV_PID_TB7 (0x67)
\r
173 #define TLV_PID_RTC (0x68)
\r
174 #define TLV_PID_BT_RTC (0x69)
\r
175 #define TLV_PID_BBS (0x6A)
\r
176 #define TLV_PID_RTC_B (0x6B)
\r
177 #define TLV_PID_TD2 (0x6C)
\r
178 #define TLV_PID_TD3 (0x6D)
\r
179 #define TLV_PID_TD5 (0x6E)
\r
180 #define TLV_PID_TD7 (0x6F)
\r
181 #define TLV_PID_TEC (0x70)
\r
182 #define TLV_PID_RTC_C (0x71)
\r
183 #define TLV_PID_AES (0x80)
\r
184 #define TLV_PID_MPY16 (0x84)
\r
185 #define TLV_PID_MPY32 (0x85)
\r
186 #define TLV_PID_MPU (0x86)
\r
187 #define TLV_PID_USCI_AB (0x90)
\r
188 #define TLV_PID_USCI_A (0x91)
\r
189 #define TLV_PID_USCI_B (0x92)
\r
190 #define TLV_PID_EUSCI_A (0x94)
\r
191 #define TLV_PID_EUSCI_B (0x95)
\r
192 #define TLV_PID_REF (0xA0)
\r
193 #define TLV_PID_COMP_B (0xA8)
\r
194 #define TLV_PID_COMP_D (0xA9)
\r
195 #define TLV_PID_USB (0x98)
\r
196 #define TLV_PID_LCD_B (0xB1)
\r
197 #define TLV_PID_LCD_C (0xB2)
\r
198 #define TLV_PID_DAC12_A (0xC0)
\r
199 #define TLV_PID_SD16_B_1 (0xC8)
\r
200 #define TLV_PID_SD16_B_2 (0xC9)
\r
201 #define TLV_PID_SD16_B_3 (0xCA)
\r
202 #define TLV_PID_SD16_B_4 (0xCB)
\r
203 #define TLV_PID_SD16_B_5 (0xCC)
\r
204 #define TLV_PID_SD16_B_6 (0xCD)
\r
205 #define TLV_PID_SD16_B_7 (0xCE)
\r
206 #define TLV_PID_SD16_B_8 (0xCF)
\r
207 #define TLV_PID_ADC12_A (0xD1)
\r
208 #define TLV_PID_ADC10_A (0xD3)
\r
209 #define TLV_PID_ADC10_B (0xD4)
\r
210 #define TLV_PID_SD16_A (0xD8)
\r
211 #define TLV_PID_TI_BSL (0xFC)
\r
213 //*****************************************************************************
\r
215 // Prototypes for the APIs.
\r
217 //*****************************************************************************
\r
219 //*****************************************************************************
\r
221 //! \brief Gets TLV Info
\r
223 //! The TLV structure uses a tag or base address to identify segments of the
\r
224 //! table where information is stored. Some examples of TLV tags are Peripheral
\r
225 //! Descriptor, Interrupts, Info Block and Die Record. This function retrieves
\r
226 //! the value of a tag and the length of the tag.
\r
228 //! \param tag represents the tag for which the information needs to be
\r
230 //! Valid values are:
\r
231 //! - \b TLV_TAG_LDTAG
\r
232 //! - \b TLV_TAG_PDTAG
\r
233 //! - \b TLV_TAG_Reserved3
\r
234 //! - \b TLV_TAG_Reserved4
\r
235 //! - \b TLV_TAG_BLANK
\r
236 //! - \b TLV_TAG_Reserved6
\r
237 //! - \b TLV_TAG_Reserved7
\r
238 //! - \b TLV_TAG_TAGEND
\r
239 //! - \b TLV_TAG_TAGEXT
\r
240 //! - \b TLV_TAG_TIMER_D_CAL
\r
241 //! - \b TLV_DEVICE_ID_0
\r
242 //! - \b TLV_DEVICE_ID_1
\r
243 //! - \b TLV_TAG_DIERECORD
\r
244 //! - \b TLV_TAG_ADCCAL
\r
245 //! - \b TLV_TAG_ADC12CAL
\r
246 //! - \b TLV_TAG_ADC10CAL
\r
247 //! - \b TLV_TAG_REFCAL
\r
248 //! \param instance In some cases a specific tag may have more than one
\r
249 //! instance. For example there may be multiple instances of timer
\r
250 //! calibration data present under a single Timer Cal tag. This variable
\r
251 //! specifies the instance for which information is to be retrieved (0,
\r
252 //! 1, etc.). When only one instance exists; 0 is passed.
\r
253 //! \param length Acts as a return through indirect reference. The function
\r
254 //! retrieves the value of the TLV tag length. This value is pointed to
\r
255 //! by *length and can be used by the application level once the
\r
256 //! function is called. If the specified tag is not found then the
\r
257 //! pointer is null 0.
\r
258 //! \param data_address acts as a return through indirect reference. Once the
\r
259 //! function is called data_address points to the pointer that holds the
\r
260 //! value retrieved from the specified TLV tag. If the specified tag is
\r
261 //! not found then the pointer is null 0.
\r
265 //*****************************************************************************
\r
266 extern void TLV_getInfo(uint8_t tag,
\r
269 uint16_t **data_address);
\r
271 //*****************************************************************************
\r
273 //! \brief Retrieves the unique device ID from the TLV structure.
\r
276 //! \return The device ID is returned as type uint16_t.
\r
278 //*****************************************************************************
\r
279 extern uint16_t TLV_getDeviceType(void);
\r
281 //*****************************************************************************
\r
283 //! \brief Gets memory information
\r
285 //! The Peripheral Descriptor tag is split into two portions a list of the
\r
286 //! available flash memory blocks followed by a list of available peripherals.
\r
287 //! This function is used to parse through the first portion and calculate the
\r
288 //! total flash memory available in a device. The typical usage is to call the
\r
289 //! TLV_getMemory which returns a non-zero value until the entire memory list
\r
290 //! has been parsed. When a zero is returned, it indicates that all the memory
\r
291 //! blocks have been counted and the next address holds the beginning of the
\r
292 //! device peripheral list.
\r
294 //! \param instance In some cases a specific tag may have more than one
\r
295 //! instance. This variable specifies the instance for which information
\r
296 //! is to be retrieved (0, 1 etc). When only one instance exists; 0 is
\r
299 //! \return The returned value is zero if the end of the memory list is
\r
302 //*****************************************************************************
\r
303 extern uint16_t TLV_getMemory(uint8_t instance);
\r
305 //*****************************************************************************
\r
307 //! \brief Gets peripheral information from the TLV
\r
309 //! he Peripheral Descriptor tag is split into two portions a list of the
\r
310 //! available flash memory blocks followed by a list of available peripherals.
\r
311 //! This function is used to parse through the second portion and can be used
\r
312 //! to check if a specific peripheral is present in a device. The function
\r
313 //! calls TLV_getPeripheral() recursively until the end of the memory list and
\r
314 //! consequently the beginning of the peripheral list is reached. <
\r
316 //! \param tag represents represents the tag for a specific peripheral for
\r
317 //! which the information needs to be retrieved. In the header file tlv.
\r
318 //! h specific peripheral tags are pre-defined, for example USCIA_B and
\r
319 //! TA0 are defined as TLV_PID_USCI_AB and TLV_PID_TA2 respectively.
\r
320 //! Valid values are:
\r
321 //! - \b TLV_PID_NO_MODULE - No Module
\r
322 //! - \b TLV_PID_PORTMAPPING - Port Mapping
\r
323 //! - \b TLV_PID_MSP430CPUXV2 - MSP430CPUXV2
\r
324 //! - \b TLV_PID_JTAG - JTAG
\r
325 //! - \b TLV_PID_SBW - SBW
\r
326 //! - \b TLV_PID_EEM_XS - EEM X-Small
\r
327 //! - \b TLV_PID_EEM_S - EEM Small
\r
328 //! - \b TLV_PID_EEM_M - EEM Medium
\r
329 //! - \b TLV_PID_EEM_L - EEM Large
\r
330 //! - \b TLV_PID_PMM - PMM
\r
331 //! - \b TLV_PID_PMM_FR - PMM FRAM
\r
332 //! - \b TLV_PID_FCTL - Flash
\r
333 //! - \b TLV_PID_CRC16 - CRC16
\r
334 //! - \b TLV_PID_CRC16_RB - CRC16 Reverse
\r
335 //! - \b TLV_PID_WDT_A - WDT_A
\r
336 //! - \b TLV_PID_SFR - SFR
\r
337 //! - \b TLV_PID_SYS - SYS
\r
338 //! - \b TLV_PID_RAMCTL - RAMCTL
\r
339 //! - \b TLV_PID_DMA_1 - DMA 1
\r
340 //! - \b TLV_PID_DMA_3 - DMA 3
\r
341 //! - \b TLV_PID_UCS - UCS
\r
342 //! - \b TLV_PID_DMA_6 - DMA 6
\r
343 //! - \b TLV_PID_DMA_2 - DMA 2
\r
344 //! - \b TLV_PID_PORT1_2 - Port 1 + 2 / A
\r
345 //! - \b TLV_PID_PORT3_4 - Port 3 + 4 / B
\r
346 //! - \b TLV_PID_PORT5_6 - Port 5 + 6 / C
\r
347 //! - \b TLV_PID_PORT7_8 - Port 7 + 8 / D
\r
348 //! - \b TLV_PID_PORT9_10 - Port 9 + 10 / E
\r
349 //! - \b TLV_PID_PORT11_12 - Port 11 + 12 / F
\r
350 //! - \b TLV_PID_PORTU - Port U
\r
351 //! - \b TLV_PID_PORTJ - Port J
\r
352 //! - \b TLV_PID_TA2 - Timer A2
\r
353 //! - \b TLV_PID_TA3 - Timer A1
\r
354 //! - \b TLV_PID_TA5 - Timer A5
\r
355 //! - \b TLV_PID_TA7 - Timer A7
\r
356 //! - \b TLV_PID_TB3 - Timer B3
\r
357 //! - \b TLV_PID_TB5 - Timer B5
\r
358 //! - \b TLV_PID_TB7 - Timer B7
\r
359 //! - \b TLV_PID_RTC - RTC
\r
360 //! - \b TLV_PID_BT_RTC - BT + RTC
\r
361 //! - \b TLV_PID_BBS - Battery Backup Switch
\r
362 //! - \b TLV_PID_RTC_B - RTC_B
\r
363 //! - \b TLV_PID_TD2 - Timer D2
\r
364 //! - \b TLV_PID_TD3 - Timer D1
\r
365 //! - \b TLV_PID_TD5 - Timer D5
\r
366 //! - \b TLV_PID_TD7 - Timer D7
\r
367 //! - \b TLV_PID_TEC - Timer Event Control
\r
368 //! - \b TLV_PID_RTC_C - RTC_C
\r
369 //! - \b TLV_PID_AES - AES
\r
370 //! - \b TLV_PID_MPY16 - MPY16
\r
371 //! - \b TLV_PID_MPY32 - MPY32
\r
372 //! - \b TLV_PID_MPU - MPU
\r
373 //! - \b TLV_PID_USCI_AB - USCI_AB
\r
374 //! - \b TLV_PID_USCI_A - USCI_A
\r
375 //! - \b TLV_PID_USCI_B - USCI_B
\r
376 //! - \b TLV_PID_EUSCI_A - eUSCI_A
\r
377 //! - \b TLV_PID_EUSCI_B - eUSCI_B
\r
378 //! - \b TLV_PID_REF - Shared Reference
\r
379 //! - \b TLV_PID_COMP_B - COMP_B
\r
380 //! - \b TLV_PID_COMP_D - COMP_D
\r
381 //! - \b TLV_PID_USB - USB
\r
382 //! - \b TLV_PID_LCD_B - LCD_B
\r
383 //! - \b TLV_PID_LCD_C - LCD_C
\r
384 //! - \b TLV_PID_DAC12_A - DAC12_A
\r
385 //! - \b TLV_PID_SD16_B_1 - SD16_B 1 Channel
\r
386 //! - \b TLV_PID_SD16_B_2 - SD16_B 2 Channel
\r
387 //! - \b TLV_PID_SD16_B_3 - SD16_B 3 Channel
\r
388 //! - \b TLV_PID_SD16_B_4 - SD16_B 4 Channel
\r
389 //! - \b TLV_PID_SD16_B_5 - SD16_B 5 Channel
\r
390 //! - \b TLV_PID_SD16_B_6 - SD16_B 6 Channel
\r
391 //! - \b TLV_PID_SD16_B_7 - SD16_B 7 Channel
\r
392 //! - \b TLV_PID_SD16_B_8 - SD16_B 8 Channel
\r
393 //! - \b TLV_PID_ADC12_A - ADC12_A
\r
394 //! - \b TLV_PID_ADC10_A - ADC10_A
\r
395 //! - \b TLV_PID_ADC10_B - ADC10_B
\r
396 //! - \b TLV_PID_SD16_A - SD16_A
\r
397 //! - \b TLV_PID_TI_BSL - BSL
\r
398 //! \param instance In some cases a specific tag may have more than one
\r
399 //! instance. For example a device may have more than a single USCI
\r
400 //! module, each of which is defined by an instance number 0, 1, 2, etc.
\r
401 //! When only one instance exists; 0 is passed.
\r
403 //! \return The returned value is zero if the specified tag value (peripheral)
\r
404 //! is not available in the device.
\r
406 //*****************************************************************************
\r
407 extern uint16_t TLV_getPeripheral(uint8_t tag,
\r
410 //*****************************************************************************
\r
412 //! \brief Get interrupt information from the TLV
\r
414 //! This function is used to retrieve information on available interrupt
\r
415 //! vectors. It allows the user to check if a specific interrupt vector is
\r
416 //! defined in a given device.
\r
418 //! \param tag represents the tag for the interrupt vector. Interrupt vector
\r
419 //! tags number from 0 to N depending on the number of available
\r
420 //! interrupts. Refer to the device datasheet for a list of available
\r
423 //! \return The returned value is zero is the specified interrupt vector is not
\r
426 //*****************************************************************************
\r
427 extern uint8_t TLV_getInterrupt(uint8_t tag);
\r
429 //*****************************************************************************
\r
431 // Mark the end of the C bindings section for C++ compilers.
\r
433 //*****************************************************************************
\r
439 #endif // __MSP430WARE_TLV_H__
\r