• Main Page
  • Data Structures
  • Files
  • File List
  • Globals

TLV.c

Go to the documentation of this file.
00001 /* ***********************************************************
00002 * THIS PROGRAM IS PROVIDED "AS IS". TI MAKES NO WARRANTIES OR
00003 * REPRESENTATIONS, EITHER EXPRESS, IMPLIED OR STATUTORY,
00004 * INCLUDING ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
00005 * FOR A PARTICULAR PURPOSE, LACK OF VIRUSES, ACCURACY OR
00006 * COMPLETENESS OF RESPONSES, RESULTS AND LACK OF NEGLIGENCE.
00007 * TI DISCLAIMS ANY WARRANTY OF TITLE, QUIET ENJOYMENT, QUIET
00008 * POSSESSION, AND NON-INFRINGEMENT OF ANY THIRD PARTY
00009 * INTELLECTUAL PROPERTY RIGHTS WITH REGARD TO THE PROGRAM OR
00010 * YOUR USE OF THE PROGRAM.
00011 *
00012 * IN NO EVENT SHALL TI BE LIABLE FOR ANY SPECIAL, INCIDENTAL,
00013 * CONSEQUENTIAL OR INDIRECT DAMAGES, HOWEVER CAUSED, ON ANY
00014 * THEORY OF LIABILITY AND WHETHER OR NOT TI HAS BEEN ADVISED
00015 * OF THE POSSIBILITY OF SUCH DAMAGES, ARISING IN ANY WAY OUT
00016 * OF THIS AGREEMENT, THE PROGRAM, OR YOUR USE OF THE PROGRAM.
00017 * EXCLUDED DAMAGES INCLUDE, BUT ARE NOT LIMITED TO, COST OF
00018 * REMOVAL OR REINSTALLATION, COMPUTER TIME, LABOR COSTS, LOSS
00019 * OF GOODWILL, LOSS OF PROFITS, LOSS OF SAVINGS, OR LOSS OF
00020 * USE OR INTERRUPTION OF BUSINESS. IN NO EVENT WILL TI'S
00021 * AGGREGATE LIABILITY UNDER THIS AGREEMENT OR ARISING OUT OF
00022 * YOUR USE OF THE PROGRAM EXCEED FIVE HUNDRED DOLLARS
00023 * (U.S.$500).
00024 *
00025 * Unless otherwise stated, the Program written and copyrighted
00026 * by Texas Instruments is distributed as "freeware".  You may,
00027 * only under TI's copyright in the Program, use and modify the
00028 * Program without any charge or restriction.  You may
00029 * distribute to third parties, provided that you transfer a
00030 * copy of this license to the third party and the third party
00031 * agrees to these terms by its first use of the Program. You
00032 * must reproduce the copyright notice and any other legend of
00033 * ownership on each copy or partial copy, of the Program.
00034 *
00035 * You acknowledge and agree that the Program contains
00036 * copyrighted material, trade secrets and other TI proprietary
00037 * information and is protected by copyright laws,
00038 * international copyright treaties, and trade secret laws, as
00039 * well as other intellectual property laws.  To protect TI's
00040 * rights in the Program, you agree not to decompile, reverse
00041 * engineer, disassemble or otherwise translate any object code
00042 * versions of the Program to a human-readable form.  You agree
00043 * that in no event will you alter, remove or destroy any
00044 * copyright notice included in the Program.  TI reserves all
00045 * rights not specifically granted under this license. Except
00046 * as specifically provided herein, nothing in this agreement
00047 * shall be construed as conferring by implication, estoppel,
00048 * or otherwise, upon you, any license or other right under any
00049 * TI patents, copyrights or trade secrets.
00050 *
00051 * You may not use the Program in non-TI devices.
00052 //
00053 //This software has been submitted to export control regulations
00054 //The ECCN is EAR99 
00055 * ********************************************************* */
00056 //*****************************************************************************
00069 // TLV Access Function Definition file
00070 
00071 #include "TLV_descriptors.h"
00072 
00073 /* Function Defintion
00074    Passing parameters:
00075       tag - The specific/particular tag information (length and data address location) required by the user
00076       *length - Address of the variable (byte long) where the number of bytes allocated for the particular 'tag' is to be stored
00077       *data_address - Address of the variable (word long) which is used to access the value info of the the particular 'tag' (in the TLV structure)
00078 
00079   NOTE: If 'length' and 'data_address' returned = 0, it implies that there was no tag match. This condition can be checked for in the 
00080         main function that calls this Get_TLV_info(..) function and appropriate actions can be taken
00081 */
00082 
00083 void Get_TLV_info(unsigned char tag, unsigned char *length, unsigned int *data_address)
00084 {
00085   char *TLV_address = (char *)TLV_START;               // TLV Structure Start Address
00086 
00087 
00088   while((*TLV_address != tag) && (*TLV_address != TLV_TAGEND) && ((unsigned int)TLV_address < TLV_END))
00089   {
00090     TLV_address += *(TLV_address+1) + 2;               // add (Current TAG address + LENGTH) + 2
00091   }
00092   if (*TLV_address == tag)                             // Check if Tag match happened..
00093   {
00094     *length = *(TLV_address+1);                        // Return length = Address + 1 
00095     *data_address = (unsigned int)(TLV_address+2);     // Return address of first data/value info = Address + 2 
00096   }
00097   else                                                 // If there was no tag match and the end of TLV structure was reached..
00098   {
00099     *length = 0;                                       // Return 0 for TAG not found
00100     data_address = 0;                                  // Return 0 for TAG not found
00101   }
00102 }

Generated on Fri Dec 17 2010 12:08:30 for Multi-cell Lithium-Ion Battery Manager System using MSP430 and BQ76PL536 by  doxygen 1.7.1