slau358q.pdf - 第79页
www.ti.com MSP-GANG.dll Description 79 SLAU358Q – September 2011 – Revised October 2019 Submit Documentation Feedback Copyright © 2011–2019, Texas Instruments Incorporated Dynamic Link Library for MSP-GANG Programmer ext…

MSP-GANG.dll Description
www.ti.com
78
SLAU358Q–September 2011–Revised October 2019
Submit Documentation Feedback
Copyright © 2011–2019, Texas Instruments Incorporated
Dynamic Link Library for MSP-GANG Programmer
All MSP-GANG DLL functions have the same "MSPGANG_" prefix in the function name. It is easy in the
application software determine what functions are used with the MSP-GANG.dll. The following sections
describe each function.
Examples of using the new MSP-Gang.dll are provided and can be found in these locations (if the default
installation directory was used):
C:\Program Files\Texas Instruments\MSP-GANG\Examples\C_Applications_MSP_DLL
and
C:\Program Files\Texas Instruments\MSP-GANG\Examples\Cpp_Applications_MSP_DLL
These examples show how to configure the MSP-Gang Programmer to the desired target device type,
select code, and subsequently program connected devices. In addition, the examples also show how to
write a serial number into a custom memory location. To use these examples copy the MSG-Gang.dll into
the working directory.
4.2.1 MSPGANG_GetDataBuffers_ptr
MSPGANG_GetDataBuffers_ptr gives access to the internal data buffers that provide code contents, data
to be programmed, and buffers of data that was read from each target device with following structure.
LONG WINAPI MSPGANG_GetDataBuffers_ptr( void ** x );
#define DBUFFER_SIZE 0x210000
#define JTAG_PASSW_LEN 0x80
#define BSL_PASSW_LEN 0x20 //MSP430
#define ARM_BSL_PASSW_LEN 0x100 //MSP432
#define MAX_BSL_PASSW_LEN 0x100 //max from (ARM_BSL_PASSW_LEN,
BSL_PASSW_LEN)
#define MAX_PASSW_LEN 0x100 //max from (ARM_BSL_PASSW_LEN,
BSL_PASSW_LEN, JTAG_PASSW_LEN )
#define FLASH_END_ADDR (DBUFFER_SIZE-1)
#define FLASH_BUF_LEN DBUFFER_SIZE
#define GANG_SIZE 8
typedef struct
{
BYTE SourceCode[DBUFFER_SIZE]; //source code from the file
BYTE UsedCode[DBUFFER_SIZE]; //combined data (source code,
serialization etc)
BYTE GangRx[DBUFFER_SIZE][GANG_SIZE]; //data read from all targets
BYTE Tmp[DBUFFER_SIZE]; //used for second file cmp
BYTE Flag_ScrCode[DBUFFER_SIZE]; //0 - empty 1-Code1, 2-Code2, 4-
Appended Code in SourceCode[x];
#define CODE1_FLAG 1
#define CODE2_FLAG 2
#define APPEND_CODE_FLAG 4
BYTE Flag_UsedCode[DBUFFER_SIZE]; //0 - empty 1-
valid data in UsedCode[x];
BYTE Flag_WrEn[DBUFFER_SIZE]; //0 - none 1-
write/verify enable in FlashMem[x]
BYTE Flag_EraseEn[DBUFFER_SIZE]; //0 - none 1-
erase enable in FlashMem[x]
BYTE Flag_RdEn[DBUFFER_SIZE]; //0 - none 1-
read enable in FlashMem[x]
BYTE Flag_Sp3[DBUFFER_SIZE]; //used internally
BYTE JTAG_Passsword[2][JTAG_PASSW_LEN];
BYTE BSL_Passsword[2][MAX_BSL_PASSW_LEN];
BYTE Flag_JTAG_Passw[2][JTAG_PASSW_LEN]; // [0][..]-
password from code file; [1][..]-password from password file
BYTE Flag_BSL_Passw[2][MAX_BSL_PASSW_LEN]; // [0][..]-
password from code file; [1][..]-password from password file
} DATA_BUFFERS;

www.ti.com
MSP-GANG.dll Description
79
SLAU358Q–September 2011–Revised October 2019
Submit Documentation Feedback
Copyright © 2011–2019, Texas Instruments Incorporated
Dynamic Link Library for MSP-GANG Programmer
extern DATA_BUFFERS dat;
Syntax
LONG MSPGANG_GetDataBuffers_ptr(void ** x)
In the application software, the pointer to the data buffer can be initialized as follows.
DATA_BUFFERS *DBuf;
void *temp;
MSPGANG_GetDataBuffers_ptr((&temp));
DBuf = (DATA_BUFFERS *)temp;
Example
Check if the code contents is specified at the MCU location and get the code contents at that location.
int get_code_content( long MCU_addr, BYTE *data )
{
long baddr, MCU_addr;
BYTE data, used_code;
baddr = MSPGANG_Convert_Address( MCU_TO_DATABUF, MCU_addr );
if( baddr >= 0 )
{
if( DBuf->Flag_ScrCode[ baddr ] )
{
*data = DBuf->SourceCode[ baddr ];
return(SUCCESS):
}
else
return(EMPTY_DATA):
}
return(WRONG_MCV_ADDR);
}
4.2.2 MSPGANG_SetGangBuffer, MSPGANG_GetGangBuffer
The MSP-GANG Programmer contains a temporary data buffer that can be used for writing and reading
data to each target device. Buffer size is 128 bytes for each target device when used it for data and 16
bytes when used for serialization.
Buffer[8] [128];
MSPGANG_SetGangBuffer writes data to selected Buffer. MSPGANG_GetGangBuffer reads contents
from the selected buffer.
Syntax
LONG MSPGANG_SetGangBuffer(BYTE target, BYTE size, BYTE *data)
LONG MSPGANG_GetGangBuffer(BYTE target, BYTE size, BYTE *data)
Arguments
#define GANG_DATA_BUF_SIZE 128
#define SN_GANG_BUF_SIZE SN_DATA_MAX_SIZE
#define TARGET_MASK 0x1F
#define SN_DATA_FLAG 0x40
If used for data:
BYTE target Target number (1 to 8)
BYTE size Size of data (1 to 128)
If used for serialization:

MSP-GANG.dll Description
www.ti.com
80
SLAU358Q–September 2011–Revised October 2019
Submit Documentation Feedback
Copyright © 2011–2019, Texas Instruments Incorporated
Dynamic Link Library for MSP-GANG Programmer
BYTE target Target number (1 to 8) ORed with SN_DATA_FLAG (SN_DATA_FLAG | Target_Number)
BYTE size Size of data (1 to 16)
BYTE *data Pointer to data buffer from where data is taken or to where the data should be saved
Result
LONG Error code
Example
Write unique 16 bytes of data to RAM or Flash
BYTE data[16];
MSPGANG_Interactive_Open_Target_Device( "test" );
for(target=1; target<=8; target++)
{
for(k=0; k<16; k++)
data[k] = enter_desired_data_per_target...
MSPGANG_SetGangBuffer( target, 16, data );
}
MSPGANG_Interactive_Copy_GANG_Buffer_to_RAM( MC_addr, 16 ); //copy unique data to
RAM
//or
MSPGANG_Interactive_Copy_GANG_Buffer_to_FLASH( MC_addr, 16 ); //copy unique data to
FLASH