Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

These functions operate on meta-data within the Multi API-DLL and help manage the underlying API-DLL instances. These functions do not directly program target devices. Use these functions to initialize the desired number of FPAs, selected all or one FPA(s), read FPA serial numbers, or clean-up resources used by Elprotronic’s DLLs.

Once the desired FPAs have been successfully opened, use Generic Functions to initialize the FPAs, and configure them for the target device(s) being programmed.

Table of Contents
minLevel1
maxLevel2

1. F OpenInstancesAndFPAs

General Description

Multi API-DLL scans USB ports or LAN for connected FPAs listed in the setup file, or input string. When an FPA listed in the setup file is found, the corresponding API-DLL is copied on disk if necessary, and loaded. F_Initialization should be called for each FPA after this function succeeds.

Syntax

IMPORTANT

Do not invoke F Check FPA access after this function has assigned FPAs to USB ports. To check simple communi- cation with FPA, use the F Get FPA SN function.

Syntax
Code Block
languagecpp
INT_X F_OpenInstancesAndFPAs( char * FileName )

Input

char * FileName : path to setup file, or list of serial numbers.

38

...

Valid FPAs-setup.ini setup file lists FPAs and SN pairs.

Code Block
FPA-1
20090123
 20150003
FPA-
3 20090234
2 20180134
--or--

FPA-1 20090123

FPA-
3
2 *	//any serial  number  (can  only be  done  at last line)

Valid FPAsIPs.ini, setup file lists FPAs by IP address:

Code Block
FPAETH-
-INVALID--
IP-1 192.168.0.101
FPAETH-IP-2 192.168.0.102
FPAETH-IP-3 192.168.0.103
FPAETH-IP-4 192.168.0.104

Invalid example:

Code Block
FPA-1 *	//this line will be read
FPA-
3
2 *	//this line will be ignored
List

Valid list of serial numbers

...

as a string:

Code Block
"*# FPA-1 20090123 FPA-2 20090346"

translates to:

Code Block
FPA-1 20090123

FPA-2
20090345
 20090346

input string: "*# *" translates to:

Code Block
FPA-1 *

In both cases, for the setup file and the input string, if a

...

specied FPA is missing then it will not
affect subsequent entries. Therefore, a setup file with these contents:

Code Block
FPA-1
 20090123

FPA-2
 20090346

FPA-3
 20090222

FPA-4
 20090245

and with FPA-3 missing (not connected, etc.) will initialize the Multi API-DLL to:

Code Block
FPA-1
 20090123

FPA-2
 20090346

FPA-3
 empty

FPA-4
 20090245

Output

INT X : number of instances opened successfully

  • 0 - failed

2 F

...

_

...

CloseInstances

General Description

All FPAs terminate communication with target devices and close target devices according to

...

configuration settings (power setting, adapter line states, etc.). Finally, the USB/Ethernet connections to the FPAs are terminated and API-DLL instances are freed. The Multi API-DLL can now be used to open a new set of FPAs using the function F_OpenInstancesAndFPAs.

Syntax

INT_X F_CloseInstances ( void );

Input

none.

Output

INT X : success or failed

  • TRUE (1) - success

  • FALSE (0) - failed

3. F_Set_FPA_index

...

General Description

Select desired FPA index to perform specific tasks (access specific API-DLL instance).

Syntax

...

Code Block
languagecpp
INT_X F_Set_FPA_index ( BYTE fpa );

Input

BYTE fpa : desired FPA index, 1 to 64, or 0 for all

Output

INT X : success or error

  • TRUE (1), used FPA index is valid

  • FPA_INVALID_NO (-2 or 0xFFFFFFFE) : FPA not opened with F OpenInstancesAndFPAs or index out of range

...

IMPORTANT

Other functions that try to access

...

this FPA index will also return FPA_INVALID_NO if this function was not called with a proper parameter.

4. F_Get_FPA

...

_

...

index

General Description

Get current FPA index.

Syntax

Code Block
BYTE F_Get_FPA_index( void );

Input

none.

Output

BYTE : current FPA index as

...

set using F_Set_FPA_index

5. F_Check_FPA_index

...

General Description

Get current FPA index and check if index is valid. A valid index corresponds to an individual FPA that has been opened with F_OpenInstancesAndFPAs. If FPA index was set to 0 (all), then this function will only return 0, even if no FPAs are open. Does not indicate whether FPA index is enabled or disabled.

Syntax

Code Block
languagecpp
INT_X F_Check_FPA_index ( void );

Input

none.

Output

INT X : current fpa index if valid

  • current FPA index as entered using F_Set_FPA_index if selected FPA has been opened with F_OpenInstancesAndFPAs

...

  • FPA_INVALID_NO (-2 or 0xFFFFFFFE) : FPA not opened with F_OpenInstancesAndFPAs or index out of range

6. F_Enable_FPA

...

_

...

index

General Description

Enable desired FPA index to accept commands. An FPA index is enabled by default. A disabled FPA index will ignore commands when the FPA index is set to it, or 0 (all FPAs).

Syntax

Code Block
void F_Enable_FPA_index ( BYTE fpa );

Input

BYTE fpa : desired FPA index, 1 to 64

Output

none.

7. F_Disable_FPA_index

...

General Description

Disable desired FPA index to ignore commands. An FPA index is enabled by default. A disabled FPA index will ignore commands when the FPA index is set to it, or 0 (all FPAs).

Syntax

Code Block
void F_Disable_FPA_index ( BYTE fpa );

Input

BYTE fpa : desired FPA index, 1 to 64

Output

none.

8. F_LastStatus

...

General Description

Return value from the last function call issued to the specified FPA (API-DLL instance). This function is useful when multiple FPAs are being programmed using FPA index 0 (all), but the return value was not the same for all FPAs (i.e. 4 FPAs succeeded, 1 FPA failed). When the return value is not the same for all FPAs then, then the actual return value from the Multi API-DLL will be FPA_UNMATCHED_RESULTS. To find out per FPA return values, select each FPA index individually using F_Set_FPA_index, and call F_LastStatus for each index.

Syntax

Code Block
languagecpp
INT_X F_LastStatus  ( BYTE  fpa  );

Input

BYTE fpa : desired FPA index, 1 to 64.

Output

INT X : Last return value from the selected FPA (API-DLL instance).

  • INT X type return value from last function call on selected FPA

  • FPA_INVALID_NO (-2 or 0xFFFFFFFE) : FPA not opened with F_OpenInstancesAndFPAs or index out of range

9. F_Multi

...

_

...

DLLTypeVer

General Description

Get Multi API-DLL software version number.

Syntax

Code Block
languagecpp
INT_X F_Multi_DLLTypeVer( void );

Input

none.

Output

INT X : (DLL_ID)

...

| (

...

Version)

  • DLL ID = 0x06000, FlashPro430

  • DLL ID = 0x07000, GangPro430

  • DLL ID = 0x08000, FlashPro-CC

  • DLL ID = 0x09000, GangPro-CC

  • DLL ID = 0x0C000, FlashPro2000

  • DLL ID = 0x0D000, GangPro2000

  • DLL ID = 0x10000, FlashPro-ARM

  • DLL ID = 0x11000, GangPro-ARM

Version = 0x0xyz, version x.yz (i.e. 0x0190 = v 1.90)

FPA INVALID NO (-2 or 0xFFFFFFFE) : FPA not opened with F OpenInstancesAndFPAs or index out of range

F_Get_FPA_SN_bookmark199_bookmark199F Get FPA SN

General Description

Get serial number (SN) of FPA assigned to specified index.

Syntax

INT_X F_Get_FPA_SN ( BYTE fpa );

Input

BYTE fpa : desired FPA index, 1 to 64

Output

INT X : serial number

SN of selected FPA

...

  • Code Block
    	// return	 Type + Version	
    	//           Type	0x6000 - Multi-FPA FlashPro430
    	//					0x7000 - Multi-FPA GangPro430
    	//					0x8000 - Multi-FPA FlashPro-CC
    	//					0x9000 - Multi-FPA GangPro-CC
    	//					0xC000 - Multi-FPA FlashPro2000
    	//					0xD000 - Multi-FPA GangPro2000
    	//				   0x10000 - Multi-FPA FlashPro-ARM
    	//				   0x11000 - Multi-FPA GangPro-ARM
    	//				   0x17000 - Multi-FPA FlashPro-M
    	//				   0x18000 - Multi-FPA GangPro-M
    	//			 Version = 0x0FFF & version
  • FPA_INVALID_NO (-2 or 0xFFFFFFFE) : FPA not opened with F_OpenInstancesAndFPAs or index out of range

10. F_Get_FPA_

...

SN

General Description

Get

...

Syntax

INT_X F_Get_FPA_Label ( BYTE fpa, BYTE *label );

Input

BYTE fpa : desired FPA index, 1 to 64.

...

serial number (SN) of FPA assigned to specified index.

Syntax

Code Block
languagecpp
INT_X F_Get_FPA_SN ( BYTE fpa );

Input

BYTE fpa : desired FPA index, 1 to 64

Output

INT X : serial number

  • SN of selected FPA

  • FPA_INVALID_NO (-2 or 0xFFFFFFFE) : FPA not opened with F_OpenInstancesAndFPAs or index out of range

11. F_Get_FPA_Label

General Description

Get detailed information of FPA assigned to specified index.

Syntax

Code Block
INT_X F_Get_FPA_Label ( BYTE fpa, BYTE *label );

Input

BYTE fpa : desired FPA index, 1 to 64.

BYTE *label : pointer to instance of FPA_LABEL and bytes array, i.e.

Code Block
FPA_LABEL inst; 
F_Get_FPA_Label(i, inst.bytes); //get label for FPA-i
Code Block
languagecpp
#define ADAPTER_HARDWARE_PN_SIZE		16	
#define ADAPTER_DESCRIPTION_SIZE		32
#define FPA_LABEL_SIZE					((ADAPTER_HARDWARE_PN_SIZE + ADAPTER_DESCRIPTION_SIZE)*sizeof(char) + 12*sizeof(BYTE) + sizeof(long))
union FPA_LABEL
{
	BYTE	bytes[ FPA_LABEL_SIZE ];
	struct
	{
		long  SN;
		BYTE  hardware_ID;
		BYTE  hardware_SubID;
		BYTE  full_access;
		BYTE  Interface_Type;
		BYTE  Valid_access_key;
		BYTE  spare3;
		BYTE  spare4;
		BYTE  spare5;
		BYTE  spare6;
		BYTE  spare7;
		BYTE  spare8;
		BYTE  spare9;
		char  adapter_hardware_PN[ ADAPTER_HARDWARE_PN_SIZE ];
		char  adapter_description[ ADAPTER_DESCRIPTION_SIZE ];
	}x;
};

Output

INT X : serial number, hardware ID, meta-data

  • updated FPA_LABEL structure pointed to by label input parameter

  • FPA_INVALID_NO (-2 or 0xFFFFFFFE) : FPA not opened with F OpenInstancesAndFPAs or index out of range

...

#define FPA_LABEL_SIZE 80

#define ADAPTER_HARDWARE_PN_SIZE 16

#define ADAPTER_DESCRIPTION_SIZE 32

...

Example of printing FPA_LABEL:

{

BYTE bytes[ FPA_LABEL_SIZE ];

struct

{

long SN;

BYTE hardware_ID;

BYTE hardware_SubID;

BYTE full_access;

BYTE Interface_Type;

BYTE Valid_access_key; BYTE spare3;

BYTE spare4; BYTE spare5; BYTE spare6; BYTE spare7; BYTE spare8; BYTE spare9;

char adapter_hardware_PN[ ADAPTER_HARDWARE_PN_SIZE ]; char adapter_description[ ADAPTER_DESCRIPTION_SIZE ];

}x;

};

F_GetProgressBar_bookmark201_bookmark201F GetProgressBar
Code Block
language
cpp
std::stringstream msg;
msg << "INIT: " << (i) << ": Get_FPA_Label, SN=" << inst.x.SN << "\r\n";
msg << "INIT:   HW ID=" << (int)inst.x.hardware_ID << ", HW sub-ID=" << (int)inst.x.hardware_SubID << "\r\n";
msg << "INIT:   Full Access=" << (int)inst.x.full_access << ", Interface Type=" << (int)inst.x.Interface_Type << "\r\n";
msg << "INIT:   Access Key=" << (int)inst.x.Valid_access_key << "\r\n";
msg << "INIT:   HW PN=" << inst.x.adapter_hardware_PN << "\r\n";
msg << "INIT:   Adapter Desc=" << inst.x.adapter_description;

12. F_GetProgressBar

General Description

Get internal progress counter value for operations done inside

...

Encapsulated Functions . When used in conjunction with F_GetLastOpCode it allows the user application to keep track of progress in the same way that the FlashPro-ARM/GangPro-ARM GUI does.

Will return value between 0 and 100 for current sub-operation being performed inside

...

encapsulated function. Depending on the complexity of the encapsulated function, the number of

...

sub-operations will vary. Use F GetLastOpCode to get currently running sub-operation opcode. When transitioning from one sub-operation that reached a progress value of 100, to another sub-operation, the progress value will restart at 0. This will repeat until the last sub-operation upon which the progress value will remain at 100. A new invocation of an encapsulated function will restart the progress value at 0.

This function is thread-safe, therefore it can be called while the Multi API-DLL is busy, for

...

example running F_AutoProgram. Intended usage is to call an encapsulated function with one thread, and repeatedly call this function and F_GetLastOpCode with another thread. When

...

simultaneously programming using multiple FPAs (fpa index set to 0 (ALL FPAs), the thread monitoring progress can iterate different input parameters (fpa=1, fpa=2, fpa=3, etc.) to monitor the progress of each FPA individually. This function cannot be called with parameter 0 (ALL FPAs).

Syntax

Code Block
languagecpp
INT_X	MSPPRG_API F_GetProgressBar(  BYTE  fpa  );

Input

BYTE fpa : desired FPA index, 1 to 64.

Output

INT X : progress indicator

  • value between 0 and 100

  • FPA_INVALID_NO (-2 or 0xFFFFFFFE) : FPA not opened with F_OpenInstancesAndFPAs or index out of range

...

Example

Refer to GetLastOpCode.

13. F_GetLastOpCode

...

General Description

Read internal opcode value for sub-operations done inside Encapsulated Functions

...

.

...

When used in conjunction with F_GetProgressBar it allows the user application to keep track of progress in the same way that the FlashPro-ARM/GangPro-ARM GUI does.

Will return opcode for current sub-operation being performed inside encapsulated function. Depending on the complexity of the encapsulated function, the number of sub-operations will vary. Use F_GetProgressBar to get progress value between 0 and 100, of currently running sub-operation. When transitioning from one sub-operation that reached a progress value of 100, to

...

another sub-operation, the progress value will restart at 0 and the opcode will be set to the new sub-operation, currently being run. This will repeat until the last sub-operation upon which the opcode will not change. A new invocation of an encapsulated function will reset the opcode to the first sub-operation of the new encapsulated function.

This function is thread-safe, therefore it can be called while the Multi API-DLL is busy, for

...

example running F_AutoProgram. Intended usage is to call an encapsulated function with one thread, and repeatedly call this function and F_GetProgressBar with another thread. When simultaneously programming using multiple FPAs (fpa index set to 0 (ALL FPAs), the thread monitoring progress can iterate different input parameters (fpa=1, fpa=2, fpa=3, etc.) to monitor the progress of each FPA individually. This function cannot be called with parameter 0 (ALL FPAs).

Syntax

Code Block
languagecpp
INT_X	MSPPRG_API F_GetLastOpCode( BYTE fpa );

Input

BYTE fpa : desired FPA index, 1 to 64.

Output

INT X : opcode of currently running sub-operation

  • PROG_OPCODE_VERIFY_ACCESS (1) : FPA is attempting to perform action described in F_Verify_Access to MCU.

...

  • PROG_OPCODE_FLASH_ERASE (2) : FPA is attempting to perform action described in F_Memory_Erase.

...

  • PROG_OPCODE_FLASH_BLANK_CHECK (3) : FPA is attempting to perform action

...

  • described in F_Memory_Blank_Check.

...

  • PROG_OPCODE_FLASH_SELECTED_BLANK_CHECK (4) : FPA is attempting to perform action described in F_Memory_Blank_Check when a subset of the memory space is selected in configuration settings.

...

  • PROG_OPCODE_FLASH_WRITE (5) : FPA is attempting to perform action described in F_Memory_Write.

  • PROG_OPCODE_FLASH_VERIFY (6) : FPA is attempting to perform action described in F_Memory_Verify.

...

  • PROG_OPCODE_FLASH_READ (7) : FPA is attempting to perform action described in F_Memory_Read.

...

  • PROG_OPCODE_LOCK_MCU (8) : FPA is attempting to perform action described in F_Lock_MCU.

...

  • PROG_OPCODE_UNLOCK_MCU (9) : FPA is attempting to perform action described in F_Clear_Locked_Device.

...

  • PROG_OPCODE_START_APP (10) : FPA is attempting to run application programmed onto target device (if enabled to be ran after F_AutoProgram in configuration settings).

  • FPA INVALID NO (-2 or 0xFFFFFFFE) : FPA not opened with F_OpenInstancesAndFPAs or index out of range

...

Example

void ProgDemoDlg::UpdateProgress()

{

//This function works a bit different than all the others.

//Usually the Multi-API DLL is not thread safe and

//only one thread can enter the Multi-API DLL.

//This function is thread-safe because it is read-only. FPA index != 0. if(fpa == 0)

{

//You can average out the results here,

//or do separate bars per FPA.

//For AutoProgram the progress bar will go from 0 to 100 many

//times during one run because of sub-opcodes. return;

}

...

Example

Code Block
languagecpp
void UpdateProgress(BYTE fpa, INT_X &progValue, INT_X &lastOpCode, CString &opCodeUpdate)
{
  if(fpa == 0)
  {
    //invalid index
    return;
  }
  progValue = F_GetProgressBar(fpa);
prog->SetPos(progValue);INT_X lastOpCode =

  lastOpCode = F_GetLastOpCode(fpa);
CString

  opCodeUpdate = "Unknown";
  switch(lastOpCode)

{

case

  {
    case PROG_OPCODE_VERIFY_ACCESS:
opCodeUpdate =

      opCodeUpdate = "Verify Access To MCU";
      break;

    case PROG_OPCODE_FLASH_ERASE:

opCodeUpdate = "Flash Erase"; break;

case

      opCodeUpdate = "Flash Erase";
      break;
    case PROG_OPCODE_FLASH_BLANK_CHECK:
opCodeUpdate =

      opCodeUpdate = "Flash Blank Check";
      break;

    case PROG_OPCODE_FLASH_SELECTED_BLANK_CHECK:
opCodeUpdate =

      opCodeUpdate = "Selected Memory Blank Check";
      break;

    case PROG_OPCODE_FLASH_WRITE:
opCodeUpdate =

      opCodeUpdate = "Flash Write";
      break;

    case PROG_OPCODE_FLASH_VERIFY:
opCodeUpdate =

      opCodeUpdate = "Flash Verify";
      break;

    case PROG_OPCODE_FLASH_READ:
opCodeUpdate =

      opCodeUpdate = "Flash Read";
      break;

    case PROG_OPCODE_LOCK_MCU:
opCodeUpdate =

      opCodeUpdate = "Lock MCU";
      break;

    case PROG_OPCODE_UNLOCK_MCU:
opCodeUpdate =

      opCodeUpdate = "Unlock MCU";
break;case

      break;
    case PROG_OPCODE_START_APP:
opCodeUpdate =

      opCodeUpdate = "Start
Application"; break;

}

CString currentOpCode = ""; GetDlgItemText(IDC_OPCODE, currentOpCode);

//Don’t update if it’s the same text (prevents flashing) if(currentOpCode.Compare(opCodeUpdate) != 0)

SetDlgItemText(IDC_OPCODE, opCodeUpdate);

}

Trace_ON_bookmark203_bookmark203Trace ON
 Application";
      break;
  }  
}

14. F_Trace_ON

General Description

Activate tracing for subsequent calls to the Multi API-DLL. Log is saved in DLLtrace.txt located in the Multi API-DLL directory. When activated, records all API-DLL function calls from the application software invoked via the Multi API-DLL. The DLLtrace.txt is overwritten for each new session.

Syntax

Code Block
languagecpp
void F_Trace_ON( void );

Input

none.

Output

none.

15. F_Trace_OFF

...

General Description

Disable tracing.

Syntax

Code Block
languagecpp
void F_Trace_OFF( void );

Input

none.

Output

none.