Extract MCU Part Number Directory
This code example prints the full list of supported MCU vendors, families, groups, and individual MCU part numbers. The condition for this example to work properly is that F_OpenInstancesAndFPAs, and F_Initialization has correctly initialized the given fpa index (1 to 64). If testing adapter 1, the user should call F_Set_FPA_index(1) before this code executes.
The code below is used to initialize the drop-down menus seen in the GUI demos that can be found in the install Elprotronic\ARM\API-DLL directory.
The sequence is as follows:
Get Vendor List
Call
F_Get_MCU_Name_list( MCU_VENDOR_LIST, k );
in a loop to read all supported vendorsThis generates a list of vendors but doesn’t actually select one, i.e. TI, ST, or NXP
Set current vendor using
F_Set_MCU_Family_Group( MCU_VENDOR_LIST, Vendor_list_index );
This function selects one vendor from the list, with given index, i.e. select ST vendor.
Get Family List from selected vendor:
Call
F_Get_MCU_Name_list( MCU_FAMILY_LIST, k );
in a loop to read all families in selected vendorThis generates a list of MCU families for one specific vendor, i.e. STM32-F0, STM32-F1, etc.
Set current family using
F_Set_MCU_Family_Group( MCU_FAMILY_LIST, Family_list_index );
This function selects one family from the list, with given index. At this point the code has selected one vendor and one family from that vendor, i.e. select STM32-F0 family.
Get Group List from selected family of selected vendor. Groups sub-divide families into similar MCUs.
Call
F_Get_MCU_Name_list( MCU_GROUP_LIST, k );
in a loop to read all groups in selected family in selected vendor.This generates a list of groups for selected family within selected vendor, i.e. STM32F0x0, STM32F0x1, STM32F0x2, and STM32F0x8
Set current group using
F_Set_MCU_Family_Group( MCU_GROUP_LIST, MCU_Group_list_index );
This functions selects one group from the list, with given index. At this point the code has selected one vendor, and one family, and one group, i.e. select STM32F0x8.
Get MCU part number list from selected group. This is the final MCU name actually used in the “MCU_name” parameter of the configuration file.
Call
F_Get_MCU_Name_list( MCU_NAME_LIST, k );
in a loop to read all MCUs in selected group, in selected family, in selected vendor.This generates a list of MCU part numbers, i.e. STM32F038C6, STM32F038E6, etc.
Select (not shown below) one MCU from the list by using
INT_X F_Set_MCU_Name(char *MCU_name );
This function selects one MCU, and changes the configuration of the library to program this specific MCU.
Snippet taken from Elprotronic\ARM\API-DLL\FP-ARM-Demo-C++:
//C++ and C# are available in the installation package
//that implement this code
//Example from demo included in installation package
//Select one FPA index to perform this sequence on.
//If all FPA are the same then iterating over other FPA indices is not necessary.
//Iterate over supported vendors, then select vendor zero in this case
//Pull-down menu in demo allows user to change selected vendor index
void ProgDemoDlg::Init_MCU_Vendor_ComboBox( void )
{
int k;
char *name;
SelMCU_Vendor->ResetContent();//Reset list of vendors
k = 0;
Vendor_list_size = 0;
do
{
//----------------------------------------------------
name = F_Get_MCU_Name_list( MCU_VENDOR_LIST, k );//get name of vendor at index k
if( strlen( name ) == 0 ) break; //reached end of list of vendors
//----------------------------------------------------
if(SelMCU_Vendor)
{
//----------------------------------------------------
SelMCU_Vendor->AddString( name ); //add newly acquired vendor name to GUI list
//----------------------------------------------------
Vendor_list_size++;
}
k++;
}while(1);
//Select vendor zero in demo GUI (will not affect DLL yet)
SelMCU_Vendor->SetCurSel(0);
//Select chosen vendor and read supported MCU families
OnCbnSelchangeMcuVendor();
}
//Initialize list of supported families for selected vendor
void ProgDemoDlg::OnCbnSelchangeMcuVendor( void )
{
Vendor_list_index = SelMCU_Vendor->GetCurSel();
//----------------------------------------------------
//Set vendor to selected index (during initialization this is usually zero)
F_Set_MCU_Family_Group( MCU_VENDOR_LIST, Vendor_list_index );
//----------------------------------------------------
Init_MCU_Family_ComboBox();
}
//Iterate over supported families for selected vendor, then select family zero in this case
//Pull-down menu in demo allows user to change selected family index
void ProgDemoDlg::Init_MCU_Family_ComboBox( void )
{
int k;
char *name;
SelMCU_Family->ResetContent();
k = 0;
Family_list_size = 0;
do
{
//----------------------------------------------------
name = F_Get_MCU_Name_list( MCU_FAMILY_LIST, k ); //get name of family at index k
if( strlen( name ) == 0 ) break; //reached end of list of families
//----------------------------------------------------
if(SelMCU_Family)
{
//----------------------------------------------------
SelMCU_Family->AddString( name ); //add newly acquired family name to GUI list
//----------------------------------------------------
Family_list_size++;
}
k++;
}while(1);
//Select family zero in demo GUI (will not affect DLL yet)
SelMCU_Family->SetCurSel(0);
//Select chosen family and read supported MCU groups
OnCbnSelchangeMcuFamily();
}
//Initialize list of supported groups for selected family
void ProgDemoDlg::OnCbnSelchangeMcuFamily( void )
{
Family_list_index = SelMCU_Family->GetCurSel();
//----------------------------------------------------
//Set family to selected index (during initialization this is usually zero)
F_Set_MCU_Family_Group( MCU_FAMILY_LIST, Family_list_index );
//----------------------------------------------------
Init_MCU_Group_ComboBox();
}
//Iterate over supported groups for selected family, then select group zero in this case
//Pull-down menu in demo allows user to change selected group index
void ProgDemoDlg::Init_MCU_Group_ComboBox( void )
{
int k;
char *name;
SelMCU_Group->ResetContent();
MCU_Group_list_size = 0;
k = 0;
do
{
//----------------------------------------------------
name = F_Get_MCU_Name_list( MCU_GROUP_LIST, k ); //get name of group at index k
if( strlen( name ) == 0 ) break; //reached end of list of groups
//----------------------------------------------------
if(SelMCU_Group)
{
//----------------------------------------------------
SelMCU_Group->AddString( name ); //add newly acquired group name to GUI list
//----------------------------------------------------
MCU_Group_list_size++;
}
k++;
}while(1);
//Select group zero in demo GUI (will not affect DLL yet)
SelMCU_Group->SetCurSel(0);
//Select chosen group and read supported MCUs
OnCbnSelchangeMcuGroup();
}
//Initialize list of supported MCUs for selected group
void ProgDemoDlg::OnCbnSelchangeMcuGroup( void )
{
MCU_Group_list_index = SelMCU_Group->GetCurSel();
//----------------------------------------------------
//Set group to selected index (during initialization this is usually zero)
F_Set_MCU_Family_Group( MCU_GROUP_LIST, MCU_Group_list_index );
//----------------------------------------------------
Init_MCU_List_ComboBox();
}
//Iterate over supported MCUs for selected group, then select MCU zero in this case
//Pull-down menu in demo allows user to change selected MCU index
void ProgDemoDlg::Init_MCU_List_ComboBox( void )
{
int k;
char *name;
SelMCU_List->ResetContent();
MCU_Name_list_size = 0;
k = 0;
do
{
//----------------------------------------------------
name = F_Get_MCU_Name_list( MCU_NAME_LIST, k ); //get name of MCU at index k
if( strlen( name ) == 0 ) break; //reached end of list of MCUs
//----------------------------------------------------
if(SelMCU_List)
{
//----------------------------------------------------
SelMCU_List->AddString( name ); //add newly acquired MCU name to GUI list
//----------------------------------------------------
MCU_Name_list_size++;
}
k++;
}while(1);
//Select MCU zero in demo GUI (will not affect DLL yet)
SelMCU_List->SetCurSel(0);
}