STM32CubeProgrammer API: STM32CubeProgrammer API Documentation

STM32CubeProgrammer API
STM32CubeProgrammer API Documentation

Introduction

In addition to the graphical user interface and the commandline interface, STM32CubeProgrammer offers a C++ API that you could use to develop your own application and benefit of wide range of features to program STM32 microcontrollers memories (such as Flash, RAM, and OTP) either over debug interface or bootloder interface (USB DFU, UART, I²C, SPI and CAN).

This documentation details all types and functions API to use STM32CubeProgrammer functionalities.

STM32CubeProgrammer API package

The API package is based on the following resources that are ready for use :

File | Description
CubeProgrammer_API.h | header file contains functions declarations and macro definitions to be used by the CubeProgrammer_API.dll.
DeviceDataStructure.h | header file contains macro definitions to be shared between several functions.
CubeProgrammer_API.dll/.so/.dylib | Dynamic Link Library file contains a library of functions and other informations that can be accessed by windows, linux and MacOs programs.
CubeProgrammer_API.lib | import library for use with MSVC compiler.

Application System requirements

We offer various examples developed for use with Visual Studio and Qt Creator IDEs:

  • Visual Studio project for windows applications under MSVC compiler.
  • Qt project for Windows, Linux and MacOs applications under MinGW compiler.
    Note
    The attached examples are tested on STM32F429, STM32L4R9 and STM32L452RE Nucleo Boards.

Windows build settings

To ensure the correct environment for the provided examples, some constraints must be taken into account

Visual studio

The code was developed with Microsoft Visual Studio Community 2017 version 15.6.6 with Windows SDK version : 10.0.16299.0 and it was tested also on Microsoft Visual Studio 2010

  • Verify that the api's lib directory is the default working directory.
  • The debug command is to execute the application that is resided in the output directory.
  • Insert the Additional Include Directories:
  • Indicate the output name and path.
  • Insert the Additional Library Directories.
  • Insert the Additional Dependencies, The CubeProgrammer_API import library "CubeProgrammer_API.lib" must be added to Linker input
    Note
    The provided Visual studio project is already configured like the description above and you can change it carefully according to your use case.

Qt creator

The Qt projects are developed with Qt Creator 4.7.1, Qt 5.11.2 and MinGW 32 bit compiler and also it can be compiled by MinGW x64.
The shadow build option must be disable to inform Qt that the build should be located in the original Qt project directory.

Note
Verify that the following DLLs are placed to /lib in the api package directory :
CubeProgrammer_API.dll | FileManager.dll | STLinkUSBDriver.dll
HSM_P11_Lib.dll | libeay32.dll | libgcc_s_dw2-1.dll
stlibp11_SAM.dll | libstdc++-6.dll | libwinpthread-1.dll
mfc120.dll | msvcp120.dll | msvcr120.dll
Qt5Core.dll | Qt5SerialPort.dll | Qt5Xml.dll

Linux build settings

To correctly build the Qt project in linux platform, you should follow the next 3 steps:

  1. Select the build configuration in Projects field of the main view.
  2. Disable the Shadow build option.
  3. Go to build environment, add the System Environment variable LD_LIBRARY_PATH and set the path to ../../../../lib
Note
Verify that the following Shared Objects are placed to /lib in the STM32CubeProgrammer package directory :
libCubeProgrammer_API.so | libCubeProgrammer_API.so.1 | libSTLinkUSBDriver.so | libFileManager.so.1
libhsmp11.so | libQt5SerialPort.so.5 | libQtXml.so.5 | libQt5Core.so.5
libicudata.so.56 libicui18n.so.56 libicuuc.so.56 -

MacOS build settings

To get the default api folder that is integrated into the STM32CubeProgrammer package already installed, go to
/Application/STMicroelectronics/STM32Cube/STM32CubeProgrammer/STM32CubeProgrammer.app/contents/MacOs/api

Note
Verify that the following Mach Objects are placed to /Application/STMicroelectronics/STM32Cube/STM32CubeProgrammer/STM32CubeProgrammer.app/contents/MacOs/bin in the STM32CubeProgrammer package directory:
libCubeProgrammer_API.dylib | libCubeProgrammer_API.1.dylib | libCubeProgrammer_API.1.0.dylib | libCubeProgrammer_API.1.0.0.dylib
libFileManager.dylib | libFileManager.1.dylib | libFileManager.1.0.dylib | libFileManager.1.0.0.dylib
libSTLinkUSBDriver.dylib | libhsmp11.dylib | libstP11_SAM.dylib | libusb-1.0.0.dylib
QtSerialPort.framework QtXml.framework QtCore.framework -
Generated by doxygen 1.8.14


STM32CubeProgrammer API: Modules

Modules
Here is a list of all modules:
STLINK
Bootloader
General
OB
Loaders


STM32CubeProgrammer API: STLINK

Functions
STLINK

Functions

int | getStLinkList (debugConnectParameters **stLinkList, int shared)
This routine allows to get ST-LINK conneted probe(s). More...
int | connectStLink (debugConnectParameters debugParameters)
This routine allows to start connection to device through SWD or JTAG interfaces. More...
int | reset (debugResetMode rstMode)
This routine used to apply a target reset. More...

Detailed Description

STLINK module groups debug ports JTAG/SWD functions together.

Function Documentation

◆ connectStLink()

int connectStLink ( debugConnectParameters debugParameters )

This routine allows to start connection to device through SWD or JTAG interfaces.

Parameters
debugParameters : Indicates customized configuration for ST-LINK connection, It is recommended to check [debugConnectParameters] fields before connection.
Returns
0 if the connection successfully established, otherwise an error occurred.
Examples:
STLINK_Example1, STLINK_Example2, and STLINK_Example3.

◆ getStLinkList()

int getStLinkList | ( | debugConnectParameters ** | stLinkList,
 |  | int | shared
 | ) |  |

This routine allows to get ST-LINK conneted probe(s).

Parameters
stLinkList | : Filled with the connected ST-LINK list and its default configurations.
shared | : Enable shared mode allowing connection of two or more instances to the same ST-LINK probe.
Returns
Number of the ST-LINK probes already exists.
Warning
The Share option is useful only with ST-LINK Server.
Note
At the end of usage, deleteInterfaceList must have been called.
Examples:
STLINK_Example1, STLINK_Example2, and STLINK_Example3.

◆ reset()

int reset ( debugResetMode rstMode )

This routine used to apply a target reset.

Note
Reset operation is only available with JTAG/SWD debug interface.
Parameters
rstMode : Indicates the reset type Soft/Hard/Core debugResetMode.
Returns
0 if the reset operation finished successfully, otherwise an error occurred.
Examples:
STLINK_Example1, and STLINK_Example3.


STM32CubeProgrammer API: Bootloader

Functions
Bootloader

Functions

int | getUsartList (usartConnectParameters **usartList)
This routine allows to get connected serial ports. More...
int | connectUsartBootloader (usartConnectParameters usartParameters)
This routine allows to start connection to device through USART interface. More...
int | sendByteUart (int byte)
This routine allows to send a single byte through the USART interface. More...
int | getDfuDeviceList (dfuDeviceInfo **dfuList)
This routine allows to get connected DFU devices. More...
int | connectDfuBootloader (char *usbIndex)
This routine allows to start connection to device through USB DFU interface. More...
int | connectSpiBootloader (spiConnectParameters spiParameters)
This routine allows to start connection to device through SPI interface. More...
int | connectCanBootloader (canConnectParameters canParameters)
This routine allows to start connection to device through CAN interface. More...
int | connectI2cBootloader (i2cConnectParameters i2cParameters)
This routine allows to start connection to device through I2C interface. More...

Detailed Description

Bootloader module is a way to group Serial interfaces USB/UART/SPI/I2C/CAN functions together.

Function Documentation

◆ connectCanBootloader()

int connectCanBootloader ( canConnectParameters canParameters )

This routine allows to start connection to device through CAN interface.

Parameters
canParameters : Indicates customized configuration for CAN connection
Returns
0 if the connection successfully established, otherwise an error occurred.
Warning
To have CAN full support, you must have St-Link firmware version at least v3JxMxB2.
Examples:
CAN_Bootloader.

◆ connectDfuBootloader()

int connectDfuBootloader ( char * usbIndex )

This routine allows to start connection to device through USB DFU interface.

Parameters
usbIndex : Indicates the index of DFU ports already connected.
Returns
0 if the connection successfully established, otherwise an error occurred.
Examples:
USB_Bootloader.

◆ connectI2cBootloader()

int connectI2cBootloader ( i2cConnectParameters i2cParameters )

This routine allows to start connection to device through I2C interface.

Parameters
i2cParameters : Indicates customized configuration for I2C connection
Returns
0 if the connection successfully established, otherwise an error occurred.
Examples:
I2C_Bootloader.

◆ connectSpiBootloader()

int connectSpiBootloader ( spiConnectParameters spiParameters )

This routine allows to start connection to device through SPI interface.

Parameters
spiParameters : Indicates customized configuration for SPI connection
Returns
0 if the connection successfully established, otherwise an error occurred.
Examples:
SPI_Bootloader.

◆ connectUsartBootloader()

int connectUsartBootloader ( usartConnectParameters usartParameters )

This routine allows to start connection to device through USART interface.

Parameters
usartParameters : Indicates customized configuration for USART connection.
Returns
0 if the connection successfully established, otherwise an error occurred.
Examples:
UART_Bootloader.

◆ getDfuDeviceList()

int getDfuDeviceList ( dfuDeviceInfo ** dfuList )

This routine allows to get connected DFU devices.

Parameters
dfuList : Receive DFU devices list and its default configurations.
Returns
Number of DFU devices already connected.
Note
At the end of usage, deleteInterfaceList must have been called.
Examples:
USB_Bootloader.

◆ getUsartList()

int getUsartList ( usartConnectParameters ** usartList )

This routine allows to get connected serial ports.

Parameters
usartList : Receive serial ports list and its default configurations.
Returns
Number of serial ports already connected.
Note
At the end of usage, deleteInterfaceList must have been called.
Examples:
UART_Bootloader.

◆ sendByteUart()

int sendByteUart ( int byte )

This routine allows to send a single byte through the USART interface.

Parameters
byte : The data to be written
Returns
0 if the sending operation correctly achieved, otherwise an error occurred.


STM32CubeProgrammer API: General

Functions
General

Functions

void | setDisplayCallbacks (displayCallBacks c)
This routine allows to choose your custom display. More...
void | setVerbosityLevel (int level)
This routine allows to choose the verbosity level for display. More...
int | checkDeviceConnection ()
This routine allows to check connection status [maintained or lost]. More...
generalInf * getDeviceGeneralInf ()
This routine allows to get general device informations. More...
int | readMemory (unsigned int address, unsigned char **data, unsigned int size)
This routine allows to receive memory data on the used interface with the configration already initialized. More...
int | writeMemory (unsigned int address, char *data, unsigned int size)
This routine allows to write memory data on the user interface with the configration already initialized. More...
int | downloadFile (const wchar_t *filePath, unsigned int address, unsigned int skipErase, unsigned int verify, const wchar_t *binPath)
This routine allows to download data from a file to the memory. File formats that are supported : hex, bin, srec. More...
int | execute (unsigned int address)
This routine allows to run the application. More...
int | massErase ()
This routine allows to erase the whole Flash memory. More...
int | sectorErase (unsigned int sectors[], unsigned int sectorNbr)
This routine allows to erase specific sectors of the Flash memory. More...
int | readUnprotect ()
This routine allows to disable the readout protection. If the memory is not protected, a message appears to indicate that the device is not under Readout protection and the command has no effects. More...
int | getTargetInterfaceType ()
This routine allows to know the interface what is in use. More...
volatile int * | getCancelPointer ()
This routine allows to drop the current read/write operation. More...
void * | fileOpen (const wchar_t *filePath)
This routine allows to open and get data from any supported file extension. More...
void | freeFileData (fileData_C *data)
This routine allows to clean up the handled file data. More...
int | verify (fileData_C *fileData, unsigned int address)
This routine allows to verfiy if the indicated file data is identical to Flash memory content. More...
int | saveFileToFile (fileData_C *fileData, const wchar_t *sFileName)
This routine allows to save the data file content to another file. More...
int | saveMemoryToFile (int address, int size, const wchar_t *sFileName)
This routine allows to save Flash memory content to file. More...
void | disconnect ()
This routine allows to clean up and disconnect the current connected target. More...
void | deleteInterfaceList ()
This routine allows to clear the list of each created interface. More...
void | automaticMode (const wchar_t *filePath, unsigned int address, unsigned int skipErase, unsigned int verify, int isMassErase, char *obCommand, int run)
This routine allows to enter and make an automatic process for memory management through JTAG/SWD, UART, DFU, SPI, CAN and I²C interfaces. More...

Detailed Description

General module groups general purposes functions used by any interface.

Function Documentation

◆ automaticMode()

void automaticMode | ( | const wchar_t * | filePath,
 |  | unsigned int | address,
 |  | unsigned int | skipErase,
 |  | unsigned int | verify,
 |  | int | isMassErase,
 |  | char * | obCommand,
 |  | int | run
 | ) |  |

This routine allows to enter and make an automatic process for memory management through JTAG/SWD, UART, DFU, SPI, CAN and I²C interfaces.

Parameters
filePath | : Indicates the full file path.
address | : The address to start downloading from.
skipErase | : If we have a blank device, we can skip erasing memory before programming [skipErase=0].
verify | : Add verification step after downloading.
isMassErase | : Erase the whole Flash memory.
obCommand | : Indicates the option bytes commands to be loaded "-ob [optionbyte=value] [optionbyte=value]..."
run | : Start the application.
Warning
Connection to target must be established before performing automatic mode.

◆ checkDeviceConnection()

int checkDeviceConnection ( )

This routine allows to check connection status [maintained or lost].

Returns
1 if the device is already connected, otherwise the connection to device is lost.

◆ deleteInterfaceList()

void deleteInterfaceList ( )

This routine allows to clear the list of each created interface.

Note
The list is filled by #getStlinkList, getDfuDeviceList or getUsartList.
Examples:
STLINK_Example1, STLINK_Example2, STLINK_Example3, UART_Bootloader, and USB_Bootloader.

◆ disconnect()

void disconnect ( )

This routine allows to clean up and disconnect the current connected target.

Note
This routine disconnect the target and delete the loaded Flash Loaders.
Examples:
CAN_Bootloader, I2C_Bootloader, SPI_Bootloader, STLINK_Example1, STLINK_Example2, STLINK_Example3, UART_Bootloader, and USB_Bootloader.

◆ downloadFile()

int downloadFile | ( | const wchar_t * | filePath,
 |  | unsigned int | address,
 |  | unsigned int | skipErase,
 |  | unsigned int | verify,
 |  | const wchar_t * | binPath
 | ) |  |

This routine allows to download data from a file to the memory. File formats that are supported : hex, bin, srec.

Parameters
filePath | : Indicates the full path of the considered file.
address | : The address to start downloading from.
skipErase | : In case to win in term time and if we have a blank device, we can skip erasing memory before programming [skipErase=0].
verify | : To add verification step after downloading.
binPath | : Path of the binary file.
Returns
0 if the downloading operation correctly finished, otherwise an error occurred.
Examples:
CAN_Bootloader, I2C_Bootloader, SPI_Bootloader, STLINK_Example2, STLINK_Example3, UART_Bootloader, and USB_Bootloader.

◆ execute()

int execute ( unsigned int address )

This routine allows to run the application.

Parameters
address : The address to start executing from. In most cases, the program will run from the Flash memory starting from 0x08000000.
Returns
0 if the execution correctly started, otherwise an error occurred.
Examples:
STLINK_Example2.

◆ fileOpen()

void* fileOpen ( const wchar_t * filePath )

This routine allows to open and get data from any supported file extension.

Parameters
filePath : Indicates the full path of the considered file.
Returns
Pointer to fileData_C if the file has hex, bin, srec or elf as extension, otherwise a null pointer to indicate that the file type is not supported.

◆ freeFileData()

void freeFileData ( fileData_C * data )

This routine allows to clean up the handled file data.

Parameters
data

◆ getCancelPointer()

volatile int* getCancelPointer ( )

This routine allows to drop the current read/write operation.

Returns
0 if there is no call for stop operation, otherwise 1.

◆ getDeviceGeneralInf()

generalInf* getDeviceGeneralInf ( )

This routine allows to get general device informations.

Returns
Structure GeneralInf in which the informations are stored.
Examples:
CAN_Bootloader, I2C_Bootloader, SPI_Bootloader, STLINK_Example1, STLINK_Example2, STLINK_Example3, UART_Bootloader, and USB_Bootloader.

◆ getTargetInterfaceType()

int getTargetInterfaceType ( )

This routine allows to know the interface what is in use.

Returns
The target interface type targetInterfaceType, otherwise -1.

◆ massErase()

int massErase ( )

This routine allows to erase the whole Flash memory.

Returns
0 if the operation finished successfully, otherwise an error was occurred.
Note
Depending on the device, this routine can take a particular period of time.
Examples:
STLINK_Example1.

◆ readMemory()

int readMemory | ( | unsigned int | address,
 |  | unsigned char ** | data,
 |  | unsigned int | size
 | ) |  |

This routine allows to receive memory data on the used interface with the configration already initialized.

Parameters
address | : The address to start reading from.
data | : Pointer to the data buffer.
size | : It indicates the size for read data.
Returns
0 if the reading operation correctly finished, otherwise an error occurred.
Warning
Unlike ST-LINK interface, the Bootloader interface can access only to some specific memory regions.
Examples:
CAN_Bootloader, I2C_Bootloader, SPI_Bootloader, STLINK_Example1, STLINK_Example2, UART_Bootloader, and USB_Bootloader.

◆ readUnprotect()

int readUnprotect ( )

This routine allows to disable the readout protection. If the memory is not protected, a message appears to indicate that the device is not under Readout protection and the command has no effects.

Returns
0 if the disabling correctly accomplished, otherwise an error occurred.
Note
Depending on the device used, this routine take a specific time.
Examples:
STLINK_Example3.

◆ saveFileToFile()

int saveFileToFile | ( | fileData_C * | fileData,
 |  | const wchar_t * | sFileName
 | ) |  |

This routine allows to save the data file content to another file.

Parameters
fileData | : Input file name.
sFileName | : Output file name.
Returns
0 if the output file was created successfully, otherwise an error occurred.

◆ saveMemoryToFile()

int saveMemoryToFile | ( | int | address,
 |  | int | size,
 |  | const wchar_t * | sFileName
 | ) |  |

This routine allows to save Flash memory content to file.

Parameters
address | : The address to start saving from.
size | : Data size to be saved.
sFileName | : Indicates the file name.
Returns
0 if the data copy was acheived successfully, otherwise an error occurred.
Note
The file name must finish with an extension ".hex", ".bin" or ".srec"

◆ sectorErase()

int sectorErase | ( | unsigned int | sectors[],
 |  | unsigned int | sectorNbr
 | ) |  |

This routine allows to erase specific sectors of the Flash memory.

Parameters
sectors | : Indicates the indexs of the specific sectors to be erased.
sectorNbr | : The number of chosen sectors.
Returns
0 if the operation finished successfully, otherwise an error occurred.
Note
Each circuit has a specific number of Flash memory sectors.
Examples:
STLINK_Example1.

◆ setDisplayCallbacks()

void setDisplayCallbacks ( displayCallBacks c )

This routine allows to choose your custom display.

Parameters
c : Fill the struct to customize the display tool.
Note
This function must be called first of all to ensure the display management.
Examples:
main.

◆ setVerbosityLevel()

void setVerbosityLevel ( int level )

This routine allows to choose the verbosity level for display.

Parameters
level : Indicates the verbosity number 0, 1 or 3.
Examples:
main.

◆ verify()

int verify | ( | fileData_C * | fileData,
 |  | unsigned int | address
 | ) |  |

This routine allows to verfiy if the indicated file data is identical to Flash memory content.

Parameters
fileData | : Input file name.
address | : The address to start verifying from, it's considered only if the file has .bin or .binary as extension.
Returns
0 if the file data matching Flash memory content, otherwise an error occurred or the data is mismatched.

◆ writeMemory()

int writeMemory | ( | unsigned int | address,
 |  | char * | data,
 |  | unsigned int | size
 | ) |  |

This routine allows to write memory data on the user interface with the configration already initialized.

Parameters
address | : The address to start writing from.
data | : Pointer to the data buffer.
size | : It indicates the size for write data.
Returns
0 if the writing operation correctly finished, otherwise an error occurred.
Warning
Unlike ST-LINK interface, the Bootloader interface can access only to some specific memory regions.
Examples:
STLINK_Example1.


STM32CubeProgrammer API: OB

Functions
OB

Functions

int sendOptionBytesCmd (char *command)
This routine allows program the given Option Byte. The option bytes are configured by the end user depending on the application requirements. More...
peripheral_C * initOptionBytesInterface ()
This routine allows to get option bytes values of the connected target. More...

Detailed Description

OB module groups option bytes functions used by any interface.

Function Documentation

◆ initOptionBytesInterface()

peripheral_C* initOptionBytesInterface ( )

This routine allows to get option bytes values of the connected target.

Returns
Structure #Peripheral_C in which the option bytes descriptions are stored.
Examples:
CAN_Bootloader, I2C_Bootloader, SPI_Bootloader, STLINK_Example3, UART_Bootloader, and USB_Bootloader.

◆ sendOptionBytesCmd()

int sendOptionBytesCmd ( char * command )

This routine allows program the given Option Byte. The option bytes are configured by the end user depending on the application requirements.

Parameters
command : Indicates the command to execute.
Returns
0 if the programming Option Byte correctly executed, otherwise an error occurred.
Note
The command must written as: -ob [optionbyte=value] [optionbyte=value] ...
int ob = sendOptionBytesCmd("–ob rdp=0x0 BOR_LEV=0");
Examples:
CAN_Bootloader, I2C_Bootloader, SPI_Bootloader, STLINK_Example3, UART_Bootloader, and USB_Bootloader.


STM32CubeProgrammer API: Loaders

Functions
Loaders

Functions

void | setLoadersPath (const char *path)
This routine allows to specify the location of Flash Loader. More...
void | setExternalLoaderPath (const char *path, externalLoader **externalLoaderInfo)
This routine allows to specify the path of the external Loaders to be loaded. More...
int | getExternalLoaders (const char *path, externalStorageInfo **externalStorageNfo)
This routine allows to get available external Loaders in th mentioned path. More...
void | removeExternalLoader (const char *path)
This routine allows to unload an external Loaders. More...
void | deleteLoaders ()
This routine allows to delete all target Flash Loaders. More...

Detailed Description

Loaders module groups loaders functions.

Function Documentation

◆ deleteLoaders()

void deleteLoaders ( )

This routine allows to delete all target Flash Loaders.

◆ getExternalLoaders()

int getExternalLoaders | ( | const char * | path,
 |  | externalStorageInfo ** | externalStorageNfo
 | ) |  |

This routine allows to get available external Loaders in th mentioned path.

Parameters
path | : Indicates the full path of the external Loader file ready for loading.
externalStorageNfo | : Structure in which we get storage information.
Returns
1 if the External loaders cannot be loaded from the path, otherwise 0.
Warning
All external Loader files should have the extension "stldr".

◆ removeExternalLoader()

void removeExternalLoader ( const char * path )

This routine allows to unload an external Loaders.

Parameters
path : Indicates the full path of the external Loader file ready for unloading.

◆ setExternalLoaderPath()

void setExternalLoaderPath | ( | const char * | path,
 |  | externalLoader ** | externalLoaderInfo
 | ) |  |

This routine allows to specify the path of the external Loaders to be loaded.

Parameters
path | : Indicates the full path of the folder containing external Loaders.
externalLoaderInfo | : Structure in which the external Loaders informations are stored.

◆ setLoadersPath()

void setLoadersPath ( const char * path )

This routine allows to specify the location of Flash Loader.

Parameters
path : Indicates the full path of the considered folder.
Examples:
main.


STM32CubeProgrammer API: Data Structures

Data Structures
Here are the data structures with brief descriptions:
C bank_C | Get option bytes banks internal descriptions
C bankSector | This stucture indicates the sectors parameters
C bit_C | This stucture will be filled by values which characterize the device's option bytes
C bitCoefficient_C | This stucture indicates the coefficients to access to the adequate option bit
C bitValue_C | This stucture describes the option Bit value
C canConnectParameters | Specify the CAN connect parameters
C category_C | Get option bytes banks categories descriptions
C debugConnectParameters | Get device characterization and specify connection parameters through ST-LINK interface
C deviceBank | This stucture defines the memory sectors for each bank
C deviceSector | Get device sectors basic informations
C dfuDeviceInfo | Get DFU device informations
C displayCallBacks | Functions must be implemented to personalize the display of messages
C externalLoader | Get external Loader parameters to launch the process of programming an external flash memory
C externalStorageInfo | Get external storage informations useful for external Loader
C fileData_C |
C FileData_C | Get file required informations
C frequencies | Get supported frequencies for JTAG and SWD ineterfaces
C generalInf |
C GeneralInf | Get device general informations
C i2cConnectParameters | Specify the I2C connect parameters
C peripheral_C | Get peripheral option bytes general informations
C segmentData_C |
C spiConnectParameters | Specify the SPI connect parameters
C storageStructure | This stucture describes sotrage characterization
C usartConnectParameters | Specify the USART connect parameters


STM32CubeProgrammer API: bank_C Struct Reference

Data Fields
bank_C Struct Reference

Get option bytes banks internal descriptions. More...

#include <DeviceDataStructure.h>

Data Fields

unsigned int | size
unsigned int | address
unsigned char | access
unsigned int | categoriesNbr
category_C ** categories

Detailed Description

Get option bytes banks internal descriptions.

Note
STLINK and Bootloader interfaces have different addresses to access to option bytes registres.

Field Documentation

◆ access

unsigned char access

Bank access Read/Write.

◆ address

unsigned int address

Bank starting address.

◆ categories

category_C** categories

Get bank categories descriptions #Category_C.

Examples:
CAN_Bootloader, I2C_Bootloader, SPI_Bootloader, STLINK_Example3, UART_Bootloader, and USB_Bootloader.

◆ categoriesNbr

unsigned int categoriesNbr

Number of option bytes categories.

Examples:
CAN_Bootloader, I2C_Bootloader, SPI_Bootloader, STLINK_Example3, UART_Bootloader, and USB_Bootloader.

◆ size

unsigned int size

Bank size.

The documentation for this struct was generated from the following file:
  • files/DeviceDataStructure.h


STM32CubeProgrammer API: bankSector Struct Reference

Data Fields
bankSector Struct Reference

This stucture indicates the sectors parameters. More...

#include <DeviceDataStructure.h>

Data Fields

unsigned int | index
unsigned int | size
unsigned int | address

Detailed Description

This stucture indicates the sectors parameters.

Field Documentation

◆ address

unsigned int address

Sector starting address.

◆ index

unsigned int index

Index of the sector.

◆ size

unsigned int size

Sector size.

The documentation for this struct was generated from the following file:
  • files/DeviceDataStructure.h


STM32CubeProgrammer API: bit_C Struct Reference

Data Fields
bit_C Struct Reference

This stucture will be filled by values which characterize the device's option bytes. More...

#include <DeviceDataStructure.h>

Data Fields

char | name [32]
char | description [300]
unsigned int | wordOffset
unsigned int | bitOffset
unsigned int | bitWidth
unsigned char | access
unsigned int | valuesNbr
bitValue_C ** values
bitCoefficient_C equation
unsigned char * | reference
unsigned int | bitValue

Detailed Description

This stucture will be filled by values which characterize the device's option bytes.

Note
See product reference manual for more details.

Field Documentation

◆ access

unsigned char access

Access Read/Write.

Examples:
CAN_Bootloader, I2C_Bootloader, SPI_Bootloader, STLINK_Example3, UART_Bootloader, and USB_Bootloader.

◆ bitOffset

unsigned int bitOffset

Bit offset.

◆ bitValue

unsigned int bitValue
Examples:
CAN_Bootloader, I2C_Bootloader, SPI_Bootloader, STLINK_Example3, UART_Bootloader, and USB_Bootloader.

◆ bitWidth

unsigned int bitWidth

Number of bits build the option.

◆ description

char description[300]

Config description.

◆ equation

bitCoefficient_C equation

Bits equation, #BitCoefficient_C.

◆ name

char name[32]

Bit name such as RDP, BOR_LEV, nBOOT0...

Examples:
CAN_Bootloader, I2C_Bootloader, SPI_Bootloader, STLINK_Example3, UART_Bootloader, and USB_Bootloader.

◆ reference

unsigned char* reference

◆ values

bitValue_C** values

Bits value, #BitValue_C.

◆ valuesNbr

unsigned int valuesNbr

Number of possible values.

◆ wordOffset

unsigned int wordOffset

Word offset.

The documentation for this struct was generated from the following file:
  • files/DeviceDataStructure.h


STM32CubeProgrammer API: bitCoefficient_C Struct Reference

Data Fields
bitCoefficient_C Struct Reference

This stucture indicates the coefficients to access to the adequate option bit. More...

#include <DeviceDataStructure.h>

Data Fields

unsigned int | multiplier
unsigned int | offset

Detailed Description

This stucture indicates the coefficients to access to the adequate option bit.

Field Documentation

◆ multiplier

unsigned int multiplier

Bit multiplier.

◆ offset

unsigned int offset

Bit offset.

The documentation for this struct was generated from the following file:
  • files/DeviceDataStructure.h


STM32CubeProgrammer API: bitValue_C Struct Reference

Data Fields
bitValue_C Struct Reference

This stucture describes the option Bit value. More...

#include <DeviceDataStructure.h>

Data Fields

unsigned int | value
char | description [200]

Detailed Description

This stucture describes the option Bit value.

Field Documentation

◆ description

char description[200]

Option bit description.

◆ value

unsigned int value

Option bit value.

The documentation for this struct was generated from the following file:
  • files/DeviceDataStructure.h


STM32CubeProgrammer API: canConnectParameters Struct Reference

Data Fields
canConnectParameters Struct Reference

Specify the CAN connect parameters. More...

#include <CubeProgrammer_API.h>

Data Fields

int | br
int | mode
int | ide
int | rtr
int | fifo
int | fm
int | fs
int | fe
char | fbn

Detailed Description

Specify the CAN connect parameters.

Note
Not all configurations are supported by STM32 Bootloader, such as CAN type is STANDARD and the filter should be always activated.
Recommended CAN parameters : br=125000, mode=0, ide=0, rtr=0, fifo=0, fm=0, fs=1, fe=1, fbn=0
Examples:
CAN_Bootloader.

Field Documentation

◆ br

int br

Baudrate and speed transmission 125KHz, 250KHz, 500KHz...

Examples:
CAN_Bootloader.

◆ fbn

char fbn

Filter bank number: 0 to 13.

Examples:
CAN_Bootloader.

◆ fe

int fe

Filter activation: DISABLE or ENABLE.

Examples:
CAN_Bootloader.

◆ fifo

int fifo

Memory of received messages: FIFO0 or FIFO1.

Examples:
CAN_Bootloader.

◆ fm

int fm

Filter mode: MASK or LIST.

Examples:
CAN_Bootloader.

◆ fs

int fs

Filter scale: 16 or 32.

Examples:
CAN_Bootloader.

◆ ide

int ide

CAN type: STANDARD or EXTENDED.

Examples:
CAN_Bootloader.

◆ mode

int mode

CAN mode: NORMAL, LOOPBACK...,

Examples:
CAN_Bootloader.

◆ rtr

int rtr

Frame format: DATA or REMOTE.

Examples:
CAN_Bootloader.
The documentation for this struct was generated from the following file:
  • files/CubeProgrammer_API.h


STM32CubeProgrammer API: category_C Struct Reference

Data Fields
category_C Struct Reference

Get option bytes banks categories descriptions. More...

#include <DeviceDataStructure.h>

Data Fields

char | name [100]
unsigned int | bitsNbr
bit_C ** bits

Detailed Description

Get option bytes banks categories descriptions.

Field Documentation

◆ bits

bit_C** bits

Get internal bits descriptions.

Examples:
CAN_Bootloader, I2C_Bootloader, SPI_Bootloader, STLINK_Example3, UART_Bootloader, and USB_Bootloader.

◆ bitsNbr

unsigned int bitsNbr

Get bits number of the considered category.

Examples:
CAN_Bootloader, I2C_Bootloader, SPI_Bootloader, STLINK_Example3, UART_Bootloader, and USB_Bootloader.

◆ name

char name[100]

Get category name such as Read Out Protection, BOR Level...

The documentation for this struct was generated from the following file:
  • files/DeviceDataStructure.h


STM32CubeProgrammer API: debugConnectParameters Struct Reference

Data Fields
debugConnectParameters Struct Reference

Get device characterization and specify connection parameters through ST-LINK interface. More...

#include <CubeProgrammer_API.h>

Data Fields

debugPort dbgPort
int | index
char | serialNumber [33]
char | firmwareVersion [20]
char | targetVoltage [5]
int | accessPortNumber
int | accessPort
debugConnectMode connectionMode
debugResetMode resetMode
int | isOldFirmware
frequencies freq
int | frequency
int | isBridge
int | shared

Detailed Description

Get device characterization and specify connection parameters through ST-LINK interface.

Examples:
STLINK_Example1, STLINK_Example2, and STLINK_Example3.

Field Documentation

◆ accessPort

int accessPort

Select access port controller.

◆ accessPortNumber

int accessPortNumber

Number of available access port.

◆ connectionMode

debugConnectMode connectionMode

Select the debug CONNECT mode debugConnectMode.

Examples:
STLINK_Example1, STLINK_Example2, and STLINK_Example3.

◆ dbgPort

debugPort dbgPort

Select the type of debug interface debugPort.

◆ firmwareVersion

char firmwareVersion[20]

Firmware version.

◆ freq

frequencies freq

Supported frequencies frequencies.

◆ frequency

int frequency

Select specific frequency.

◆ index

int index

Select one of the debug ports connected.

◆ isBridge

int isBridge

Indicates if it's Bridge device or not.

◆ isOldFirmware

int isOldFirmware

Check Old ST-LINK firmware version.

◆ resetMode

debugResetMode resetMode

Select the debug RESET mode debugResetMode.

◆ serialNumber

char serialNumber[33]

ST-LINK serial number.

◆ shared

int shared

Select connection type, if it's shared, use ST-LINK Server.

Examples:
STLINK_Example1, STLINK_Example2, and STLINK_Example3.

◆ targetVoltage

char targetVoltage[5]

Operate voltage.

The documentation for this struct was generated from the following file:
  • files/CubeProgrammer_API.h


STM32CubeProgrammer API: deviceBank Struct Reference

Data Fields
deviceBank Struct Reference

This stucture defines the memory sectors for each bank. More...

#include <DeviceDataStructure.h>

Data Fields

unsigned int sectorsNumber
bankSector * sectors

Detailed Description

This stucture defines the memory sectors for each bank.

Field Documentation

◆ sectors

bankSector* sectors

Sectors specifications #Bank_Sector.

◆ sectorsNumber

unsigned int sectorsNumber

Number of sectors of the considered bank.

The documentation for this struct was generated from the following file:
  • files/DeviceDataStructure.h


STM32CubeProgrammer API: deviceSector Struct Reference

Data Fields
deviceSector Struct Reference

Get device sectors basic informations. More...

#include <CubeProgrammer_API.h>

Data Fields

uint32_t | sectorNum
uint32_t | sectorSize

Detailed Description

Get device sectors basic informations.

Field Documentation

◆ sectorNum

uint32_t sectorNum

Number of Sectors.

◆ sectorSize

uint32_t sectorSize

Sector Size in BYTEs.

The documentation for this struct was generated from the following file:
  • files/CubeProgrammer_API.h


STM32CubeProgrammer API: dfuDeviceInfo Struct Reference

Data Fields
dfuDeviceInfo Struct Reference

Get DFU device informations . More...

#include <CubeProgrammer_API.h>

Data Fields

char | usbIndex [10]
int | busNumber
int | addressNumber
char | productId [100]
char | serialNumber [100]
unsigned int | dfuVersion

Detailed Description

Get DFU device informations .

Examples:
USB_Bootloader.

Field Documentation

◆ addressNumber

int addressNumber

Address number.

◆ busNumber

int busNumber

Bus number.

◆ dfuVersion

unsigned int dfuVersion

DFU version.

◆ productId

char productId[100]

Product number.

◆ serialNumber

char serialNumber[100]

Serial number.

◆ usbIndex

char usbIndex[10]

USB index.

The documentation for this struct was generated from the following file:
  • files/CubeProgrammer_API.h


STM32CubeProgrammer API: displayCallBacks Struct Reference

Data Fields
displayCallBacks Struct Reference

Functions must be implemented to personalize the display of messages. More...

#include <CubeProgrammer_API.h>

Data Fields

void(* | initProgressBar )()
void(* | logMessage )(int msgType, const wchar_t *str)
void(* | loadBar )(int x, int n)

Detailed Description

Functions must be implemented to personalize the display of messages.

Examples:
main.

Field Documentation

◆ initProgressBar

void(* initProgressBar) ()

Add a progress bar.

Examples:
main.

◆ loadBar

void(* loadBar) (int x, int n)

Display the loading of read/write process.

Examples:
main.

◆ logMessage

void(* logMessage) (int msgType, const wchar_t *str)

Display internal messages according to verbosity level.

Examples:
main.
The documentation for this struct was generated from the following file:
  • files/CubeProgrammer_API.h


STM32CubeProgrammer API: externalLoader Struct Reference

Data Fields
externalLoader Struct Reference

Get external Loader parameters to launch the process of programming an external flash memory. More...

#include <CubeProgrammer_API.h>

Data Fields

char | filePath [200]
char | deviceName [100]
int | deviceType
uint32_t | deviceStartAddress
uint32_t | deviceSize
uint32_t | pageSize
uint32_t | sectorsTypeNbr
deviceSector * sectors

Detailed Description

Get external Loader parameters to launch the process of programming an external flash memory.

Field Documentation

◆ deviceName

char deviceName[100]

Device Name and Description.

◆ deviceSize

uint32_t deviceSize

Total Size of Device.

◆ deviceStartAddress

uint32_t deviceStartAddress

Default Device Start Address.

◆ deviceType

int deviceType

Device Type: ONCHIP, EXT8BIT, EXT16BIT, ...

◆ filePath

char filePath[200]

FlashLoader file path.

◆ pageSize

uint32_t pageSize

Programming Page Size.

◆ sectors

deviceSector* sectors

Device sectors.

◆ sectorsTypeNbr

uint32_t sectorsTypeNbr

Type number.

The documentation for this struct was generated from the following file:
  • files/CubeProgrammer_API.h


STM32CubeProgrammer API: externalStorageInfo Struct Reference

Data Fields
externalStorageInfo Struct Reference

Get external storage informations useful for external Loader. More...

#include <CubeProgrammer_API.h>

Data Fields

unsigned int externalLoaderNbr
externalLoader * externalLoader

Detailed Description

Get external storage informations useful for external Loader.

Field Documentation

◆ externalLoader

externalLoader* externalLoader

◆ externalLoaderNbr

unsigned int externalLoaderNbr
The documentation for this struct was generated from the following file:
  • files/CubeProgrammer_API.h


STM32CubeProgrammer API: fileData_C Struct Reference

Data Fields
fileData_C Struct Reference

#include <CubeProgrammer_API.h>

Data Fields

int | Type
int | segmentsNbr
segmentData_C * segments

Field Documentation

◆ segments

segmentData_C* segments

Segments description.

◆ segmentsNbr

int segmentsNbr

Number of required segments.

◆ Type

int Type

File extension type.

The documentation for this struct was generated from the following file:
  • files/CubeProgrammer_API.h


STM32CubeProgrammer API: FileData_C Struct Reference

FileData_C Struct Reference

Get file required informations. More...

#include <CubeProgrammer_API.h>

Detailed Description

Get file required informations.

The documentation for this struct was generated from the following file:
  • files/CubeProgrammer_API.h


STM32CubeProgrammer API: frequencies Struct Reference

Data Fields
frequencies Struct Reference

Get supported frequencies for JTAG and SWD ineterfaces. More...

#include <CubeProgrammer_API.h>

Data Fields

unsigned int | jtagFreq [12]
unsigned int | jtagFreqNumber
unsigned int | swdFreq [12]
unsigned int | swdFreqNumber

Detailed Description

Get supported frequencies for JTAG and SWD ineterfaces.

Field Documentation

◆ jtagFreq

unsigned int jtagFreq[12]

JTAG frequency.

◆ jtagFreqNumber

unsigned int jtagFreqNumber

Get JTAG supported frequencies.

◆ swdFreq

unsigned int swdFreq[12]

SWD frequency.

◆ swdFreqNumber

unsigned int swdFreqNumber

Get SWD supported frequencies.

The documentation for this struct was generated from the following file:
  • files/CubeProgrammer_API.h


STM32CubeProgrammer API: generalInf Struct Reference

Data Fields
generalInf Struct Reference

#include <CubeProgrammer_API.h>

Data Fields

unsigned short | deviceId
int | flashSize
char | type [4]
char | cpu [20]
char | name [100]
char | series [100]
char | description [100]

Detailed Description

Examples:
CAN_Bootloader, I2C_Bootloader, SPI_Bootloader, STLINK_Example1, STLINK_Example2, STLINK_Example3, UART_Bootloader, and USB_Bootloader.

Field Documentation

◆ cpu

char cpu[20]

Cortex CPU.

Examples:
CAN_Bootloader, I2C_Bootloader, SPI_Bootloader, STLINK_Example1, STLINK_Example2, STLINK_Example3, UART_Bootloader, and USB_Bootloader.

◆ description

char description[100]

Take notice.

◆ deviceId

unsigned short deviceId

Device ID.

◆ flashSize

int flashSize

Flash memory size.

◆ name

char name[100]

Device name.

Examples:
CAN_Bootloader, I2C_Bootloader, SPI_Bootloader, STLINK_Example1, STLINK_Example2, STLINK_Example3, UART_Bootloader, and USB_Bootloader.

◆ series

char series[100]

Device serie.

◆ type

char type[4]

Device MCU or MPU.

Examples:
CAN_Bootloader, I2C_Bootloader, SPI_Bootloader, STLINK_Example1, STLINK_Example2, STLINK_Example3, UART_Bootloader, and USB_Bootloader.
The documentation for this struct was generated from the following file:
  • files/CubeProgrammer_API.h


STM32CubeProgrammer API: GeneralInf Struct Reference

GeneralInf Struct Reference

Get device general informations. More...

#include <CubeProgrammer_API.h>

Detailed Description

Get device general informations.

The documentation for this struct was generated from the following file:
  • files/CubeProgrammer_API.h


STM32CubeProgrammer API: i2cConnectParameters Struct Reference

Data Fields
i2cConnectParameters Struct Reference

Specify the I2C connect parameters. More...

#include <CubeProgrammer_API.h>

Data Fields

int | add
int | br
int | sm
int | am
int | af
int | df
char | dnf
int | rt
int | ft

Detailed Description

Specify the I2C connect parameters.

Warning
The Bootloader Slave address varies depending on the device (see AN2606).
Note
Not all configurations are supported by STM32 Bootloader, such as address in 7 bits form, analog filter: ENABLE, digital filter: DISABLE.
Recommended I2C parameters : add=0x??, br=400, sm=1, am=0, af=1, df=0, dnf=0, rt=0, ft=0
Examples:
I2C_Bootloader.

Field Documentation

◆ add

int add

Device address in hex format.

Examples:
I2C_Bootloader.

◆ af

int af

Analog filter: DISABLE or ENABLE.

Examples:
I2C_Bootloader.

◆ am

int am

Address Mode: 7 or 10 bits.

Examples:
I2C_Bootloader.

◆ br

int br

Baudrate and speed transmission : 100 or 400 KHz.

Examples:
I2C_Bootloader.

◆ df

int df

Digital filter: DISABLE or ENABLE.

Examples:
I2C_Bootloader.

◆ dnf

char dnf

Digital noise filter: 0 to 15.

Examples:
I2C_Bootloader.

◆ ft

int ft

Fall time: 0-300 for STANDARD speed mode and 0-300 for FAST.

Examples:
I2C_Bootloader.

◆ rt

int rt

Rise time: 0-1000 for STANDARD speed mode and 0-300 for FAST.

Examples:
I2C_Bootloader.

◆ sm

int sm

Speed Mode: STANDARD or FAST.

Examples:
I2C_Bootloader.
The documentation for this struct was generated from the following file:
  • files/CubeProgrammer_API.h


STM32CubeProgrammer API: peripheral_C Struct Reference

Data Fields
peripheral_C Struct Reference

Get peripheral option bytes general informations. More...

#include <DeviceDataStructure.h>

Data Fields

char | name [32]
char | description [200]
unsigned int | banksNbr
bank_C ** banks

Detailed Description

Get peripheral option bytes general informations.

Examples:
CAN_Bootloader, I2C_Bootloader, SPI_Bootloader, STLINK_Example3, UART_Bootloader, and USB_Bootloader.

Field Documentation

◆ banks

bank_C** banks

Get banks descriptions #Bank_C.

Examples:
CAN_Bootloader, I2C_Bootloader, SPI_Bootloader, STLINK_Example3, UART_Bootloader, and USB_Bootloader.

◆ banksNbr

unsigned int banksNbr

Number of existed banks.

Examples:
CAN_Bootloader, I2C_Bootloader, SPI_Bootloader, STLINK_Example3, UART_Bootloader, and USB_Bootloader.

◆ description

char description[200]

Peripheral description.

◆ name

char name[32]

Peripheral name.

The documentation for this struct was generated from the following file:
  • files/DeviceDataStructure.h


STM32CubeProgrammer API: segmentData_C Struct Reference

Data Fields
segmentData_C Struct Reference

#include <CubeProgrammer_API.h>

Data Fields

int | address
int | size
unsigned char * | data

Field Documentation

◆ address

int address

Segment start address.

◆ data

unsigned char* data

Memory segment data.

◆ size

int size

Memory segment size.

The documentation for this struct was generated from the following file:
  • files/CubeProgrammer_API.h


STM32CubeProgrammer API: spiConnectParameters Struct Reference

Data Fields
spiConnectParameters Struct Reference

Specify the SPI connect parameters. More...

#include <CubeProgrammer_API.h>

Data Fields

uint32_t | baudrate
uint16_t | crcPol
int | direction
int | cpha
int | cpol
int | crc
int | firstBit
int | frameFormat
int | dataSize
int | mode
int | nss
int | nssPulse
int | delay

Detailed Description

Specify the SPI connect parameters.

Note
Recommended SPI parameters : baudrate=375, crcPol=7, direction=0, cpha=0, cpol=0, crc=0, firstBit=1, frameFormat=0, dataSize=1, mode=1, nss=1, nssPulse=1, delay=1
Examples:
SPI_Bootloader.

Field Documentation

◆ baudrate

uint32_t baudrate

Speed transmission 187, 375, 750, 1500, 3000, 6000, 12000 KHz.

Examples:
SPI_Bootloader.

◆ cpha

int cpha

1Edge or 2Edge.

Examples:
SPI_Bootloader.

◆ cpol

int cpol

LOW or HIGH.

Examples:
SPI_Bootloader.

◆ crc

int crc

DISABLE or ENABLE.

Examples:
SPI_Bootloader.

◆ crcPol

uint16_t crcPol

crc polynom value.

Examples:
SPI_Bootloader.

◆ dataSize

int dataSize

Size of frame data: 16bit or 8bit .

Examples:
SPI_Bootloader.

◆ delay

int delay

Delay of few microseconds, No Delay or Delay, at least 4us delay is inserted

Examples:
SPI_Bootloader.

◆ direction

int direction

2LFullDuplex/2LRxOnly/1LRx/1LTx.

Examples:
SPI_Bootloader.

◆ firstBit

int firstBit

First bit: LSB or MSB.

Examples:
SPI_Bootloader.

◆ frameFormat

int frameFormat

Frame format: Motorola or TI.

Examples:
SPI_Bootloader.

◆ mode

int mode

Operating mode: Slave or Master.

Examples:
SPI_Bootloader.

◆ nss

int nss

Selection: Soft or Hard.

Examples:
SPI_Bootloader.

◆ nssPulse

int nssPulse

NSS pulse: No Pulse or Pulse.

Examples:
SPI_Bootloader.
The documentation for this struct was generated from the following file:
  • files/CubeProgrammer_API.h


STM32CubeProgrammer API: storageStructure Struct Reference

Data Fields
storageStructure Struct Reference

This stucture describes sotrage characterization. More...

#include <DeviceDataStructure.h>

Data Fields

unsigned int banksNumber
deviceBank * banks

Detailed Description

This stucture describes sotrage characterization.

Field Documentation

◆ banks

deviceBank* banks

Banks sectors definition #Device_Bank.

◆ banksNumber

unsigned int banksNumber

Number of exsisted banks.

The documentation for this struct was generated from the following file:
  • files/DeviceDataStructure.h


STM32CubeProgrammer API: usartConnectParameters Struct Reference

Data Fields
usartConnectParameters Struct Reference

Specify the USART connect parameters. More...

#include <CubeProgrammer_API.h>

Data Fields

char | portName [100]
unsigned int | baudrate
usartParity parity
unsigned char | dataBits
float | stopBits
usartFlowControl flowControl
unsigned char | noinitBits

Detailed Description

Specify the USART connect parameters.

Examples:
UART_Bootloader.

Field Documentation

◆ baudrate

unsigned int baudrate

Speed transmission: 115200, 9600...

◆ dataBits

unsigned char dataBits

Data bit: value in {6, 7, 8}.

◆ flowControl

usartFlowControl flowControl

Flow control: value in usartFlowControl.

◆ noinitBits

unsigned char noinitBits

Set No Init bits: value in {0,1}.

◆ parity

usartParity parity

Parity bit: value in usartParity.

◆ portName

char portName[100]

Interface identifier: COM1, COM2, /dev/ttyS0...

◆ stopBits

float stopBits

Stop bit: value in {1, 1.5, 2}.

The documentation for this struct was generated from the following file:
  • files/CubeProgrammer_API.h


STM32CubeProgrammer API: Data Structure Index

Data Structure Index
b | c | d | e | f | g | i | p | s | u
b
category_C externalStorageInfo GeneralInf spiConnectParameters
d
f
i
storageStructure
bank_C
u
bankSector debugConnectParameters fileData_C i2cConnectParameters
bit_C deviceBank FileData_C
p
usartConnectParameters
bitCoefficient_C deviceSector frequencies
bitValue_C dfuDeviceInfo
g
peripheral_C
c
displayCallBacks
s
e
generalInf
canConnectParameters segmentData_C
externalLoader
b | c | d | e | f | g | i | p | s | u


STM32CubeProgrammer API: Data Fields

Here is a list of all struct and union fields with links to the structures/unions they belong to:

- a -

  • access : bank_C , bit_C
  • accessPort : debugConnectParameters
  • accessPortNumber : debugConnectParameters
  • add : i2cConnectParameters
  • address : bank_C , bankSector , segmentData_C
  • addressNumber : dfuDeviceInfo
  • af : i2cConnectParameters
  • am : i2cConnectParameters

- b -

  • banks : peripheral_C , storageStructure
  • banksNbr : peripheral_C
  • banksNumber : storageStructure
  • baudrate : spiConnectParameters , usartConnectParameters
  • bitOffset : bit_C
  • bits : category_C
  • bitsNbr : category_C
  • bitValue : bit_C
  • bitWidth : bit_C
  • br : canConnectParameters , i2cConnectParameters
  • busNumber : dfuDeviceInfo

- c -

  • categories : bank_C
  • categoriesNbr : bank_C
  • connectionMode : debugConnectParameters
  • cpha : spiConnectParameters
  • cpol : spiConnectParameters
  • cpu : generalInf
  • crc : spiConnectParameters
  • crcPol : spiConnectParameters

- d -

  • data : segmentData_C
  • dataBits : usartConnectParameters
  • dataSize : spiConnectParameters
  • dbgPort : debugConnectParameters
  • delay : spiConnectParameters
  • description : bit_C , bitValue_C , generalInf , peripheral_C
  • deviceId : generalInf
  • deviceName : externalLoader
  • deviceSize : externalLoader
  • deviceStartAddress : externalLoader
  • deviceType : externalLoader
  • df : i2cConnectParameters
  • dfuVersion : dfuDeviceInfo
  • direction : spiConnectParameters
  • dnf : i2cConnectParameters

- e -

  • equation : bit_C
  • externalLoader : externalStorageInfo
  • externalLoaderNbr : externalStorageInfo

- f -

  • fbn : canConnectParameters
  • fe : canConnectParameters
  • fifo : canConnectParameters
  • filePath : externalLoader
  • firmwareVersion : debugConnectParameters
  • firstBit : spiConnectParameters
  • flashSize : generalInf
  • flowControl : usartConnectParameters
  • fm : canConnectParameters
  • frameFormat : spiConnectParameters
  • freq : debugConnectParameters
  • frequency : debugConnectParameters
  • fs : canConnectParameters
  • ft : i2cConnectParameters

- i -

  • ide : canConnectParameters
  • index : bankSector , debugConnectParameters
  • initProgressBar : displayCallBacks
  • isBridge : debugConnectParameters
  • isOldFirmware : debugConnectParameters

- j -

  • jtagFreq : frequencies
  • jtagFreqNumber : frequencies

- l -

  • loadBar : displayCallBacks
  • logMessage : displayCallBacks

- m -

  • mode : canConnectParameters , spiConnectParameters
  • multiplier : bitCoefficient_C

- n -

  • name : bit_C , category_C , generalInf , peripheral_C
  • noinitBits : usartConnectParameters
  • nss : spiConnectParameters
  • nssPulse : spiConnectParameters

- o -

  • offset : bitCoefficient_C

- p -

  • pageSize : externalLoader
  • parity : usartConnectParameters
  • portName : usartConnectParameters
  • productId : dfuDeviceInfo

- r -

  • reference : bit_C
  • resetMode : debugConnectParameters
  • rt : i2cConnectParameters
  • rtr : canConnectParameters

- s -

  • sectorNum : deviceSector
  • sectors : deviceBank , externalLoader
  • sectorSize : deviceSector
  • sectorsNumber : deviceBank
  • sectorsTypeNbr : externalLoader
  • segments : fileData_C
  • segmentsNbr : fileData_C
  • serialNumber : debugConnectParameters , dfuDeviceInfo
  • series : generalInf
  • shared : debugConnectParameters
  • size : bank_C , bankSector , segmentData_C
  • sm : i2cConnectParameters
  • stopBits : usartConnectParameters
  • swdFreq : frequencies
  • swdFreqNumber : frequencies

- t -

  • targetVoltage : debugConnectParameters
  • Type : fileData_C
  • type : generalInf

- u -

  • usbIndex : dfuDeviceInfo

- v -

  • value : bitValue_C
  • values : bit_C
  • valuesNbr : bit_C

- w -

  • wordOffset : bit_C


STM32CubeProgrammer API: Data Fields - Variables

- a -

  • access : bank_C , bit_C
  • accessPort : debugConnectParameters
  • accessPortNumber : debugConnectParameters
  • add : i2cConnectParameters
  • address : bank_C , bankSector , segmentData_C
  • addressNumber : dfuDeviceInfo
  • af : i2cConnectParameters
  • am : i2cConnectParameters

- b -

  • banks : peripheral_C , storageStructure
  • banksNbr : peripheral_C
  • banksNumber : storageStructure
  • baudrate : spiConnectParameters , usartConnectParameters
  • bitOffset : bit_C
  • bits : category_C
  • bitsNbr : category_C
  • bitValue : bit_C
  • bitWidth : bit_C
  • br : canConnectParameters , i2cConnectParameters
  • busNumber : dfuDeviceInfo

- c -

  • categories : bank_C
  • categoriesNbr : bank_C
  • connectionMode : debugConnectParameters
  • cpha : spiConnectParameters
  • cpol : spiConnectParameters
  • cpu : generalInf
  • crc : spiConnectParameters
  • crcPol : spiConnectParameters

- d -

  • data : segmentData_C
  • dataBits : usartConnectParameters
  • dataSize : spiConnectParameters
  • dbgPort : debugConnectParameters
  • delay : spiConnectParameters
  • description : bit_C , bitValue_C , generalInf , peripheral_C
  • deviceId : generalInf
  • deviceName : externalLoader
  • deviceSize : externalLoader
  • deviceStartAddress : externalLoader
  • deviceType : externalLoader
  • df : i2cConnectParameters
  • dfuVersion : dfuDeviceInfo
  • direction : spiConnectParameters
  • dnf : i2cConnectParameters

- e -

  • equation : bit_C
  • externalLoader : externalStorageInfo
  • externalLoaderNbr : externalStorageInfo

- f -

  • fbn : canConnectParameters
  • fe : canConnectParameters
  • fifo : canConnectParameters
  • filePath : externalLoader
  • firmwareVersion : debugConnectParameters
  • firstBit : spiConnectParameters
  • flashSize : generalInf
  • flowControl : usartConnectParameters
  • fm : canConnectParameters
  • frameFormat : spiConnectParameters
  • freq : debugConnectParameters
  • frequency : debugConnectParameters
  • fs : canConnectParameters
  • ft : i2cConnectParameters

- i -

  • ide : canConnectParameters
  • index : bankSector , debugConnectParameters
  • initProgressBar : displayCallBacks
  • isBridge : debugConnectParameters
  • isOldFirmware : debugConnectParameters

- j -

  • jtagFreq : frequencies
  • jtagFreqNumber : frequencies

- l -

  • loadBar : displayCallBacks
  • logMessage : displayCallBacks

- m -

  • mode : canConnectParameters , spiConnectParameters
  • multiplier : bitCoefficient_C

- n -

  • name : bit_C , category_C , generalInf , peripheral_C
  • noinitBits : usartConnectParameters
  • nss : spiConnectParameters
  • nssPulse : spiConnectParameters

- o -

  • offset : bitCoefficient_C

- p -

  • pageSize : externalLoader
  • parity : usartConnectParameters
  • portName : usartConnectParameters
  • productId : dfuDeviceInfo

- r -

  • reference : bit_C
  • resetMode : debugConnectParameters
  • rt : i2cConnectParameters
  • rtr : canConnectParameters

- s -

  • sectorNum : deviceSector
  • sectors : deviceBank , externalLoader
  • sectorSize : deviceSector
  • sectorsNumber : deviceBank
  • sectorsTypeNbr : externalLoader
  • segments : fileData_C
  • segmentsNbr : fileData_C
  • serialNumber : debugConnectParameters , dfuDeviceInfo
  • series : generalInf
  • shared : debugConnectParameters
  • size : bank_C , bankSector , segmentData_C
  • sm : i2cConnectParameters
  • stopBits : usartConnectParameters
  • swdFreq : frequencies
  • swdFreqNumber : frequencies

- t -

  • targetVoltage : debugConnectParameters
  • Type : fileData_C
  • type : generalInf

- u -

  • usbIndex : dfuDeviceInfo

- v -

  • value : bitValue_C
  • values : bit_C
  • valuesNbr : bit_C

- w -

  • wordOffset : bit_C


STM32CubeProgrammer API: File List

File List
Here is a list of all files with brief descriptions:
[detail level 12]
▼ files
CAN_Example.cpp
CubeProgrammer_API.h
DeviceDataStructure.h
DisplayManager.cpp
Example1.cpp
Example2.cpp
Example3.cpp
I2C_Example.cpp
main.cpp
SPI_Example.cpp
UART_Example.cpp
USB_Example.cpp


STM32CubeProgrammer API: files Directory Reference

  • files
files Directory Reference

Files

file | CAN_Example.cpp
file | CubeProgrammer_API.h [code]
file | DeviceDataStructure.h [code]
file | DisplayManager.cpp
file | Example1.cpp
file | Example2.cpp
file | Example3.cpp
file | I2C_Example.cpp
file | main.cpp
file | SPI_Example.cpp
file | UART_Example.cpp
file | USB_Example.cpp


STM32CubeProgrammer API: files/CAN_Example.cpp File Reference

  • files
CAN_Example.cpp File Reference

Detailed Description

This example allows to connect to the target through CAN Bootloader interface and execute some operations to the internal STM32 Flash memory.

  • Connect to the device via CAN interface.
  • File programming + verification step.
  • Read 64 bytes from 0x08000000.
  • Option bytes programming : BOR level.
  • Display option bytes.

Go to the source code : CAN_Bootloader


STM32CubeProgrammer API: files/CubeProgrammer_API.h File Reference

  • files
Data Structures | Macros | Typedefs | Enumerations | Functions
CubeProgrammer_API.h File Reference
#include <stdint.h>
#include "DeviceDataStructure.h"

Go to the source code of this file.

Data Structures

struct | dfuDeviceInfo
Get DFU device informations . More...
struct | usartConnectParameters
Specify the USART connect parameters. More...
struct | spiConnectParameters
Specify the SPI connect parameters. More...
struct | canConnectParameters
Specify the CAN connect parameters. More...
struct | i2cConnectParameters
Specify the I2C connect parameters. More...
struct | frequencies
Get supported frequencies for JTAG and SWD ineterfaces. More...
struct | debugConnectParameters
Get device characterization and specify connection parameters through ST-LINK interface. More...
struct | displayCallBacks
Functions must be implemented to personalize the display of messages. More...
struct | segmentData_C
struct | fileData_C
struct | generalInf
struct | deviceSector
Get device sectors basic informations. More...
struct | externalLoader
Get external Loader parameters to launch the process of programming an external flash memory. More...
struct | externalStorageInfo
Get external storage informations useful for external Loader. More...

Macros

#define CP_EXPORTS

Typedefs

typedef enum usartParity | usartParity
typedef enum usartFlowControl | usartFlowControl
typedef struct dfuDeviceInfo | dfuDeviceInfo
typedef struct usartConnectParameters | usartConnectParameters
typedef struct spiConnectParameters | spiConnectParameters
typedef struct canConnectParameters | canConnectParameters
typedef struct i2cConnectParameters | i2cConnectParameters
typedef enum debugResetMode | debugResetMode
typedef enum debugConnectMode | debugConnectMode
typedef enum debugPort | debugPort
typedef struct frequencies | frequencies
typedef struct debugConnectParameters | debugConnectParameters
typedef enum targetInterfaceType | targetInterfaceType
typedef struct displayCallBacks | displayCallBacks
typedef struct segmentData_C | segmentData_C
typedef struct fileData_C | fileData_C
typedef struct generalInf | generalInf
typedef struct deviceSector | deviceSector
typedef struct externalLoader | externalLoader
typedef struct externalStorageInfo | externalStorageInfo

Enumerations

enum cubeProgrammerVerbosityLevel {
CUBEPROGRAMMER_VER_LEVEL_NONE = 0, CUBEPROGRAMMER_VER_LEVEL_ONE = 1, CUBEPROGRAMMER_VER_LEVEL_TWO = 2, CUBEPROGRAMMER_VER_LEVEL_DEBUG = 3,
CUBEPROGRAMMER_NO_PROGRESS_BAR = 4
}
List of verbosity levels. More...
enum cubeProgrammerError {
CUBEPROGRAMMER_NO_ERROR = 0, CUBEPROGRAMMER_ERROR_NOT_CONNECTED = -1, CUBEPROGRAMMER_ERROR_NO_DEVICE = -2, CUBEPROGRAMMER_ERROR_CONNECTION = -3,
CUBEPROGRAMMER_ERROR_NO_FILE = -4, CUBEPROGRAMMER_ERROR_NOT_SUPPORTED = -5, CUBEPROGRAMMER_ERROR_INTERFACE_NOT_SUPPORTED = -6, CUBEPROGRAMMER_ERROR_NO_MEM = -7,
CUBEPROGRAMMER_ERROR_WRONG_PARAM = -8, CUBEPROGRAMMER_ERROR_READ_MEM = -9, CUBEPROGRAMMER_ERROR_WRITE_MEM = -10, CUBEPROGRAMMER_ERROR_ERASE_MEM = -11,
CUBEPROGRAMMER_ERROR_UNSUPPORTED_FILE_FORMAT = -12, CUBEPROGRAMMER_ERROR_REFRESH_REQUIRED = -13, CUBEPROGRAMMER_ERROR_NO_SECURITY = -14, CUBEPROGRAMMER_ERROR_CHANGE_FREQ = -15,
CUBEPROGRAMMER_ERROR_OTHER = -99
}
List of errors that can be occured. More...
enum | usartParity { EVEN = 0, ODD = 1, NONE = 2 }
The parity bit in the data frame of the USART communication tells the receiving device if there is any error in the data bits. More...
enum | usartFlowControl { OFF = 0, HARDWARE = 1, SOFTWARE = 2 }
UART Flow Control is a method for devices to communicate with each other over UART without the risk of losing data. More...
enum | debugResetMode { SOFTWARE_RESET, HARDWARE_RESET, CORE_RESET }
Choose the way to apply a system reset. More...
enum | debugConnectMode { NORMAL_MODE, HOTPLUG_MODE, UNDER_RESET_MODE, PRE_RESET_MODE }
Choose the appropriate mode for connection. More...
enum | debugPort { JTAG = 0, SWD = 1 }
Select the debug port interface for connection. More...
enum targetInterfaceType {
STLINK_INTERFACE = 0, USART_INTERFACE = 1, USB_INTERFACE = 2, SPI_INTERFACE = 3,
I2C_INTERFACE = 4, CAN_INTERFACE = 5
}
Indicates the supported interfaces. More...

Functions

int | getStLinkList (debugConnectParameters **stLinkList, int shared)
This routine allows to get ST-LINK conneted probe(s). More...
int | connectStLink (debugConnectParameters debugParameters)
This routine allows to start connection to device through SWD or JTAG interfaces. More...
int | reset (debugResetMode rstMode)
This routine used to apply a target reset. More...
int | getUsartList (usartConnectParameters **usartList)
This routine allows to get connected serial ports. More...
int | connectUsartBootloader (usartConnectParameters usartParameters)
This routine allows to start connection to device through USART interface. More...
int | sendByteUart (int byte)
This routine allows to send a single byte through the USART interface. More...
int | getDfuDeviceList (dfuDeviceInfo **dfuList)
This routine allows to get connected DFU devices. More...
int | connectDfuBootloader (char *usbIndex)
This routine allows to start connection to device through USB DFU interface. More...
int | connectSpiBootloader (spiConnectParameters spiParameters)
This routine allows to start connection to device through SPI interface. More...
int | connectCanBootloader (canConnectParameters canParameters)
This routine allows to start connection to device through CAN interface. More...
int | connectI2cBootloader (i2cConnectParameters i2cParameters)
This routine allows to start connection to device through I2C interface. More...
void | setDisplayCallbacks (displayCallBacks c)
This routine allows to choose your custom display. More...
void | setVerbosityLevel (int level)
This routine allows to choose the verbosity level for display. More...
int | checkDeviceConnection ()
This routine allows to check connection status [maintained or lost]. More...
generalInf * getDeviceGeneralInf ()
This routine allows to get general device informations. More...
int | readMemory (unsigned int address, unsigned char **data, unsigned int size)
This routine allows to receive memory data on the used interface with the configration already initialized. More...
int | writeMemory (unsigned int address, char *data, unsigned int size)
This routine allows to write memory data on the user interface with the configration already initialized. More...
int | downloadFile (const wchar_t *filePath, unsigned int address, unsigned int skipErase, unsigned int verify, const wchar_t *binPath)
This routine allows to download data from a file to the memory. File formats that are supported : hex, bin, srec. More...
int | execute (unsigned int address)
This routine allows to run the application. More...
int | massErase ()
This routine allows to erase the whole Flash memory. More...
int | sectorErase (unsigned int sectors[], unsigned int sectorNbr)
This routine allows to erase specific sectors of the Flash memory. More...
int | readUnprotect ()
This routine allows to disable the readout protection. If the memory is not protected, a message appears to indicate that the device is not under Readout protection and the command has no effects. More...
int | getTargetInterfaceType ()
This routine allows to know the interface what is in use. More...
volatile int * | getCancelPointer ()
This routine allows to drop the current read/write operation. More...
void * | fileOpen (const wchar_t *filePath)
This routine allows to open and get data from any supported file extension. More...
void | freeFileData (fileData_C *data)
This routine allows to clean up the handled file data. More...
int | verify (fileData_C *fileData, unsigned int address)
This routine allows to verfiy if the indicated file data is identical to Flash memory content. More...
int | saveFileToFile (fileData_C *fileData, const wchar_t *sFileName)
This routine allows to save the data file content to another file. More...
int | saveMemoryToFile (int address, int size, const wchar_t *sFileName)
This routine allows to save Flash memory content to file. More...
void | disconnect ()
This routine allows to clean up and disconnect the current connected target. More...
void | deleteInterfaceList ()
This routine allows to clear the list of each created interface. More...
void | automaticMode (const wchar_t *filePath, unsigned int address, unsigned int skipErase, unsigned int verify, int isMassErase, char *obCommand, int run)
This routine allows to enter and make an automatic process for memory management through JTAG/SWD, UART, DFU, SPI, CAN and I²C interfaces. More...
int | sendOptionBytesCmd (char *command)
This routine allows program the given Option Byte. The option bytes are configured by the end user depending on the application requirements. More...
peripheral_C * initOptionBytesInterface ()
This routine allows to get option bytes values of the connected target. More...
void | setLoadersPath (const char *path)
This routine allows to specify the location of Flash Loader. More...
void | setExternalLoaderPath (const char *path, externalLoader **externalLoaderInfo)
This routine allows to specify the path of the external Loaders to be loaded. More...
int | getExternalLoaders (const char *path, externalStorageInfo **externalStorageNfo)
This routine allows to get available external Loaders in th mentioned path. More...
void | removeExternalLoader (const char *path)
This routine allows to unload an external Loaders. More...
void | deleteLoaders ()
This routine allows to delete all target Flash Loaders. More...

Macro Definition Documentation

◆ CP_EXPORTS

#define CP_EXPORTS

Typedef Documentation

◆ canConnectParameters

typedef struct canConnectParameters canConnectParameters

◆ debugConnectMode

typedef enum debugConnectMode debugConnectMode

◆ debugConnectParameters

typedef struct debugConnectParameters debugConnectParameters

◆ debugPort

typedef enum debugPort debugPort

◆ debugResetMode

typedef enum debugResetMode debugResetMode

◆ deviceSector

typedef struct deviceSector deviceSector

◆ dfuDeviceInfo

typedef struct dfuDeviceInfo dfuDeviceInfo

◆ displayCallBacks

typedef struct displayCallBacks displayCallBacks

◆ externalLoader

typedef struct externalLoader externalLoader

◆ externalStorageInfo

typedef struct externalStorageInfo externalStorageInfo

◆ fileData_C

typedef struct fileData_C fileData_C

◆ frequencies

typedef struct frequencies frequencies

◆ generalInf

typedef struct generalInf generalInf

◆ i2cConnectParameters

typedef struct i2cConnectParameters i2cConnectParameters

◆ segmentData_C

typedef struct segmentData_C segmentData_C

◆ spiConnectParameters

typedef struct spiConnectParameters spiConnectParameters

◆ targetInterfaceType

typedef enum targetInterfaceType targetInterfaceType

◆ usartConnectParameters

typedef struct usartConnectParameters usartConnectParameters

◆ usartFlowControl

typedef enum usartFlowControl usartFlowControl

◆ usartParity

typedef enum usartParity usartParity

Enumeration Type Documentation

◆ cubeProgrammerError

enum cubeProgrammerError

List of errors that can be occured.

Enumerator
CUBEPROGRAMMER_NO_ERROR | Success (no error)
CUBEPROGRAMMER_ERROR_NOT_CONNECTED | Device not connected
CUBEPROGRAMMER_ERROR_NO_DEVICE | Device not found
CUBEPROGRAMMER_ERROR_CONNECTION | Device connection error
CUBEPROGRAMMER_ERROR_NO_FILE | No such file
CUBEPROGRAMMER_ERROR_NOT_SUPPORTED | Operation not supported or unimplemented on this interface
CUBEPROGRAMMER_ERROR_INTERFACE_NOT_SUPPORTED | Interface not supported or unimplemented on this plateform
CUBEPROGRAMMER_ERROR_NO_MEM | Insufficient memory
CUBEPROGRAMMER_ERROR_WRONG_PARAM | Wrong parameters
CUBEPROGRAMMER_ERROR_READ_MEM | Memory read failure
CUBEPROGRAMMER_ERROR_WRITE_MEM | Memory write failure
CUBEPROGRAMMER_ERROR_ERASE_MEM | Memory erase failure
CUBEPROGRAMMER_ERROR_UNSUPPORTED_FILE_FORMAT | File format not supported for this kind of device
CUBEPROGRAMMER_ERROR_REFRESH_REQUIRED | Refresh required
CUBEPROGRAMMER_ERROR_NO_SECURITY | Refresh required
CUBEPROGRAMMER_ERROR_CHANGE_FREQ | Changing frequency problem
CUBEPROGRAMMER_ERROR_OTHER | Other error

◆ cubeProgrammerVerbosityLevel

enum cubeProgrammerVerbosityLevel

List of verbosity levels.

Enumerator
CUBEPROGRAMMER_VER_LEVEL_NONE | no messages ever printed by the library
CUBEPROGRAMMER_VER_LEVEL_ONE | warning, error and success messages are printed (default)
CUBEPROGRAMMER_VER_LEVEL_TWO | error roots informational messages are printed
CUBEPROGRAMMER_VER_LEVEL_DEBUG | debug and informational messages are printed
CUBEPROGRAMMER_NO_PROGRESS_BAR | no progress bar is printed in the output of the library

◆ debugConnectMode

enum debugConnectMode

Choose the appropriate mode for connection.

Enumerator
NORMAL_MODE | Connect with normal mode, the target is reset then halted while the type of reset is selected using the [debugResetMode].
HOTPLUG_MODE | Connect with hotplug mode, this option allows the user to connect to the target without halt or reset.
UNDER_RESET_MODE | Connect with under reset mode, option allows the user to connect to the target using a reset vector catch before executing any instruction.
PRE_RESET_MODE | Connect with pre reset mode.

◆ debugPort

enum debugPort

Select the debug port interface for connection.

Enumerator
JTAG | JTAG debug port.
SWD | SWD debug port.

◆ debugResetMode

enum debugResetMode

Choose the way to apply a system reset.

Enumerator
SOFTWARE_RESET | Apply a reset by the software.
HARDWARE_RESET | Apply a reset by the hardware.
CORE_RESET | Apply a reset by the internal core peripheral.

◆ targetInterfaceType

enum targetInterfaceType

Indicates the supported interfaces.

Enumerator
STLINK_INTERFACE | STLINK used as connection interface.
USART_INTERFACE | USART used as connection interface.
USB_INTERFACE | USB DFU used as connection interface.
SPI_INTERFACE | SPI used as connection interface.
I2C_INTERFACE | I2C used as connection interface.
CAN_INTERFACE | CAN used as connection interface.

◆ usartFlowControl

enum usartFlowControl

UART Flow Control is a method for devices to communicate with each other over UART without the risk of losing data.

Enumerator
OFF | No flow control.
HARDWARE | Hardware flow control : RTS/CTS.
SOFTWARE | Software flow control : Transmission is started and stopped by sending special characters.

◆ usartParity

enum usartParity

The parity bit in the data frame of the USART communication tells the receiving device if there is any error in the data bits.

Enumerator
EVEN | Even parity bit.
ODD | Odd parity bit.
NONE | No check parity.


STM32CubeProgrammer API: files/DeviceDataStructure.h File Reference

  • files
Data Structures | Macros | Typedefs
DeviceDataStructure.h File Reference

Go to the source code of this file.

Data Structures

struct | bankSector
This stucture indicates the sectors parameters. More...
struct | deviceBank
This stucture defines the memory sectors for each bank. More...
struct | storageStructure
This stucture describes sotrage characterization. More...
struct | bitCoefficient_C
This stucture indicates the coefficients to access to the adequate option bit. More...
struct | bitValue_C
This stucture describes the option Bit value. More...
struct | bit_C
This stucture will be filled by values which characterize the device's option bytes. More...
struct | category_C
Get option bytes banks categories descriptions. More...
struct | bank_C
Get option bytes banks internal descriptions. More...
struct | peripheral_C
Get peripheral option bytes general informations. More...

Macros

#define | R_ACCESS 0x0
#define | W_ACCESS 0x1
#define | RW_ACCESS 0x2
#define | RWE_ACCESS 0x3

Typedefs

typedef struct bankSector | bankSector
typedef struct deviceBank | deviceBank
typedef struct storageStructure | storageStructure
typedef struct bitCoefficient_C | bitCoefficient_C
typedef struct bitValue_C | bitValue_C
typedef struct bit_C | bit_C
typedef struct category_C | category_C
typedef struct bank_C | bank_C
typedef struct peripheral_C | peripheral_C

Macro Definition Documentation

◆ R_ACCESS

#define R_ACCESS 0x0

◆ RW_ACCESS

#define RW_ACCESS 0x2

◆ RWE_ACCESS

#define RWE_ACCESS 0x3

◆ W_ACCESS

#define W_ACCESS 0x1

Typedef Documentation

◆ bank_C

typedef struct bank_C bank_C

◆ bankSector

typedef struct bankSector bankSector

◆ bit_C

typedef struct bit_C bit_C

◆ bitCoefficient_C

typedef struct bitCoefficient_C bitCoefficient_C

◆ bitValue_C

typedef struct bitValue_C bitValue_C

◆ category_C

typedef struct category_C category_C

◆ deviceBank

typedef struct deviceBank deviceBank

◆ peripheral_C

typedef struct peripheral_C peripheral_C

◆ storageStructure

typedef struct storageStructure storageStructure


STM32CubeProgrammer API: files/DisplayManager.cpp File Reference

  • files
DisplayManager.cpp File Reference

Detailed Description

This example of functions allows to personalize the display messages.

  • Implement Init Progress Bar function to add a progress bar.
  • Implement load Bar function to animate the loading process 0% to 100%.
  • Implement DisplayMessage function to ensure the display of internal DLL messages.
  • Implement logMessage function to personalize the display (user messages).

Go to the source code : DisplayManager


STM32CubeProgrammer API: files/Example1.cpp File Reference

  • files
Example1.cpp File Reference

Detailed Description

This example allows to execute some operations to the internal STM32 Flash memory.

  1. Detect connected ST-LINK and display them.
  2. Loop on each ST-LINK probes and execute the following operations:
    • Mass erase.
    • Single word edition (-w32).
    • Read 64 bytes from 0x08000000.
    • Sector erase.
    • Read 64 bytes from 0x08000000 .
    • System Reset.

Go to the source code : STLINK_Example1


STM32CubeProgrammer API: files/Example2.cpp File Reference

  • files
Example2.cpp File Reference

Detailed Description

This example allows to execute some operations to the internal STM32 Flash memory.

  1. Detect connected ST-LINK and display them.
  2. Loop on each ST-LINK probes and execute the following operations:
    • File programming + verification step.
    • Read 256 bytes from the address 0x08000000.
    • Run application.

Go to the source code : STLINK_Example2


STM32CubeProgrammer API: files/Example3.cpp File Reference

  • files
Example3.cpp File Reference

Detailed Description

This example allows to execute some operations to the internal STM32 Flash memory.

  1. Detect connected ST-LINK and display them.
  2. Loop on each ST-LINK probes and execute the following operations:
    • File programming + verification step.
    • Set RDP level.
    • Display option bytes.
    • Disable readout protection.
    • Display option bytes.
    • System Reset.

Go to the source code : STLINK_Example3


STM32CubeProgrammer API: files/I2C_Example.cpp File Reference

  • files
I2C_Example.cpp File Reference

Detailed Description

This example allows to connect to the target through I2C Bootloader interface and execute some operations to the internal STM32 Flash memory.

  • Connect to the device via I2C interface by indicating the slave address.
  • File programming + verification step.
  • Read 64 bytes from 0x08000000.
  • Option bytes programming : BOR level.
  • Display option bytes.

Go to the source code : I2C_Bootloader


STM32CubeProgrammer API: files/main.cpp File Reference

  • files
main.cpp File Reference

Detailed Description

The examples provided by the documentation are written for documentation to take inspiration for use cases. This code is the main program that allows to choose and execute the preferred example and to execute some operations to the internal STM32 Flash memory.

  • Set the Loader path.
  • Associate display manager functions.
  • Call examples functions.
  • Close all connected ST-LINK probes.

Go to the source code : main


STM32CubeProgrammer API: files/SPI_Example.cpp File Reference

  • files
SPI_Example.cpp File Reference

Detailed Description

This example allows to connect to the target through SPI Bootloader interface and execute some operations to the internal STM32 Flash memory.

  • Connect to the device via SPI interface.
  • File programming + verification step.
  • Read 64 bytes from 0x08000000.
  • Option bytes programming : BOR level.
  • Display option bytes.

Go to the source code : SPI_Bootloader


STM32CubeProgrammer API: files/UART_Example.cpp File Reference

  • files
UART_Example.cpp File Reference

Detailed Description

This example allows to connect to the target through UART Bootloader interface and execute some operations to the internal STM32 Flash memory.

  • Connect to the device via UART.
  • File programming + verification step.
  • Read 64 bytes from 0x08000000.
  • Option bytes programming : BOR level.
  • Display option bytes.

Go to the source code : UART_Bootloader


STM32CubeProgrammer API: files/USB_Example.cpp File Reference

  • files
USB_Example.cpp File Reference

Detailed Description

This example allows to connect to the target through USB Bootloader interface and execute some operations to the internal STM32 Flash memory.

  • Connect to the device via USB interface.
  • File programming + verification step.
  • Read 64 bytes from 0x08000000.
  • Option bytes programming : BOR level.
  • Display option bytes.

Go to the source code : USB_Bootloader


STM32CubeProgrammer API: Globals

Here is a list of all functions, variables, defines, enums, and typedefs with links to the files they belong to:

- a -

  • automaticMode() : CubeProgrammer_API.h

- b -

  • bank_C : DeviceDataStructure.h
  • bankSector : DeviceDataStructure.h
  • bit_C : DeviceDataStructure.h
  • bitCoefficient_C : DeviceDataStructure.h
  • bitValue_C : DeviceDataStructure.h

- c -

  • CAN_INTERFACE : CubeProgrammer_API.h
  • canConnectParameters : CubeProgrammer_API.h
  • category_C : DeviceDataStructure.h
  • checkDeviceConnection() : CubeProgrammer_API.h
  • connectCanBootloader() : CubeProgrammer_API.h
  • connectDfuBootloader() : CubeProgrammer_API.h
  • connectI2cBootloader() : CubeProgrammer_API.h
  • connectSpiBootloader() : CubeProgrammer_API.h
  • connectStLink() : CubeProgrammer_API.h
  • connectUsartBootloader() : CubeProgrammer_API.h
  • CORE_RESET : CubeProgrammer_API.h
  • CP_EXPORTS : CubeProgrammer_API.h
  • CUBEPROGRAMMER_ERROR_CHANGE_FREQ : CubeProgrammer_API.h
  • CUBEPROGRAMMER_ERROR_CONNECTION : CubeProgrammer_API.h
  • CUBEPROGRAMMER_ERROR_ERASE_MEM : CubeProgrammer_API.h
  • CUBEPROGRAMMER_ERROR_INTERFACE_NOT_SUPPORTED : CubeProgrammer_API.h
  • CUBEPROGRAMMER_ERROR_NO_DEVICE : CubeProgrammer_API.h
  • CUBEPROGRAMMER_ERROR_NO_FILE : CubeProgrammer_API.h
  • CUBEPROGRAMMER_ERROR_NO_MEM : CubeProgrammer_API.h
  • CUBEPROGRAMMER_ERROR_NO_SECURITY : CubeProgrammer_API.h
  • CUBEPROGRAMMER_ERROR_NOT_CONNECTED : CubeProgrammer_API.h
  • CUBEPROGRAMMER_ERROR_NOT_SUPPORTED : CubeProgrammer_API.h
  • CUBEPROGRAMMER_ERROR_OTHER : CubeProgrammer_API.h
  • CUBEPROGRAMMER_ERROR_READ_MEM : CubeProgrammer_API.h
  • CUBEPROGRAMMER_ERROR_REFRESH_REQUIRED : CubeProgrammer_API.h
  • CUBEPROGRAMMER_ERROR_UNSUPPORTED_FILE_FORMAT : CubeProgrammer_API.h
  • CUBEPROGRAMMER_ERROR_WRITE_MEM : CubeProgrammer_API.h
  • CUBEPROGRAMMER_ERROR_WRONG_PARAM : CubeProgrammer_API.h
  • CUBEPROGRAMMER_NO_ERROR : CubeProgrammer_API.h
  • CUBEPROGRAMMER_NO_PROGRESS_BAR : CubeProgrammer_API.h
  • CUBEPROGRAMMER_VER_LEVEL_DEBUG : CubeProgrammer_API.h
  • CUBEPROGRAMMER_VER_LEVEL_NONE : CubeProgrammer_API.h
  • CUBEPROGRAMMER_VER_LEVEL_ONE : CubeProgrammer_API.h
  • CUBEPROGRAMMER_VER_LEVEL_TWO : CubeProgrammer_API.h
  • cubeProgrammerError : CubeProgrammer_API.h
  • cubeProgrammerVerbosityLevel : CubeProgrammer_API.h

- d -

  • debugConnectMode : CubeProgrammer_API.h
  • debugConnectParameters : CubeProgrammer_API.h
  • debugPort : CubeProgrammer_API.h
  • debugResetMode : CubeProgrammer_API.h
  • deleteInterfaceList() : CubeProgrammer_API.h
  • deleteLoaders() : CubeProgrammer_API.h
  • deviceBank : DeviceDataStructure.h
  • deviceSector : CubeProgrammer_API.h
  • dfuDeviceInfo : CubeProgrammer_API.h
  • disconnect() : CubeProgrammer_API.h
  • displayCallBacks : CubeProgrammer_API.h
  • downloadFile() : CubeProgrammer_API.h

- e -

  • EVEN : CubeProgrammer_API.h
  • execute() : CubeProgrammer_API.h
  • externalLoader : CubeProgrammer_API.h
  • externalStorageInfo : CubeProgrammer_API.h

- f -

  • fileData_C : CubeProgrammer_API.h
  • fileOpen() : CubeProgrammer_API.h
  • freeFileData() : CubeProgrammer_API.h
  • frequencies : CubeProgrammer_API.h

- g -

  • generalInf : CubeProgrammer_API.h
  • getCancelPointer() : CubeProgrammer_API.h
  • getDeviceGeneralInf() : CubeProgrammer_API.h
  • getDfuDeviceList() : CubeProgrammer_API.h
  • getExternalLoaders() : CubeProgrammer_API.h
  • getStLinkList() : CubeProgrammer_API.h
  • getTargetInterfaceType() : CubeProgrammer_API.h
  • getUsartList() : CubeProgrammer_API.h

- h -

  • HARDWARE : CubeProgrammer_API.h
  • HARDWARE_RESET : CubeProgrammer_API.h
  • HOTPLUG_MODE : CubeProgrammer_API.h

- i -

  • I2C_INTERFACE : CubeProgrammer_API.h
  • i2cConnectParameters : CubeProgrammer_API.h
  • initOptionBytesInterface() : CubeProgrammer_API.h

- j -

  • JTAG : CubeProgrammer_API.h

- m -

  • massErase() : CubeProgrammer_API.h

- n -

  • NONE : CubeProgrammer_API.h
  • NORMAL_MODE : CubeProgrammer_API.h

- o -

  • ODD : CubeProgrammer_API.h
  • OFF : CubeProgrammer_API.h

- p -

  • peripheral_C : DeviceDataStructure.h
  • PRE_RESET_MODE : CubeProgrammer_API.h

- r -

  • R_ACCESS : DeviceDataStructure.h
  • readMemory() : CubeProgrammer_API.h
  • readUnprotect() : CubeProgrammer_API.h
  • removeExternalLoader() : CubeProgrammer_API.h
  • reset() : CubeProgrammer_API.h
  • RW_ACCESS : DeviceDataStructure.h
  • RWE_ACCESS : DeviceDataStructure.h

- s -

  • saveFileToFile() : CubeProgrammer_API.h
  • saveMemoryToFile() : CubeProgrammer_API.h
  • sectorErase() : CubeProgrammer_API.h
  • segmentData_C : CubeProgrammer_API.h
  • sendByteUart() : CubeProgrammer_API.h
  • sendOptionBytesCmd() : CubeProgrammer_API.h
  • setDisplayCallbacks() : CubeProgrammer_API.h
  • setExternalLoaderPath() : CubeProgrammer_API.h
  • setLoadersPath() : CubeProgrammer_API.h
  • setVerbosityLevel() : CubeProgrammer_API.h
  • SOFTWARE : CubeProgrammer_API.h
  • SOFTWARE_RESET : CubeProgrammer_API.h
  • SPI_INTERFACE : CubeProgrammer_API.h
  • spiConnectParameters : CubeProgrammer_API.h
  • STLINK_INTERFACE : CubeProgrammer_API.h
  • storageStructure : DeviceDataStructure.h
  • SWD : CubeProgrammer_API.h

- t -

  • targetInterfaceType : CubeProgrammer_API.h

- u -

  • UNDER_RESET_MODE : CubeProgrammer_API.h
  • USART_INTERFACE : CubeProgrammer_API.h
  • usartConnectParameters : CubeProgrammer_API.h
  • usartFlowControl : CubeProgrammer_API.h
  • usartParity : CubeProgrammer_API.h
  • USB_INTERFACE : CubeProgrammer_API.h

- v -

  • verify() : CubeProgrammer_API.h

- w -

  • W_ACCESS : DeviceDataStructure.h
  • writeMemory() : CubeProgrammer_API.h


STM32CubeProgrammer API: Globals

- a -

  • automaticMode() : CubeProgrammer_API.h

- c -

  • checkDeviceConnection() : CubeProgrammer_API.h
  • connectCanBootloader() : CubeProgrammer_API.h
  • connectDfuBootloader() : CubeProgrammer_API.h
  • connectI2cBootloader() : CubeProgrammer_API.h
  • connectSpiBootloader() : CubeProgrammer_API.h
  • connectStLink() : CubeProgrammer_API.h
  • connectUsartBootloader() : CubeProgrammer_API.h

- d -

  • deleteInterfaceList() : CubeProgrammer_API.h
  • deleteLoaders() : CubeProgrammer_API.h
  • disconnect() : CubeProgrammer_API.h
  • downloadFile() : CubeProgrammer_API.h

- e -

  • execute() : CubeProgrammer_API.h

- f -

  • fileOpen() : CubeProgrammer_API.h
  • freeFileData() : CubeProgrammer_API.h

- g -

  • getCancelPointer() : CubeProgrammer_API.h
  • getDeviceGeneralInf() : CubeProgrammer_API.h
  • getDfuDeviceList() : CubeProgrammer_API.h
  • getExternalLoaders() : CubeProgrammer_API.h
  • getStLinkList() : CubeProgrammer_API.h
  • getTargetInterfaceType() : CubeProgrammer_API.h
  • getUsartList() : CubeProgrammer_API.h

- i -

  • initOptionBytesInterface() : CubeProgrammer_API.h

- m -

  • massErase() : CubeProgrammer_API.h

- r -

  • readMemory() : CubeProgrammer_API.h
  • readUnprotect() : CubeProgrammer_API.h
  • removeExternalLoader() : CubeProgrammer_API.h
  • reset() : CubeProgrammer_API.h

- s -

  • saveFileToFile() : CubeProgrammer_API.h
  • saveMemoryToFile() : CubeProgrammer_API.h
  • sectorErase() : CubeProgrammer_API.h
  • sendByteUart() : CubeProgrammer_API.h
  • sendOptionBytesCmd() : CubeProgrammer_API.h
  • setDisplayCallbacks() : CubeProgrammer_API.h
  • setExternalLoaderPath() : CubeProgrammer_API.h
  • setLoadersPath() : CubeProgrammer_API.h
  • setVerbosityLevel() : CubeProgrammer_API.h

- v -

  • verify() : CubeProgrammer_API.h

- w -

  • writeMemory() : CubeProgrammer_API.h


STM32CubeProgrammer API: Globals

  • bank_C : DeviceDataStructure.h
  • bankSector : DeviceDataStructure.h
  • bit_C : DeviceDataStructure.h
  • bitCoefficient_C : DeviceDataStructure.h
  • bitValue_C : DeviceDataStructure.h
  • canConnectParameters : CubeProgrammer_API.h
  • category_C : DeviceDataStructure.h
  • debugConnectMode : CubeProgrammer_API.h
  • debugConnectParameters : CubeProgrammer_API.h
  • debugPort : CubeProgrammer_API.h
  • debugResetMode : CubeProgrammer_API.h
  • deviceBank : DeviceDataStructure.h
  • deviceSector : CubeProgrammer_API.h
  • dfuDeviceInfo : CubeProgrammer_API.h
  • displayCallBacks : CubeProgrammer_API.h
  • externalLoader : CubeProgrammer_API.h
  • externalStorageInfo : CubeProgrammer_API.h
  • fileData_C : CubeProgrammer_API.h
  • frequencies : CubeProgrammer_API.h
  • generalInf : CubeProgrammer_API.h
  • i2cConnectParameters : CubeProgrammer_API.h
  • peripheral_C : DeviceDataStructure.h
  • segmentData_C : CubeProgrammer_API.h
  • spiConnectParameters : CubeProgrammer_API.h
  • storageStructure : DeviceDataStructure.h
  • targetInterfaceType : CubeProgrammer_API.h
  • usartConnectParameters : CubeProgrammer_API.h
  • usartFlowControl : CubeProgrammer_API.h
  • usartParity : CubeProgrammer_API.h


STM32CubeProgrammer API: Globals

  • cubeProgrammerError : CubeProgrammer_API.h
  • cubeProgrammerVerbosityLevel : CubeProgrammer_API.h
  • debugConnectMode : CubeProgrammer_API.h
  • debugPort : CubeProgrammer_API.h
  • debugResetMode : CubeProgrammer_API.h
  • targetInterfaceType : CubeProgrammer_API.h
  • usartFlowControl : CubeProgrammer_API.h
  • usartParity : CubeProgrammer_API.h


STM32CubeProgrammer API: Globals

- c -

  • CAN_INTERFACE : CubeProgrammer_API.h
  • CORE_RESET : CubeProgrammer_API.h
  • CUBEPROGRAMMER_ERROR_CHANGE_FREQ : CubeProgrammer_API.h
  • CUBEPROGRAMMER_ERROR_CONNECTION : CubeProgrammer_API.h
  • CUBEPROGRAMMER_ERROR_ERASE_MEM : CubeProgrammer_API.h
  • CUBEPROGRAMMER_ERROR_INTERFACE_NOT_SUPPORTED : CubeProgrammer_API.h
  • CUBEPROGRAMMER_ERROR_NO_DEVICE : CubeProgrammer_API.h
  • CUBEPROGRAMMER_ERROR_NO_FILE : CubeProgrammer_API.h
  • CUBEPROGRAMMER_ERROR_NO_MEM : CubeProgrammer_API.h
  • CUBEPROGRAMMER_ERROR_NO_SECURITY : CubeProgrammer_API.h
  • CUBEPROGRAMMER_ERROR_NOT_CONNECTED : CubeProgrammer_API.h
  • CUBEPROGRAMMER_ERROR_NOT_SUPPORTED : CubeProgrammer_API.h
  • CUBEPROGRAMMER_ERROR_OTHER : CubeProgrammer_API.h
  • CUBEPROGRAMMER_ERROR_READ_MEM : CubeProgrammer_API.h
  • CUBEPROGRAMMER_ERROR_REFRESH_REQUIRED : CubeProgrammer_API.h
  • CUBEPROGRAMMER_ERROR_UNSUPPORTED_FILE_FORMAT : CubeProgrammer_API.h
  • CUBEPROGRAMMER_ERROR_WRITE_MEM : CubeProgrammer_API.h
  • CUBEPROGRAMMER_ERROR_WRONG_PARAM : CubeProgrammer_API.h
  • CUBEPROGRAMMER_NO_ERROR : CubeProgrammer_API.h
  • CUBEPROGRAMMER_NO_PROGRESS_BAR : CubeProgrammer_API.h
  • CUBEPROGRAMMER_VER_LEVEL_DEBUG : CubeProgrammer_API.h
  • CUBEPROGRAMMER_VER_LEVEL_NONE : CubeProgrammer_API.h
  • CUBEPROGRAMMER_VER_LEVEL_ONE : CubeProgrammer_API.h
  • CUBEPROGRAMMER_VER_LEVEL_TWO : CubeProgrammer_API.h

- e -

  • EVEN : CubeProgrammer_API.h

- h -

  • HARDWARE : CubeProgrammer_API.h
  • HARDWARE_RESET : CubeProgrammer_API.h
  • HOTPLUG_MODE : CubeProgrammer_API.h

- i -

  • I2C_INTERFACE : CubeProgrammer_API.h

- j -

  • JTAG : CubeProgrammer_API.h

- n -

  • NONE : CubeProgrammer_API.h
  • NORMAL_MODE : CubeProgrammer_API.h

- o -

  • ODD : CubeProgrammer_API.h
  • OFF : CubeProgrammer_API.h

- p -

  • PRE_RESET_MODE : CubeProgrammer_API.h

- s -

  • SOFTWARE : CubeProgrammer_API.h
  • SOFTWARE_RESET : CubeProgrammer_API.h
  • SPI_INTERFACE : CubeProgrammer_API.h
  • STLINK_INTERFACE : CubeProgrammer_API.h
  • SWD : CubeProgrammer_API.h

- u -

  • UNDER_RESET_MODE : CubeProgrammer_API.h
  • USART_INTERFACE : CubeProgrammer_API.h
  • USB_INTERFACE : CubeProgrammer_API.h


STM32CubeProgrammer API: Globals

  • CP_EXPORTS : CubeProgrammer_API.h
  • R_ACCESS : DeviceDataStructure.h
  • RW_ACCESS : DeviceDataStructure.h
  • RWE_ACCESS : DeviceDataStructure.h
  • W_ACCESS : DeviceDataStructure.h


STM32CubeProgrammer API: Examples

Examples
Here is a list of all examples:
  • CAN_Bootloader
  • DisplayManager
  • I2C_Bootloader
  • main
  • SPI_Bootloader
  • STLINK_Example1
  • STLINK_Example2
  • STLINK_Example3
  • UART_Bootloader
  • USB_Bootloader


STM32CubeProgrammer API: CAN_Bootloader

CAN_Bootloader

This example allows to connect to the target through CAN Bootloader interface and execute some operations to the internal STM32 Flash memory.

  • Connect to the device via CAN interface.
  • File programming + verification step.
  • Read 64 bytes from 0x08000000.
  • Option bytes programming : BOR level.
  • Display option bytes.
    /
    #include <CAN_Example.h>
    #include <DisplayManager.h>
    #include <CubeProgrammer_API.h>
    int CAN_Example(void) {
    logMessage(Title, "\n+++ CAN Bootloader Example +++\n\n");
    generalInf* genInfo;
    canConnectParameters canParam;
    canParam.br = 125000;
    canParam.mode = 0;
    canParam.ide = 0;
    canParam.rtr = 0;
    canParam.fifo = 0;
    canParam.fm = 0;
    canParam.fs = 1;
    canParam.fe = 1;
    canParam.fbn = 0;
    /* Target connect */
    int canConnectFlag = connectCanBootloader(canParam);
    if (canConnectFlag != 0) {
    logMessage(Error, "Establishing connection with the device failed");
    disconnect();
    return 0;
    }
    else {
    logMessage(GreenInfo, "\n--- Device Connected --- \n");
    }
    /* Display device informations */
    genInfo = getDeviceGeneralInf();
    logMessage(Normal, "\nDevice name : %s ", genInfo->name);
    logMessage(Normal, "\nDevice type : %s ", genInfo->type);
    logMessage(Normal, "\nDevice CPU : %s \n", genInfo->cpu);
    /* Download File + verification */
    #ifdef _WIN32
    const wchar_t* filePath = L"../test file/data.hex";
    #else
    const wchar_t* filePath = L"../api/test file/data.hex";
    #endif
    unsigned int isVerify = 1; //add verification step
    unsigned int isSkipErase = 0; // no skip erase
    int downloadFileFlag = downloadFile(filePath, 0x08000000, isSkipErase, isVerify, L"");
    if (downloadFileFlag != 0)
    {
    disconnect();
    return 0;
    }
    /* Reading 64 bytes from 0x08000000 */
    int size = 64;
    int startAddress = 0x08000000;
    unsigned char* dataStruct = 0;
    int readMemoryFlag = readMemory(startAddress, &dataStruct, size);
    if (readMemoryFlag != 0)
    {
    disconnect();
    return 0;
    }
    logMessage(Normal, "\nReading 32-bit memory content\n");
    logMessage(Normal, " Size : %d Bytes\n", size);
    logMessage(Normal, " Address: : 0x%08X\n", startAddress);
    int i = 0, col = 0;
    while ((i<size))
    {
    col = 0;
    logMessage(Normal, "\n0x%08X :", startAddress + i);
    while ((col<4) && (i<size))
    {
    logMessage(Info, " %08X ", *(unsigned int *)(dataStruct + i));
    col++;
    i += 4;
    }
    }
    logMessage(Normal, "\n");
    /* Option bytes programming : BOR level */
    int sendOptionBytesCmdFlag = sendOptionBytesCmd((char*)"-ob BOR_LEV=1");
    if (sendOptionBytesCmdFlag != 0)
    {
    disconnect();
    return 0;
    }
    /* Display option bytes */
    peripheral_C* ob = initOptionBytesInterface();
    if (ob == 0)
    {
    disconnect();
    return 0;
    }
    for (unsigned int i = 0; i < ob->banksNbr; i++)
    {
    logMessage(Normal, "OPTION BYTES BANK: %d\n", i);
    for (unsigned int j = 0; j < ob->banks[i]->categoriesNbr; j++)
    {
    logMessage(Title, "\t%s\n", ob->banks[i]->categories[j]);
    for (unsigned int k = 0; k < ob->banks[i]->categories[j]->bitsNbr; k++)
    {
    if (ob->banks[i]->categories[j]->bits[k]->access == 0 || ob->banks[i]->categories[j]->bits[k]->access == 2) {
    logMessage(Normal, "\t\t%s", ob->banks[i]->categories[j]->bits[k]->name);
    logMessage(Info, ": 0x%x\n", ob->banks[i]->categories[j]->bits[k]->bitValue);
    }
    }
    }
    }
    /* Process successfully Done */
    disconnect();
    return 1;
    }


STM32CubeProgrammer API: DisplayManager

DisplayManager

This example of functions allows to personalize the display messages.

  • Implement Init Progress Bar function to add a progress bar.
  • Implement load Bar function to animate the loading process 0% to 100%.
  • Implement DisplayMessage function to ensure the display of internal DLL messages.
  • Implement logMessage function to personalize the display (user messages).
    /
    #define _CRT_SECURE_NO_WARNINGS // will disable warnings to use vsprintf instead vsprintf_s
    #include <stdio.h>
    #include <DisplayManager.h>
    #include <stdarg.h>
    #include <string>
    #include <iostream>
    #ifdef _WIN32
    #include <windows.h>
    HANDLE console = GetStdHandle(STD_OUTPUT_HANDLE);;
    CONSOLE_SCREEN_BUFFER_INFO SBInfo, CurSBInfo;
    #endif
    #define WIDH 50
    using namespace std;
    unsigned int verbosityLevel;
    unsigned int Progress = 0;
    void InitPBar()
    {
    #ifdef _WIN32
    if (verbosityLevel == VERBOSITY_LEVEL_1)
    {
    for (int idx = 0; idx < WIDH; idx++)
    {
    console = GetStdHandle(STD_OUTPUT_HANDLE);
    SetConsoleTextAttribute(console, LIGHTGREY);
    putc(177, stdout);
    }
    GetConsoleScreenBufferInfo(console, &SBInfo);
    printf(" %d%c", Progress,'%');
    SetConsoleTextAttribute(console, LIGHTCYAN);
    putc('\r', stdout);
    Progress = 0;
    }
    #endif
    }
    void lBar(int currProgress, int total)
    {
    unsigned int alreadyLoaded = 0;
    if (total == 0) return;
    if (currProgress > total)
    currProgress = total;
    /*Calculuate the ratio of complete-to-incomplete.*/
    float ratio = currProgress / (float)total;
    unsigned int counter = (unsigned int)ratio * WIDH;
    if ((counter > alreadyLoaded) && (verbosityLevel == VERBOSITY_LEVEL_1))
    {
    #ifdef _WIN32
    SetConsoleTextAttribute(console, FOREGROUND_GREEN);
    for (DWORD Idx = Progress; Idx < (counter - alreadyLoaded); Idx++)
    {
    putc(219, stdout);
    }
    Progress = counter;
    GetConsoleScreenBufferInfo(console, &CurSBInfo);
    SetConsoleCursorPosition(console, SBInfo.dwCursorPosition);
    printf(" %d%%", (int)(ratio * 100));
    SetConsoleCursorPosition(console, CurSBInfo.dwCursorPosition);
    #else
    printf("\033[00;32m");
    printf("[");
    for (int i = 0; i < counter; i++)
    {
    printf("=");
    }
    for (int i = counter; i < WIDH; i++)
    {
    printf(" ");
    }
    // draw the percentage progress
    printf("] %3d%% \r", (int)(ratio * 100)); /* Move to the first column*/
    printf("\033[39;49m");
    #endif
    }
    alreadyLoaded = counter;
    }
    void DisplayMessage(int msgType, const wchar_t* str)
    {
    #ifdef _WIN32
    switch (msgType)
    {
    default:
    case Normal:
    SetConsoleTextAttribute(console, WHITE);
    break;
    case GreenInfo:
    SetConsoleTextAttribute(console, GREEN);
    break;
    case Info:
    SetConsoleTextAttribute(console, LIGHTGREY);
    break;
    case Title:
    SetConsoleTextAttribute(console, LIGHTCYAN);
    break;
    case Error:
    SetConsoleTextAttribute(console, RED);
    break;
    case Warning:
    SetConsoleTextAttribute(console, YELLOW);
    break;
    case ErrorNoPopup:
    SetConsoleTextAttribute(console, RED);
    break;
    case WarningNoPopup:
    SetConsoleTextAttribute(console, YELLOW);
    break;
    case Verbosity_1:
    SetConsoleTextAttribute(console, CYAN);
    break;
    case Verbosity_2:
    SetConsoleTextAttribute(console, CYAN);
    break;
    case Verbosity_3:
    SetConsoleTextAttribute(console, CYAN);
    break;
    }
    if ((msgType != Verbosity_1 && msgType != Verbosity_2 && msgType != Verbosity_3) || ((msgType == Verbosity_1 && verbosityLevel >= VERBOSITY_LEVEL_1) || (msgType == Verbosity_2 && verbosityLevel >= VERBOSITY_LEVEL_2) || (msgType == Verbosity_3 && verbosityLevel == VERBOSITY_LEVEL_3))) {
    wprintf(L"%s\n", str);
    }
    SetConsoleTextAttribute(console, WHITE);
    #else
    if (verbosityLevel == VERBOSITY_LEVEL_1)
    {
    if ((msgType == Verbosity_1 && verbosityLevel >= 1))
    printf("\033[39;36m");
    if ((msgType == Verbosity_2 && verbosityLevel >= 2))
    printf("\033[39;36m");
    if ((msgType == Verbosity_3 && verbosityLevel >= 3))
    printf("\033[39;36m");
    switch (msgType)
    {
    case GreenInfo:
    printf("\033[00;32m");
    break;
    case Info:
    printf("\e[90m");
    break;
    case Normal:
    printf("\033[39;49m");
    break;
    case Warning:
    printf("\033[00;33m");
    break;
    case Error:
    printf("\033[00;31m");
    break;
    case Title:
    printf("\e[36m\033[01m");
    break;
    }
    }
    if ((msgType != Verbosity_1 && msgType != Verbosity_2 && msgType != Verbosity_3) || ((msgType == Verbosity_1 && verbosityLevel >= 1) || (msgType == Verbosity_2 && verbosityLevel >= 2) || (msgType == Verbosity_3 && verbosityLevel == 3)))
    {
    std::wcout << str << std::endl;
    }
    printf("\033[39;49m");
    #endif
    }
    void logMessage(int msgType, const char* str, ...)
    {
    #ifdef _WIN32
    switch (msgType)
    {
    default:
    case Normal:
    SetConsoleTextAttribute(console, WHITE);
    break;
    case GreenInfo:
    SetConsoleTextAttribute(console, GREEN);
    break;
    case Info:
    SetConsoleTextAttribute(console, LIGHTGREY);
    break;
    case Title:
    SetConsoleTextAttribute(console, LIGHTCYAN);
    break;
    case Error:
    SetConsoleTextAttribute(console, RED);
    break;
    case Warning:
    SetConsoleTextAttribute(console, YELLOW);
    break;
    case ErrorNoPopup:
    SetConsoleTextAttribute(console, RED);
    break;
    case WarningNoPopup:
    SetConsoleTextAttribute(console, YELLOW);
    break;
    case Verbosity_1:
    SetConsoleTextAttribute(console, CYAN);
    break;
    case Verbosity_2:
    SetConsoleTextAttribute(console, CYAN);
    break;
    case Verbosity_3:
    SetConsoleTextAttribute(console, CYAN);
    break;
    }
    #else
    switch (msgType)
    {
    case GreenInfo:
    printf("\033[00;32m");
    break;
    case Info:
    printf("\e[90m");
    break;
    case Normal:
    printf("\033[39;49m");
    break;
    case Warning:
    printf("\033[00;33m");
    break;
    case Error:
    printf("\033[00;31m");
    break;
    case Title:
    printf("\e[36m\033[01m");
    break;
    }
    #endif
    va_list args;
    va_start(args, str);
    char buffer[256];
    vsprintf(buffer, str, args);
    printf("%s", buffer);
    va_end(args);
    #ifdef _WIN32
    SetConsoleTextAttribute(console, WHITE);
    #else
    printf("\033[39;49m");
    #endif
    }


STM32CubeProgrammer API: I2C_Bootloader

I2C_Bootloader

This example allows to connect to the target through I2C Bootloader interface and execute some operations to the internal STM32 Flash memory.

  • Connect to the device via I2C interface by indicating the slave address.
  • File programming + verification step.
  • Read 64 bytes from 0x08000000.
  • Option bytes programming : BOR level.
  • Display option bytes.
    /
    #include <I2C_Example.h>
    #include <DisplayManager.h>
    #include <CubeProgrammer_API.h>
    #define STM32L45xxx 0x4A // I2C Bootloader address for STM32L45xxx device
    #define STM32F42xxx 0x38
    #define STM32F72xxx 0x49
    #define STM32H74xxx 0x4E //...
    int I2C_Example(void) {
    logMessage(Title, "\n+++ I2C Bootloader Example +++\n\n");
    generalInf* genInfo;
    i2cConnectParameters i2cParam;
    i2cParam.add = STM32L45xxx ; //Bootloader address for STM32L452RE, an address must be insered here, otherwise the connection can not be established.
    i2cParam.br = 400;
    i2cParam.sm = 1;
    i2cParam.am = 0;
    i2cParam.af = 1;
    i2cParam.df = 0;
    i2cParam.dnf = 0;
    i2cParam.rt = 0;
    i2cParam.ft = 0;
    /* Target connect */
    int i2cConnectFlag = connectI2cBootloader(i2cParam);
    if (i2cConnectFlag != 0) {
    logMessage(Error, "Establishing connection with the device failed");
    disconnect();
    return 0;
    }
    else {
    logMessage(GreenInfo, "\n--- Device Connected --- \n");
    }
    /* Display device informations */
    genInfo = getDeviceGeneralInf();
    logMessage(Normal, "\nDevice name : %s ", genInfo->name);
    logMessage(Normal, "\nDevice type : %s ", genInfo->type);
    logMessage(Normal, "\nDevice CPU : %s \n", genInfo->cpu);
    /* Download File + verification */
    #ifdef _WIN32
    const wchar_t* filePath = L"../test file/data.hex";
    #else
    const wchar_t* filePath = L"../api/test file/data.hex";
    #endif
    unsigned int isVerify = 1; //add verification step
    unsigned int isSkipErase = 0; // no skip erase
    int downloadFileFlag = downloadFile(filePath, 0x08000000, isSkipErase, isVerify, L"");
    if (downloadFileFlag != 0)
    {
    disconnect();
    return 0;
    }
    /* Reading 64 bytes from 0x08000000 */
    int size = 64;
    int startAddress = 0x08000000;
    unsigned char* dataStruct = 0;
    int readMemoryFlag = readMemory(startAddress, &dataStruct, size);
    if (readMemoryFlag != 0)
    {
    disconnect();
    return 0;
    }
    logMessage(Normal, "\nReading 32-bit memory content\n");
    logMessage(Normal, " Size : %d Bytes\n", size);
    logMessage(Normal, " Address: : 0x%08X\n", startAddress);
    int i = 0, col = 0;
    while ((i<size))
    {
    col = 0;
    logMessage(Normal, "\n0x%08X :", startAddress + i);
    while ((col<4) && (i<size))
    {
    logMessage(Info, " %08X ", *(unsigned int *)(dataStruct + i));
    col++;
    i += 4;
    }
    }
    logMessage(Normal, "\n");
    /* Option bytes programming : BOR level */
    int sendOptionBytesCmdFlag = sendOptionBytesCmd((char*)"-ob BOR_LEV=1");
    if (sendOptionBytesCmdFlag != 0)
    {
    disconnect();
    return 0;
    }
    /* Display option bytes */
    peripheral_C* ob = initOptionBytesInterface();
    if (ob == 0)
    {
    disconnect();
    return 0;
    }
    for (unsigned int i = 0; i < ob->banksNbr; i++)
    {
    logMessage(Normal, "OPTION BYTES BANK: %d\n", i);
    for (unsigned int j = 0; j < ob->banks[i]->categoriesNbr; j++)
    {
    logMessage(Title, "\t%s\n", ob->banks[i]->categories[j]);
    for (unsigned int k = 0; k < ob->banks[i]->categories[j]->bitsNbr; k++)
    {
    if (ob->banks[i]->categories[j]->bits[k]->access == 0 || ob->banks[i]->categories[j]->bits[k]->access == 2) {
    logMessage(Normal, "\t\t%s", ob->banks[i]->categories[j]->bits[k]->name);
    logMessage(Info, ": 0x%x\n", ob->banks[i]->categories[j]->bits[k]->bitValue);
    }
    }
    }
    }
    /* Process successfully Done */
    disconnect();
    return 1;
    }


STM32CubeProgrammer API: main

main

The examples provided by the documentation are written for documentation to take inspiration for use cases. This code is the main program that allows to choose and execute the preferred example and to execute some operations to the internal STM32 Flash memory.

  • Set the Loader path.
  • Associate display manager functions.
  • Call examples functions.
  • Close all connected ST-LINK probes.
    /
    #include <iostream>
    #include <DisplayManager.h>
    #include <CubeProgrammer_API.h>
    #include <Example1.h>
    #include <Example2.h>
    #include <Example3.h>
    #include <I2C_Example.h>
    #include <CAN_Example.h>
    #include <SPI_Example.h>
    #include <UART_Example.h>
    #include <USB_Example.h>
    extern unsigned int verbosityLevel;
    int main()
    {
    int ret = 0;
    const char* loaderPath = "./.";
    displayCallBacks vsLogMsg;
    /* Set device loaders path that contains FlashLoader and ExternalLoader folders*/
    setLoadersPath(loaderPath);
    /* Set the progress bar and message display functions callbacks */
    vsLogMsg.logMessage = DisplayMessage;
    vsLogMsg.initProgressBar = InitPBar;
    vsLogMsg.loadBar = lBar;
    setDisplayCallbacks(vsLogMsg);
    /* Set DLL verbosity level */
    setVerbosityLevel(verbosityLevel = VERBOSITY_LEVEL_1);
    ret = Example1();
    //ret = Example2();
    //ret = Example3();
    //ret = I2C_Example();
    //ret = CAN_Example();
    //ret = SPI_Example();
    //ret = UART_Example();
    //ret = USB_Example();
    std::cout << "\n" << "Press enter to continue...";
    std::cin.get() ;
    return ret;
    }


STM32CubeProgrammer API: SPI_Bootloader

SPI_Bootloader

This example allows to connect to the target through SPI Bootloader interface and execute some operations to the internal STM32 Flash memory.

  • Connect to the device via SPI interface.
  • File programming + verification step.
  • Read 64 bytes from 0x08000000.
  • Option bytes programming : BOR level.
  • Display option bytes.
    /
    #include <SPI_Example.h>
    #include <DisplayManager.h>
    #include <CubeProgrammer_API.h>
    int SPI_Example(void) {
    logMessage(Title, "\n+++ SPI Bootloader Example +++\n\n");
    generalInf* genInfo;
    spiConnectParameters spiParam;
    spiParam.baudrate = 375;
    spiParam.crcPol = 7;
    spiParam.direction = 0;
    spiParam.cpha = 0;
    spiParam.cpol = 0;
    spiParam.crc = 0;
    spiParam.firstBit = 1;
    spiParam.frameFormat = 0;
    spiParam.dataSize = 1;
    spiParam.mode = 1;
    spiParam.nss = 1;
    spiParam.nssPulse = 1;
    spiParam.delay = 1;
    /* Target connect */
    int spiConnectFlag = connectSpiBootloader(spiParam);
    if (spiConnectFlag != 0) {
    logMessage(Error, "Establishing connection with the device failed");
    disconnect();
    return 0;
    }
    else {
    logMessage(GreenInfo, "\n--- Device Connected --- \n");
    }
    /* Display device informations */
    genInfo = getDeviceGeneralInf();
    logMessage(Normal, "\nDevice name : %s ", genInfo->name);
    logMessage(Normal, "\nDevice type : %s ", genInfo->type);
    logMessage(Normal, "\nDevice CPU : %s \n", genInfo->cpu);
    /* Download File + verification */
    #ifdef _WIN32
    const wchar_t* filePath = L"../test file/data.hex";
    #else
    const wchar_t* filePath = L"../api/test file/data.hex";
    #endif
    unsigned int isVerify = 1; //add verification step
    unsigned int isSkipErase = 0; // no skip erase
    int downloadFileFlag = downloadFile(filePath, 0x08000000, isSkipErase, isVerify, L"");
    if (downloadFileFlag != 0)
    {
    disconnect();
    return 0;
    }
    /* Reading 64 bytes from 0x08000000 */
    int size = 64;
    int startAddress = 0x08000000;
    unsigned char* dataStruct = 0;
    int readMemoryFlag = readMemory(startAddress, &dataStruct, size);
    if (readMemoryFlag != 0)
    {
    disconnect();
    return 0;
    }
    logMessage(Normal, "\nReading 32-bit memory content\n");
    logMessage(Normal, " Size : %d Bytes\n", size);
    logMessage(Normal, " Address: : 0x%08X\n", startAddress);
    int i = 0, col = 0;
    while ((i<size))
    {
    col = 0;
    logMessage(Normal, "\n0x%08X :", startAddress + i);
    while ((col<4) && (i<size))
    {
    logMessage(Info, " %08X ", *(unsigned int *)(dataStruct + i));
    col++;
    i += 4;
    }
    }
    logMessage(Normal, "\n");
    /* Option bytes programming : BOR level */
    int sendOptionBytesCmdFlag = sendOptionBytesCmd((char*)"-ob BOR_LEV=1");
    if (sendOptionBytesCmdFlag != 0)
    {
    disconnect();
    return 0;
    }
    /* Display option bytes */
    peripheral_C* ob = initOptionBytesInterface();
    if (ob == 0)
    {
    disconnect();
    return 0;
    }
    for (unsigned int i = 0; i < ob->banksNbr; i++)
    {
    logMessage(Normal, "OPTION BYTES BANK: %d\n", i);
    for (unsigned int j = 0; j < ob->banks[i]->categoriesNbr; j++)
    {
    logMessage(Title, "\t%s\n", ob->banks[i]->categories[j]);
    for (unsigned int k = 0; k < ob->banks[i]->categories[j]->bitsNbr; k++)
    {
    if (ob->banks[i]->categories[j]->bits[k]->access == 0 || ob->banks[i]->categories[j]->bits[k]->access == 2) {
    logMessage(Normal, "\t\t%s", ob->banks[i]->categories[j]->bits[k]->name);
    logMessage(Info, ": 0x%x\n", ob->banks[i]->categories[j]->bits[k]->bitValue);
    }
    }
    }
    }
    /* Process successfully Done */
    disconnect();
    return 1;
    }


STM32CubeProgrammer API: STLINK_Example1

STLINK_Example1

This example allows to execute some operations to the internal STM32 Flash memory.

  1. Detect connected ST-LINK and display them.
  2. Loop on each St-LINK probes and execute the following operations:
    • Mass erase.
    • Single word edition (-w32).
    • Read 64 bytes from 0x08000000.
    • Sector erase.
    • Read 64 bytes from 0x08000000 .
    • System Reset.
      /
      #include <stdio.h>
      #include <DisplayManager.h>
      #include <CubeProgrammer_API.h>
      int Example1(void) {
      logMessage(Title, "\n+++ Example 1 +++\n\n");
      debugConnectParameters *stLinkList;
      debugConnectParameters debugParameters;
      generalInf* genInfo;
      int getStlinkListNb = getStLinkList(&stLinkList, 0);
      if (getStlinkListNb == 0)
      {
      logMessage(Error, "No STLINK available\n");
      return 0;
      }
      else {
      logMessage(Title, "\n-------- Connected ST-LINK Probes List --------");
      for (int i = 0; i < getStlinkListNb; i++)
      {
      logMessage(Normal, "\nST-LINK Probe %d :\n", i);
      logMessage(Info, " ST-LINK SN : %s \n", stLinkList[i].serialNumber);
      logMessage(Info, " ST-LINK FW : %s \n", stLinkList[i].firmwareVersion);
      }
      logMessage(Title, "-----------------------------------------------\n\n");
      }
      for (int index = 0; index < getStlinkListNb; index++) {
      logMessage(Title, "\n--------------------- ");
      logMessage(Title, "\n ST-LINK Probe : %d ", index);
      logMessage(Title, "\n--------------------- \n\n");
      debugParameters = stLinkList[index];
      debugParameters.connectionMode = UNDER_RESET_MODE;
      debugParameters.shared = 0;
      /* Target connect */
      int connectStlinkFlag = connectStLink(debugParameters);
      if (connectStlinkFlag != 0) {
      logMessage(Error, "Establishing connection with the device failed\n");
      disconnect();
      continue;
      }
      else {
      logMessage(GreenInfo, "\n--- Device %d Connected --- \n",index);
      }
      /* Display device informations */
      genInfo = getDeviceGeneralInf();
      logMessage(Normal, "\nDevice name : %s ", genInfo->name);
      logMessage(Normal, "\nDevice type : %s ", genInfo->type);
      logMessage(Normal, "\nDevice CPU : %s \n", genInfo->cpu);
      /* Apply mass Erase */
      int massEraseFlag = massErase();
      if (massEraseFlag != 0)
      {
      disconnect();
      continue;
      }
      /* Single word edition */
      int size = 4;
      int startAddress = 0x08000000;
      char data[8] = { (char)0xAA, (char)0xAA, (char)0xBB, (char)0xBB, (char)0xCC, (char)0xCC, (char)0xDD, (char)0xDD };
      int writeMemoryFlag = writeMemory(startAddress, data, size);
      if (writeMemoryFlag != 0)
      {
      disconnect();
      continue;
      }
      /* Reading 64 bytes from 0x08000000 */
      unsigned char* dataStruct = 0;
      size = 64;
      int readMemoryFlag = readMemory(startAddress, &dataStruct, size);
      if (readMemoryFlag != 0)
      {
      disconnect();
      continue;
      }
      logMessage(Normal, "\nReading 32-bit memory content\n");
      logMessage(Normal, " Size : %d Bytes\n", size);
      logMessage(Normal, " Address: : 0x%08X\n", startAddress);
      int i = 0, col=0;
      while ((i<size))
      {
      col = 0;
      logMessage(Normal, "\n0x%08X :", startAddress + i);
      while ((col<4) && (i<size))
      {
      logMessage(Info, " %08X ", *(unsigned int *)(dataStruct + i));
      col++;
      i += 4;
      }
      }
      logMessage(Normal, "\n");
      /* Sector Erase */
      unsigned int sectors[4] = { 0, 1, 2, 3 }; // we suppose that we have 4 sectors
      int sectorEraseFlag = sectorErase(sectors, 1); // we will erase just the first sector
      if (sectorEraseFlag != 0)
      {
      disconnect();
      continue;
      }
      /* Reading 64 bytes from 0x08000000 */
      i = 0, col = 0;
      size = 64;
      dataStruct = 0;
      readMemoryFlag = readMemory(startAddress, &dataStruct, size);
      if (readMemoryFlag != 0)
      {
      disconnect();
      continue;
      }
      logMessage(Normal, "\nReading 32-bit memory content\n");
      logMessage(Normal, " Size : %d Bytes\n", size);
      logMessage(Normal, " Address: : 0x%08X\n", startAddress);
      while ((i<size))
      {
      col = 0;
      logMessage(Normal, "\n0x%08X :", startAddress + i);
      while ((col<4) && (i<size))
      {
      logMessage(Info, " %08X ", *(unsigned int *)(dataStruct + i));
      col++;
      i += 4;
      }
      }
      logMessage(Normal, "\n");
      /* Apply a System Reset */
      int resetFlag = reset(SOFTWARE_RESET);
      if (resetFlag != 0)
      {
      logMessage(Error, "\nUnable to reset MCU!\n");
      disconnect();
      continue;
      }
      else
      logMessage(GreenInfo, "\nSystem Reset is performed\n");
      /* Process successfully Done */
      disconnect();
      }
      deleteInterfaceList();
      return 1;
      }


STM32CubeProgrammer API: STLINK_Example2

STLINK_Example2

This example allows to execute some operations to the internal STM32 Flash memory.

  1. Detect connected ST-LINK and display them.
  2. Loop on each St-LINK probes and execute the following operations:
    • File programming + verification step.
    • Read 256 bytes from the address 0x08000000.
    • Run application.
      /
      #include <Example2.h>
      #include <DisplayManager.h>
      #include <CubeProgrammer_API.h>
      int Example2(void) {
      logMessage(Title, "\n+++ Example 2 +++\n");
      debugConnectParameters *stLinkList;
      debugConnectParameters debugParameters;
      generalInf* genInfo;
      int getStlinkListNb = getStLinkList(&stLinkList, 0);
      if (getStlinkListNb == 0)
      {
      logMessage(Error, "No STLINK available\n");
      return 0;
      }
      else {
      logMessage(Title, "\n-------- Connected ST-LINK Probes List --------");
      for (int i = 0; i < getStlinkListNb; i++)
      {
      logMessage(Normal, "\nST-LINK Probe %d :\n", i);
      logMessage(Info, " ST-LINK SN : %s \n", stLinkList[i].serialNumber);
      logMessage(Info, " ST-LINK FW : %s \n", stLinkList[i].firmwareVersion);
      }
      logMessage(Title, "-----------------------------------------------\n\n");
      }
      for (int index = 0; index < getStlinkListNb; index++) {
      logMessage(Title, "\n--------------------- ");
      logMessage(Title, "\n ST-LINK Probe : %d ", index);
      logMessage(Title, "\n--------------------- \n\n");
      debugParameters = stLinkList[index];
      debugParameters.connectionMode = UNDER_RESET_MODE;
      debugParameters.shared = 0;
      /* Target connect */
      int connectStlinkFlag = connectStLink(debugParameters);
      if (connectStlinkFlag != 0) {
      logMessage(Error, "Establishing connection with the device failed\n");
      disconnect();
      continue;
      }
      else {
      logMessage(GreenInfo, "\n--- Device %d Connected --- \n", index);
      }
      /* Display device informations */
      genInfo = getDeviceGeneralInf();
      logMessage(Normal, "\nDevice name : %s ", genInfo->name);
      logMessage(Normal, "\nDevice type : %s ", genInfo->type);
      logMessage(Normal, "\nDevice CPU : %s \n", genInfo->cpu);
      /* Download File + verification */
      #ifdef _WIN32
      const wchar_t* filePath = L"../test file/data.hex";
      #else
      const wchar_t* filePath = L"../api/test file/data.hex";
      #endif
      unsigned int isVerify = 1; //add verification step
      unsigned int isSkipErase = 0; // no skip erase
      int downloadFileFlag = downloadFile(filePath, 0x08000000, isSkipErase, isVerify, L"");
      if (downloadFileFlag != 0)
      {
      disconnect();
      continue;
      }
      /* Reading 256 bytes from 0x08000000 */
      unsigned char* dataStruct = 0;
      int size = 256;
      int startAddress = 0x08000000;
      int readMemoryFlag = readMemory(startAddress, &dataStruct, size);
      if (readMemoryFlag != 0)
      {
      disconnect();
      continue;
      }
      logMessage(Normal, "\nReading 32-bit memory content\n");
      logMessage(Normal, " Size : %d Bytes\n", size);
      logMessage(Normal, " Address: : 0x%08X\n", startAddress);
      int i = 0, col = 0;
      while ((i<size))
      {
      col = 0;
      logMessage(Normal, "\n0x%08X :", startAddress+i);
      while ((col<4) && (i<size))
      {
      logMessage(Info, " %08X ", *(unsigned int *)(dataStruct + i));
      col++;
      i += 4;
      }
      }
      logMessage(Normal, "\n");
      /* Run application */
      int executeFlag = execute(0x08000000);
      if (executeFlag != 0)
      {
      disconnect();
      continue;
      }
      /* The system will lose the connection with bootloader when it is in running mode */
      /* Process successfully Done */
      disconnect();
      }
      deleteInterfaceList();
      return 1;
      }


STM32CubeProgrammer API: STLINK_Example3

STLINK_Example3

This example allows to execute some operations to the internal STM32 Flash memory.

  1. Detect connected ST-LINK and display them.
  2. Loop on each St-LINK probes and execute the following operations:
    • File programming + verification step.
    • Set RDP level.
    • Display option bytes.
    • Disable readout protection.
    • Display option bytes.
    • System Reset.
      /
      #include <Example3.h>
      #include <DisplayManager.h>
      #include <CubeProgrammer_API.h>
      int Example3(void) {
      logMessage(Title, "\n+++ Example 3 +++\n");
      debugConnectParameters *stLinkList;
      debugConnectParameters debugParameters;
      generalInf* genInfo;
      int getStlinkListNb = getStLinkList(&stLinkList, 0);
      if (getStlinkListNb == 0)
      {
      logMessage(Error, "No STLINK available\n");
      return 0;
      }
      else {
      logMessage(Title, "\n-------- Connected ST-LINK Probes List --------");
      for (int i = 0; i < getStlinkListNb; i++)
      {
      logMessage(Normal, "\nST-LINK Probe %d :\n", i);
      logMessage(Info, " ST-LINK SN : %s \n", stLinkList[i].serialNumber);
      logMessage(Info, " ST-LINK FW : %s \n", stLinkList[i].firmwareVersion);
      }
      logMessage(Title, "-----------------------------------------------\n\n");
      }
      for (int index = 0; index < getStlinkListNb; index++) {
      logMessage(Title, "\n--------------------- ");
      logMessage(Title, "\n ST-LINK Probe : %d ", index);
      logMessage(Title, "\n--------------------- \n\n");
      debugParameters = stLinkList[index];
      debugParameters.connectionMode = UNDER_RESET_MODE;
      debugParameters.shared = 0;
      /* Target connect */
      int connectStlinkFlag = connectStLink(debugParameters); //try to connect
      if (connectStlinkFlag != 0) {
      logMessage(Error, "Establishing connection with the device failed\n");
      continue;
      }
      else {
      logMessage(GreenInfo, "\n--- Device %d Connected --- \n", index);
      }
      /* Display device informations */
      genInfo = getDeviceGeneralInf();
      logMessage(Normal, "\nDevice name : %s ", genInfo->name);
      logMessage(Normal, "\nDevice type : %s ", genInfo->type);
      logMessage(Normal, "\nDevice CPU : %s \n", genInfo->cpu);
      logMessage(Normal, "\n");
      /* Download file + verification */
      #ifdef _WIN32
      const wchar_t* filePath = L"../test file/data.hex";
      #else
      const wchar_t* filePath = L"../api/test file/data.hex";
      #endif
      unsigned int isVerify = 1; //add verification step
      unsigned int isSkipErase = 0; // no skip erase
      int downloadFileFlag = downloadFile(filePath, 0x08000000, isSkipErase, isVerify, L"");
      if (downloadFileFlag != 0)
      {
      disconnect();
      continue;
      }
      /* Set rdp option byte */
      int sendOptionBytesCmdFlag = sendOptionBytesCmd((char*)"-ob rdp=0xbb");
      if (sendOptionBytesCmdFlag != 0)
      {
      disconnect();
      continue;
      }
      /* Display option bytes */
      peripheral_C* ob;
      ob = initOptionBytesInterface();
      if (ob == 0)
      {
      disconnect();
      continue;
      }
      for (unsigned int i = 0; i < ob->banksNbr; i++)
      {
      logMessage(Normal, "OPTION BYTES BANK: %d\n", i);
      for (unsigned int j = 0; j < ob->banks[i]->categoriesNbr; j++)
      {
      logMessage(Title, "\t%s\n", ob->banks[i]->categories[j]);
      for (unsigned int k = 0; k < ob->banks[i]->categories[j]->bitsNbr; k++)
      {
      if (ob->banks[i]->categories[j]->bits[k]->access == 0 || ob->banks[i]->categories[j]->bits[k]->access == 2) {
      logMessage(Normal, "\t\t%s", ob->banks[i]->categories[j]->bits[k]->name);
      logMessage(Info, ": 0x%x\n", ob->banks[i]->categories[j]->bits[k]->bitValue);
      }
      }
      }
      }
      /* Disable readout protection */
      int readUnprotectFlag = readUnprotect();
      if (readUnprotectFlag != 0)
      {
      disconnect();
      continue;
      }
      /* Display option bytes */
      ob = initOptionBytesInterface();
      if (ob == 0)
      {
      disconnect();
      continue;
      }
      for (unsigned int i = 0; i < ob->banksNbr; i++)
      {
      logMessage(Normal, "OPTION BYTES BANK: %d\n", i);
      for (unsigned int j = 0; j < ob->banks[i]->categoriesNbr; j++)
      {
      logMessage(Title, "\t%s\n", ob->banks[i]->categories[j]);
      for (unsigned int k = 0; k < ob->banks[i]->categories[j]->bitsNbr; k++)
      {
      if (ob->banks[i]->categories[j]->bits[k]->access == 0 || ob->banks[i]->categories[j]->bits[k]->access == 2) {
      logMessage(Normal, "\t\t%s", ob->banks[i]->categories[j]->bits[k]->name);
      logMessage(Info, ": 0x%x\n", ob->banks[i]->categories[j]->bits[k]->bitValue);
      }
      }
      }
      }
      /* Apply a System Reset */
      int resetFlag = reset(SOFTWARE_RESET);
      if (resetFlag != 0)
      {
      logMessage(Error, "\nUnable to reset MCU!\n");
      disconnect();
      continue;
      }
      else
      logMessage(GreenInfo, "\nSystem Reset is performed\n");
      /* Process successfully Done */
      disconnect();
      }
      deleteInterfaceList();
      return 1;
      }


STM32CubeProgrammer API: UART_Bootloader

UART_Bootloader

This example allows to connect to the target through UART Bootloader interface and execute some operations to the internal STM32 Flash memory.

  • Connect to the device via UART.
  • File programming + verification step.
  • Read 64 bytes from 0x08000000.
  • Option bytes programming : BOR level.
  • Display option bytes.
    /
    #include <UART_Example.h>
    #include <DisplayManager.h>
    #include <CubeProgrammer_API.h>
    int UART_Example(void) {
    logMessage(Title, "\n+++ UART Bootloader Example +++\n\n");
    generalInf* genInfo;
    usartConnectParameters *uartParam;
    int getUsartListFlag = getUsartList(&uartParam);
    if (getUsartListFlag == 0)
    {
    logMessage(Error, "NO Serial Port available\n");
    return 0;
    }
    else {
    logMessage(Title, "\n------------- Serial Port List --------------\n");
    for (int i = 0; i < getUsartListFlag; i++)
    {
    logMessage(Normal, "\nPort Name [%d] :", i);
    logMessage(Info, " %s ", uartParam[i].portName);
    }
    logMessage(Title, "\n---------------------------------------------\n\n");
    }
    /* Target connect, choose the adequate Serial port by indicating its index that is already mentioned in Serial Port List above */
    int uartConnectFlag = connectUsartBootloader(uartParam[0]);
    if (uartConnectFlag != 0)
    {
    disconnect();
    return 0;
    }
    else {
    logMessage(GreenInfo, "\n--- Device Connected --- \n");
    }
    /* Display device informations */
    genInfo = getDeviceGeneralInf();
    logMessage(Normal, "\nDevice name : %s ", genInfo->name);
    logMessage(Normal, "\nDevice type : %s ", genInfo->type);
    logMessage(Normal, "\nDevice CPU : %s \n", genInfo->cpu);
    /* Download File + verification */
    #ifdef _WIN32
    const wchar_t* filePath = L"../test file/data.hex";
    #else
    const wchar_t* filePath = L"../api/test file/data.hex";
    #endif
    unsigned int isVerify = 1; //add verification step
    unsigned int isSkipErase = 0; // no skip erase
    int downloadFileFlag = downloadFile(filePath, 0x08000000, isSkipErase, isVerify, L"");
    if (downloadFileFlag != 0)
    {
    disconnect();
    return 0;
    }
    /* Reading 64 bytes from 0x08000000 */
    int size = 64;
    int startAddress = 0x08000000;
    unsigned char* dataStruct = 0;
    int readMemoryFlag = readMemory(startAddress, &dataStruct, size);
    if (readMemoryFlag != 0)
    {
    disconnect();
    return 0;
    }
    logMessage(Normal, "\nReading 32-bit memory content\n");
    logMessage(Normal, " Size : %d Bytes\n", size);
    logMessage(Normal, " Address: : 0x%08X\n", startAddress);
    int i = 0, col = 0;
    while ((i<size))
    {
    col = 0;
    logMessage(Normal, "\n0x%08X :", startAddress + i);
    while ((col<4) && (i<size))
    {
    logMessage(Info, " %08X ", *(unsigned int *)(dataStruct + i));
    col++;
    i += 4;
    }
    }
    logMessage(Normal, "\n");
    /* Option bytes programming : BOR level */
    int sendOptionBytesCmdFlag = sendOptionBytesCmd((char*)"-ob BOR_LEV=1");
    if (sendOptionBytesCmdFlag != 0)
    {
    disconnect();
    return 0;
    }
    /* Display option bytes */
    peripheral_C* ob = initOptionBytesInterface();
    if (ob == 0)
    {
    disconnect();
    return 0;
    }
    for (unsigned int i = 0; i < ob->banksNbr; i++)
    {
    logMessage(Normal, "OPTION BYTES BANK: %d\n", i);
    for (unsigned int j = 0; j < ob->banks[i]->categoriesNbr; j++)
    {
    logMessage(Title, "\t%s\n", ob->banks[i]->categories[j]);
    for (unsigned int k = 0; k < ob->banks[i]->categories[j]->bitsNbr; k++)
    {
    if (ob->banks[i]->categories[j]->bits[k]->access == 0 || ob->banks[i]->categories[j]->bits[k]->access == 2) {
    logMessage(Normal, "\t\t%s", ob->banks[i]->categories[j]->bits[k]->name);
    logMessage(Info, ": 0x%x\n", ob->banks[i]->categories[j]->bits[k]->bitValue);
    }
    }
    }
    }
    /* Process successfully Done */
    disconnect();
    deleteInterfaceList();
    return 1;
    }


STM32CubeProgrammer API: USB_Bootloader

USB_Bootloader

This example allows to connect to the target through USB Bootloader interface and execute some operations to the internal STM32 Flash memory.

  • Connect to the device via USB interface.
  • File programming + verification step.
  • Read 64 bytes from 0x08000000.
  • Option bytes programming : BOR level.
  • Display option bytes.
    /
    #include <USB_Example.h>
    #include <DisplayManager.h>
    #include <CubeProgrammer_API.h>
    int USB_Example(void) {
    logMessage(Title, "\n+++ USB Bootloader Example +++\n\n");
    generalInf* genInfo;
    dfuDeviceInfo *dfuList;
    int getDfuListNb = getDfuDeviceList(&dfuList);
    if (getDfuListNb == 0)
    {
    logMessage(Error, "No USB DFU available\n");
    return 0;
    }
    else {
    logMessage(Title, "\n------------- USB DFU List --------------\n");
    for (int i = 0; i < getDfuListNb; i++)
    {
    logMessage(Normal, "USB Port %d \n",i);
    logMessage(Info, " USB index : %s \n", dfuList[i].usbIndex);
    logMessage(Info, " USB SN : %s \n", dfuList[i].serialNumber);
    logMessage(Info, " DFU version : 0x%02X ", dfuList[i].dfuVersion);
    }
    logMessage(Title, "\n-----------------------------------------\n\n");
    }
    /* Target connect, choose the adequate USB port by indicating its index that is already mentioned in USB DFU List above */
    int usbConnectFlag = connectDfuBootloader(dfuList[0].usbIndex);
    if (usbConnectFlag != 0)
    {
    disconnect();
    return 0;
    }
    else {
    logMessage(GreenInfo, "\n--- Device Connected --- \n");
    }
    /* Display device informations */
    genInfo = getDeviceGeneralInf();
    logMessage(Normal, "\nDevice name : %s ", genInfo->name);
    logMessage(Normal, "\nDevice type : %s ", genInfo->type);
    logMessage(Normal, "\nDevice CPU : %s \n", genInfo->cpu);
    /* Download File + verification */
    #ifdef _WIN32
    const wchar_t* filePath = L"../test file/data.hex";
    #else
    const wchar_t* filePath = L"../api/test file/data.hex";
    #endif
    unsigned int isVerify = 1; //add verification step
    unsigned int isSkipErase = 0; // no skip erase
    int downloadFileFlag = downloadFile(filePath, 0x08000000, isSkipErase, isVerify, L"");
    if (downloadFileFlag != 0)
    {
    disconnect();
    return 0;
    }
    /* Reading 64 bytes from 0x08000000 */
    int size = 64;
    int startAddress = 0x08000000;
    unsigned char* dataStruct = 0;
    int readMemoryFlag = readMemory(startAddress, &dataStruct, size);
    if (readMemoryFlag != 0)
    {
    disconnect();
    return 0;
    }
    logMessage(Normal, "\nReading 32-bit memory content\n");
    logMessage(Normal, " Size : %d Bytes\n", size);
    logMessage(Normal, " Address: : 0x%08X\n", startAddress);
    int i = 0, col = 0;
    while ((i<size))
    {
    col = 0;
    logMessage(Normal, "\n0x%08X :", startAddress + i);
    while ((col<4) && (i<size))
    {
    logMessage(Info, " %08X ", *(unsigned int *)(dataStruct + i));
    col++;
    i += 4;
    }
    }
    logMessage(Normal, "\n");
    /* Option bytes programming : BOR level */
    int sendOptionBytesCmdFlag = sendOptionBytesCmd((char*)"-ob BOR_LEV=1");
    if (sendOptionBytesCmdFlag != 0)
    {
    disconnect();
    return 0;
    }
    /* Display option bytes */
    peripheral_C* ob = initOptionBytesInterface();
    if (ob == 0)
    {
    disconnect();
    return 0;
    }
    for (unsigned int i = 0; i < ob->banksNbr; i++)
    {
    logMessage(Normal, "OPTION BYTES BANK: %d\n", i);
    for (unsigned int j = 0; j < ob->banks[i]->categoriesNbr; j++)
    {
    logMessage(Title, "\t%s\n", ob->banks[i]->categories[j]);
    for (unsigned int k = 0; k < ob->banks[i]->categories[j]->bitsNbr; k++)
    {
    if (ob->banks[i]->categories[j]->bits[k]->access == 0 || ob->banks[i]->categories[j]->bits[k]->access == 2) {
    logMessage(Normal, "\t\t%s", ob->banks[i]->categories[j]->bits[k]->name);
    logMessage(Info, ": 0x%x\n", ob->banks[i]->categories[j]->bits[k]->bitValue);
    }
    }
    }
    }
    /* Process successfully Done */
    disconnect();
    deleteInterfaceList();
    return 1;
    }


STM32CubeProgrammer API: files/CubeProgrammer_API.h Source File

  • files
CubeProgrammer_API.h
Go to the documentation of this file.
1 /* doxygen documentation */
88 #ifndef CUBEPROGRAMMER_API_H
89 #define CUBEPROGRAMMER_API_H
90
91 #ifdef __cplusplus
92 extern "C" {
93 #endif
94
95 #include <stdint.h>
96 #include "DeviceDataStructure.h"
97
98 #if (defined WIN32 || defined _WIN32 || defined WINCE)
99 # define CP_EXPORTS __declspec(dllexport)
100 #else
101 # define CP_EXPORTS
102 #endif
103
104
105 /* -------------------------------------------------------------------------------------------- */
106 /* Errors Enumerations */
107 /* -------------------------------------------------------------------------------------------- */
108
113 enum cubeProgrammerVerbosityLevel {
115 CUBEPROGRAMMER_VER_LEVEL_NONE = 0,
116
118 CUBEPROGRAMMER_VER_LEVEL_ONE = 1,
119
121 CUBEPROGRAMMER_VER_LEVEL_TWO = 2,
122
124 CUBEPROGRAMMER_VER_LEVEL_DEBUG = 3,
125
127 CUBEPROGRAMMER_NO_PROGRESS_BAR = 4, /* progress bars are printed only with verbosity level one */
128 };
129
130
135 enum cubeProgrammerError {
137 CUBEPROGRAMMER_NO_ERROR = 0,
138
140 CUBEPROGRAMMER_ERROR_NOT_CONNECTED = -1,
141
143 CUBEPROGRAMMER_ERROR_NO_DEVICE = -2,
144
146 CUBEPROGRAMMER_ERROR_CONNECTION = -3,
147
149 CUBEPROGRAMMER_ERROR_NO_FILE = -4,
150
152 CUBEPROGRAMMER_ERROR_NOT_SUPPORTED = -5,
153
155 CUBEPROGRAMMER_ERROR_INTERFACE_NOT_SUPPORTED = -6,
156
158 CUBEPROGRAMMER_ERROR_NO_MEM = -7,
159
161 CUBEPROGRAMMER_ERROR_WRONG_PARAM = -8,
162
164 CUBEPROGRAMMER_ERROR_READ_MEM = -9,
165
167 CUBEPROGRAMMER_ERROR_WRITE_MEM = -10,
168
170 CUBEPROGRAMMER_ERROR_ERASE_MEM = -11,
171
173 CUBEPROGRAMMER_ERROR_UNSUPPORTED_FILE_FORMAT = -12,
174
176 CUBEPROGRAMMER_ERROR_REFRESH_REQUIRED = -13,
177
179 CUBEPROGRAMMER_ERROR_NO_SECURITY = -14,
180
182 CUBEPROGRAMMER_ERROR_CHANGE_FREQ = -15,
183
184
185 /* NB: Remember to update CUBEPROGRAMMER_ERROR_COUNT below. */
186
188 CUBEPROGRAMMER_ERROR_OTHER = -99,
189 };
190
191
192 /* -------------------------------------------------------------------------------------------- */
193 /* Bootloader Data Structures and Enumerations */
194 /* -------------------------------------------------------------------------------------------- */
195
200 typedef enum usartParity
201 {
202 EVEN = 0,
203 ODD = 1,
204 NONE = 2,
205 }usartParity;
206
207
212 typedef enum usartFlowControl
213 {
214 OFF = 0,
215 HARDWARE = 1,
216 SOFTWARE = 2,
217 }usartFlowControl;
218
219
224 typedef struct dfuDeviceInfo
225 {
226 char usbIndex[10];
227 int busNumber;
228 int addressNumber;
229 char productId[100];
230 char serialNumber[100];
231 unsigned int dfuVersion;
232 }dfuDeviceInfo;
233
238 typedef struct usartConnectParameters
239 {
240 char portName[100];
241 unsigned int baudrate;
242 usartParity parity;
243 unsigned char dataBits;
244 float stopBits;
245 usartFlowControl flowControl;
246 unsigned char noinitBits;
248 }usartConnectParameters;
249
250
256 typedef struct spiConnectParameters
257 {
258 uint32_t baudrate ;
259 uint16_t crcPol ;
260 int direction ;
261 int cpha ;
262 int cpol ;
263 int crc ;
264 int firstBit ;
265 int frameFormat ;
266 int dataSize ;
267 int mode ;
268 int nss ;
269 int nssPulse ;
270 int delay ;
272 } spiConnectParameters;
273
274
281 typedef struct canConnectParameters
282 {
283 int br ;
284 int mode ;
285 int ide ;
286 int rtr ;
287 int fifo ;
288 int fm ;
289 int fs ;
290 int fe ;
291 char fbn ;
293 } canConnectParameters;
294
295
303 typedef struct i2cConnectParameters
304 {
305 int add ;
306 int br ;
307 int sm ;
308 int am ;
309 int af ;
310 int df ;
311 char dnf ;
312 int rt ;
313 int ft ;
315 } i2cConnectParameters;
316
317
318 /* -------------------------------------------------------------------------------------------- */
319 /* STLINK Data Structures and Enumerations */
320 /* -------------------------------------------------------------------------------------------- */
321
326 typedef enum debugResetMode
327 {
328 SOFTWARE_RESET,
329 HARDWARE_RESET,
330 CORE_RESET
331 }debugResetMode;
332
333
338 typedef enum debugConnectMode
339 {
340 NORMAL_MODE,
341 HOTPLUG_MODE,
342 UNDER_RESET_MODE,
343 PRE_RESET_MODE
344 }debugConnectMode;
345
346
351 typedef enum debugPort
352 {
353 JTAG = 0,
354 SWD = 1,
355 }debugPort;
356
357
362 typedef struct frequencies
363 {
364 unsigned int jtagFreq[12];
365 unsigned int jtagFreqNumber;
366 unsigned int swdFreq[12];
367 unsigned int swdFreqNumber;
368 }frequencies;
369
370
375 typedef struct debugConnectParameters
376 {
377 debugPort dbgPort;
378 int index;
379 char serialNumber[33];
380 char firmwareVersion[20];
381 char targetVoltage[5];
382 int accessPortNumber;
383 int accessPort;
384 debugConnectMode connectionMode;
385 debugResetMode resetMode;
386 int isOldFirmware;
387 frequencies freq;
388 int frequency;
389 int isBridge;
390 int shared;
391 }debugConnectParameters;
392
393
394 /* -------------------------------------------------------------------------------------------- */
395 /* General Data Structures and Enumerations */
396 /* -------------------------------------------------------------------------------------------- */
397
402 typedef enum targetInterfaceType
403 {
404 STLINK_INTERFACE = 0,
405 USART_INTERFACE = 1,
406 USB_INTERFACE = 2,
407 SPI_INTERFACE = 3,
408 I2C_INTERFACE = 4,
409 CAN_INTERFACE = 5
410 }targetInterfaceType;
411
412
417 typedef struct displayCallBacks
418 {
419 void (*initProgressBar)();
420 void (*logMessage)(int msgType, const wchar_t* str);
421 void (*loadBar)(int x, int n);
422 } displayCallBacks;
423
424
425 typedef struct segmentData_C
426 {
427 int address;
428 int size;
429 unsigned char* data;
430 }segmentData_C ;
431
432
437 typedef struct fileData_C
438 {
439 int Type;
440 int segmentsNbr;
441 segmentData_C* segments;
442 }fileData_C ;
443
444
449 typedef struct generalInf
450 {
451 unsigned short deviceId;
452 int flashSize;
453 char type[4];
454 char cpu[20];
455 char name[100];
456 char series[100];
457 char description[100];
458 }generalInf ;
459
460
461 /* -------------------------------------------------------------------------------------------- */
462 /* Loaders Data Structures */
463 /* -------------------------------------------------------------------------------------------- */
464
465
470 typedef struct deviceSector
471 {
472 uint32_t sectorNum;
473 uint32_t sectorSize;
474 }deviceSector;
475
476
481 typedef struct externalLoader{
482 char filePath[200];
483 char deviceName[100];
484 int deviceType;
485 uint32_t deviceStartAddress;
486 uint32_t deviceSize;
487 uint32_t pageSize;
488 // unsigned char EraseValue; /**< Content of Erased Memory. */
489 uint32_t sectorsTypeNbr;
490 deviceSector* sectors;
491 }externalLoader;
492
493
498 typedef struct externalStorageInfo
499 {
500 unsigned int externalLoaderNbr;
501 externalLoader* externalLoader;
502 }externalStorageInfo;
503
504
505 /* -------------------------------------------------------------------------------------------- */
506 /* STLINK functions */
507 /* -------------------------------------------------------------------------------------------- */
508
522 int getStLinkList(debugConnectParameters** stLinkList, int shared);
523
524
531 int connectStLink(debugConnectParameters debugParameters);
532
533
540 int reset(debugResetMode rstMode) ;
541
545 /* -------------------------------------------------------------------------------------------- */
546 /* Bootloader functions */
547 /* -------------------------------------------------------------------------------------------- */
548
560 int getUsartList(usartConnectParameters** usartList);
561
562
568 int connectUsartBootloader(usartConnectParameters usartParameters);
569
570
576 int sendByteUart(int byte);
577
578
585 int getDfuDeviceList(dfuDeviceInfo** dfuList);
586
587
593 int connectDfuBootloader(char* usbIndex);
594
595
601 int connectSpiBootloader(spiConnectParameters spiParameters);
602
603
610 int connectCanBootloader(canConnectParameters canParameters);
611
612
618 int connectI2cBootloader(i2cConnectParameters i2cParameters);
619
623 /* -------------------------------------------------------------------------------------------- */
624 /* General purposes functions */
625 /* -------------------------------------------------------------------------------------------- */
626
637 void setDisplayCallbacks(displayCallBacks c);
638
639
644 void setVerbosityLevel(int level);
645
646
651 int checkDeviceConnection();
652
653
658 generalInf* getDeviceGeneralInf();
659
660
669 int readMemory(unsigned int address, unsigned char** data, unsigned int size);
670
671
680 int writeMemory(unsigned int address, char* data, unsigned int size);
681
682
693 int downloadFile(const wchar_t* filePath, unsigned int address, unsigned int skipErase, unsigned int verify, const wchar_t* binPath);
694
695
702 int execute(unsigned int address);
703
704
710 int massErase();
711
712
720 int sectorErase(unsigned int sectors[],unsigned int sectorNbr);
721
722
730 int readUnprotect();
731
732
737 int getTargetInterfaceType();
738
739
744 volatile int* getCancelPointer();
745
746
752 void *fileOpen(const wchar_t* filePath);
753
754
759 void freeFileData(fileData_C* data);
760
761
768 int verify(fileData_C* fileData, unsigned int address);
769
770
777 int saveFileToFile(fileData_C *fileData, const wchar_t* sFileName);
778
779
788 int saveMemoryToFile(int address, int size, const wchar_t* sFileName);
789
790
795 void disconnect();
796
797
802 void deleteInterfaceList();
803
804
816 void automaticMode(const wchar_t* filePath, unsigned int address, unsigned int skipErase, unsigned int verify, int isMassErase, char* obCommand, int run);
817
818
822 /* -------------------------------------------------------------------------------------------- */
823 /* Option Bytes functions */
824 /* -------------------------------------------------------------------------------------------- */
825
842 int sendOptionBytesCmd(char* command);
843
844
849 peripheral_C* initOptionBytesInterface();
850
854 /* -------------------------------------------------------------------------------------------- */
855 /* Loaders functions */
856 /* -------------------------------------------------------------------------------------------- */
857
858
869 void setLoadersPath(const char* path);
870
871
877 void setExternalLoaderPath(const char* path, externalLoader** externalLoaderInfo);
878
879
887 int getExternalLoaders(const char* path, externalStorageInfo** externalStorageNfo);
888
889
894 void removeExternalLoader(const char* path);
895
896
900 void deleteLoaders();
901
906 #ifdef __cplusplus
907 }
908 #endif
909
910
911
912 #endif // CUBEPROGRAMMER_API_H
i2cConnectParameters::am
int am
Definition: CubeProgrammer_API.h:308
connectDfuBootloader
int connectDfuBootloader(char *usbIndex)
This routine allows to start connection to device through USB DFU interface.
CUBEPROGRAMMER_VER_LEVEL_DEBUG
Definition: CubeProgrammer_API.h:124
canConnectParameters
struct canConnectParameters canConnectParameters
dfuDeviceInfo::productId
char productId[100]
Definition: CubeProgrammer_API.h:229
externalStorageInfo::externalLoaderNbr
unsigned int externalLoaderNbr
Definition: CubeProgrammer_API.h:500
removeExternalLoader
void removeExternalLoader(const char *path)
This routine allows to unload an external Loaders.
CUBEPROGRAMMER_VER_LEVEL_TWO
Definition: CubeProgrammer_API.h:121
i2cConnectParameters
Specify the I2C connect parameters.
Definition: CubeProgrammer_API.h:303
externalLoader::deviceStartAddress
uint32_t deviceStartAddress
Definition: CubeProgrammer_API.h:485
usartConnectParameters::parity
usartParity parity
Definition: CubeProgrammer_API.h:242
CUBEPROGRAMMER_ERROR_NOT_CONNECTED
Definition: CubeProgrammer_API.h:140
i2cConnectParameters
struct i2cConnectParameters i2cConnectParameters
SWD
Definition: CubeProgrammer_API.h:354
SOFTWARE
Definition: CubeProgrammer_API.h:216
spiConnectParameters::cpha
int cpha
Definition: CubeProgrammer_API.h:261
CUBEPROGRAMMER_ERROR_ERASE_MEM
Definition: CubeProgrammer_API.h:170
spiConnectParameters::nssPulse
int nssPulse
Definition: CubeProgrammer_API.h:269
USART_INTERFACE
Definition: CubeProgrammer_API.h:405
generalInf::deviceId
unsigned short deviceId
Definition: CubeProgrammer_API.h:451
setExternalLoaderPath
void setExternalLoaderPath(const char *path, externalLoader **externalLoaderInfo)
This routine allows to specify the path of the external Loaders to be loaded.
deleteInterfaceList
void deleteInterfaceList()
This routine allows to clear the list of each created interface.
generalInf
struct generalInf generalInf
segmentData_C::data
unsigned char * data
Definition: CubeProgrammer_API.h:429
HOTPLUG_MODE
Definition: CubeProgrammer_API.h:341
debugConnectParameters
struct debugConnectParameters debugConnectParameters
getTargetInterfaceType
int getTargetInterfaceType()
This routine allows to know the interface what is in use.
debugConnectParameters::accessPortNumber
int accessPortNumber
Definition: CubeProgrammer_API.h:382
frequencies
Get supported frequencies for JTAG and SWD ineterfaces.
Definition: CubeProgrammer_API.h:362
cubeProgrammerError
cubeProgrammerError
List of errors that can be occured.
Definition: CubeProgrammer_API.h:135
externalLoader
struct externalLoader externalLoader
CORE_RESET
Definition: CubeProgrammer_API.h:330
execute
int execute(unsigned int address)
This routine allows to run the application.
externalLoader::sectorsTypeNbr
uint32_t sectorsTypeNbr
Definition: CubeProgrammer_API.h:489
i2cConnectParameters::br
int br
Definition: CubeProgrammer_API.h:306
usartConnectParameters::dataBits
unsigned char dataBits
Definition: CubeProgrammer_API.h:243
dfuDeviceInfo
struct dfuDeviceInfo dfuDeviceInfo
segmentData_C
Definition: CubeProgrammer_API.h:425
CUBEPROGRAMMER_ERROR_NO_SECURITY
Definition: CubeProgrammer_API.h:179
spiConnectParameters::dataSize
int dataSize
Definition: CubeProgrammer_API.h:266
dfuDeviceInfo::addressNumber
int addressNumber
Definition: CubeProgrammer_API.h:228
massErase
int massErase()
This routine allows to erase the whole Flash memory.
externalLoader::filePath
char filePath[200]
Definition: CubeProgrammer_API.h:482
fileData_C::segments
segmentData_C * segments
Definition: CubeProgrammer_API.h:441
deviceSector::sectorNum
uint32_t sectorNum
Definition: CubeProgrammer_API.h:472
automaticMode
void automaticMode(const wchar_t *filePath, unsigned int address, unsigned int skipErase, unsigned int verify, int isMassErase, char *obCommand, int run)
This routine allows to enter and make an automatic process for memory management through JTAG/SWD...
spiConnectParameters::baudrate
uint32_t baudrate
Definition: CubeProgrammer_API.h:258
usartConnectParameters::stopBits
float stopBits
Definition: CubeProgrammer_API.h:244
CUBEPROGRAMMER_ERROR_READ_MEM
Definition: CubeProgrammer_API.h:164
dfuDeviceInfo::usbIndex
char usbIndex[10]
Definition: CubeProgrammer_API.h:226
freeFileData
void freeFileData(fileData_C *data)
This routine allows to clean up the handled file data.
sendByteUart
int sendByteUart(int byte)
This routine allows to send a single byte through the USART interface.
debugConnectMode
debugConnectMode
Choose the appropriate mode for connection.
Definition: CubeProgrammer_API.h:338
canConnectParameters::fifo
int fifo
Definition: CubeProgrammer_API.h:287
CUBEPROGRAMMER_ERROR_OTHER
Definition: CubeProgrammer_API.h:188
CUBEPROGRAMMER_ERROR_CONNECTION
Definition: CubeProgrammer_API.h:146
CUBEPROGRAMMER_VER_LEVEL_ONE
Definition: CubeProgrammer_API.h:118
JTAG
Definition: CubeProgrammer_API.h:353
segmentData_C::size
int size
Definition: CubeProgrammer_API.h:428
frequencies::jtagFreqNumber
unsigned int jtagFreqNumber
Definition: CubeProgrammer_API.h:365
connectUsartBootloader
int connectUsartBootloader(usartConnectParameters usartParameters)
This routine allows to start connection to device through USART interface.
debugConnectParameters::index
int index
Definition: CubeProgrammer_API.h:378
getExternalLoaders
int getExternalLoaders(const char *path, externalStorageInfo **externalStorageNfo)
This routine allows to get available external Loaders in th mentioned path.
NONE
Definition: CubeProgrammer_API.h:204
getStLinkList
int getStLinkList(debugConnectParameters **stLinkList, int shared)
This routine allows to get ST-LINK conneted probe(s).
debugConnectParameters::accessPort
int accessPort
Definition: CubeProgrammer_API.h:383
NORMAL_MODE
Definition: CubeProgrammer_API.h:340
SPI_INTERFACE
Definition: CubeProgrammer_API.h:407
deleteLoaders
void deleteLoaders()
This routine allows to delete all target Flash Loaders.
generalInf::description
char description[100]
Definition: CubeProgrammer_API.h:457
externalLoader::deviceType
int deviceType
Definition: CubeProgrammer_API.h:484
disconnect
void disconnect()
This routine allows to clean up and disconnect the current connected target.
debugConnectParameters
Get device characterization and specify connection parameters through ST-LINK interface.
Definition: CubeProgrammer_API.h:375
segmentData_C
struct segmentData_C segmentData_C
externalStorageInfo
Get external storage informations useful for external Loader.
Definition: CubeProgrammer_API.h:498
usartConnectParameters
struct usartConnectParameters usartConnectParameters
displayCallBacks::loadBar
void(* loadBar)(int x, int n)
Definition: CubeProgrammer_API.h:421
segmentData_C::address
int address
Definition: CubeProgrammer_API.h:427
readUnprotect
int readUnprotect()
This routine allows to disable the readout protection. If the memory is not protected, a message appears to indicate that the device is not under Readout protection and the command has no effects.
spiConnectParameters::crcPol
uint16_t crcPol
Definition: CubeProgrammer_API.h:259
usartConnectParameters::portName
char portName[100]
Definition: CubeProgrammer_API.h:240
debugConnectParameters::freq
frequencies freq
Definition: CubeProgrammer_API.h:387
setDisplayCallbacks
void setDisplayCallbacks(displayCallBacks c)
This routine allows to choose your custom display.
setVerbosityLevel
void setVerbosityLevel(int level)
This routine allows to choose the verbosity level for display.
usartConnectParameters
Specify the USART connect parameters.
Definition: CubeProgrammer_API.h:238
dfuDeviceInfo
Get DFU device informations .
Definition: CubeProgrammer_API.h:224
spiConnectParameters::nss
int nss
Definition: CubeProgrammer_API.h:268
reset
int reset(debugResetMode rstMode)
This routine used to apply a target reset.
PRE_RESET_MODE
Definition: CubeProgrammer_API.h:343
externalStorageInfo::externalLoader
externalLoader * externalLoader
Definition: CubeProgrammer_API.h:501
peripheral_C
Get peripheral option bytes general informations.
Definition: DeviceDataStructure.h:128
CUBEPROGRAMMER_ERROR_WRITE_MEM
Definition: CubeProgrammer_API.h:167
i2cConnectParameters::dnf
char dnf
Definition: CubeProgrammer_API.h:311
CUBEPROGRAMMER_VER_LEVEL_NONE
Definition: CubeProgrammer_API.h:115
spiConnectParameters::delay
int delay
Definition: CubeProgrammer_API.h:270
canConnectParameters
Specify the CAN connect parameters.
Definition: CubeProgrammer_API.h:281
ODD
Definition: CubeProgrammer_API.h:203
canConnectParameters::fm
int fm
Definition: CubeProgrammer_API.h:288
externalLoader::deviceSize
uint32_t deviceSize
Definition: CubeProgrammer_API.h:486
DeviceDataStructure.h
CUBEPROGRAMMER_NO_PROGRESS_BAR
Definition: CubeProgrammer_API.h:127
frequencies::swdFreq
unsigned int swdFreq[12]
Definition: CubeProgrammer_API.h:366
HARDWARE
Definition: CubeProgrammer_API.h:215
displayCallBacks::initProgressBar
void(* initProgressBar)()
Definition: CubeProgrammer_API.h:419
getDfuDeviceList
int getDfuDeviceList(dfuDeviceInfo **dfuList)
This routine allows to get connected DFU devices.
CUBEPROGRAMMER_ERROR_WRONG_PARAM
Definition: CubeProgrammer_API.h:161
displayCallBacks::logMessage
void(* logMessage)(int msgType, const wchar_t *str)
Definition: CubeProgrammer_API.h:420
deviceSector
struct deviceSector deviceSector
connectStLink
int connectStLink(debugConnectParameters debugParameters)
This routine allows to start connection to device through SWD or JTAG interfaces. ...
targetInterfaceType
targetInterfaceType
Indicates the supported interfaces.
Definition: CubeProgrammer_API.h:402
usartConnectParameters::baudrate
unsigned int baudrate
Definition: CubeProgrammer_API.h:241
STLINK_INTERFACE
Definition: CubeProgrammer_API.h:404
getCancelPointer
volatile int * getCancelPointer()
This routine allows to drop the current read/write operation.
CUBEPROGRAMMER_NO_ERROR
Definition: CubeProgrammer_API.h:137
debugConnectParameters::connectionMode
debugConnectMode connectionMode
Definition: CubeProgrammer_API.h:384
fileData_C
struct fileData_C fileData_C
spiConnectParameters::frameFormat
int frameFormat
Definition: CubeProgrammer_API.h:265
debugConnectParameters::isOldFirmware
int isOldFirmware
Definition: CubeProgrammer_API.h:386
CUBEPROGRAMMER_ERROR_NO_DEVICE
Definition: CubeProgrammer_API.h:143
getDeviceGeneralInf
generalInf * getDeviceGeneralInf()
This routine allows to get general device informations.
debugConnectParameters::serialNumber
char serialNumber[33]
Definition: CubeProgrammer_API.h:379
CUBEPROGRAMMER_ERROR_UNSUPPORTED_FILE_FORMAT
Definition: CubeProgrammer_API.h:173
generalInf::name
char name[100]
Definition: CubeProgrammer_API.h:455
cubeProgrammerVerbosityLevel
cubeProgrammerVerbosityLevel
List of verbosity levels.
Definition: CubeProgrammer_API.h:113
usartConnectParameters::flowControl
usartFlowControl flowControl
Definition: CubeProgrammer_API.h:245
connectSpiBootloader
int connectSpiBootloader(spiConnectParameters spiParameters)
This routine allows to start connection to device through SPI interface.
dfuDeviceInfo::busNumber
int busNumber
Definition: CubeProgrammer_API.h:227
I2C_INTERFACE
Definition: CubeProgrammer_API.h:408
saveMemoryToFile
int saveMemoryToFile(int address, int size, const wchar_t *sFileName)
This routine allows to save Flash memory content to file.
displayCallBacks
Functions must be implemented to personalize the display of messages.
Definition: CubeProgrammer_API.h:417
debugConnectParameters::shared
int shared
Definition: CubeProgrammer_API.h:390
CUBEPROGRAMMER_ERROR_CHANGE_FREQ
Definition: CubeProgrammer_API.h:182
debugResetMode
debugResetMode
Choose the way to apply a system reset.
Definition: CubeProgrammer_API.h:326
HARDWARE_RESET
Definition: CubeProgrammer_API.h:329
debugConnectParameters::isBridge
int isBridge
Definition: CubeProgrammer_API.h:389
displayCallBacks
struct displayCallBacks displayCallBacks
i2cConnectParameters::rt
int rt
Definition: CubeProgrammer_API.h:312
CUBEPROGRAMMER_ERROR_REFRESH_REQUIRED
Definition: CubeProgrammer_API.h:176
connectCanBootloader
int connectCanBootloader(canConnectParameters canParameters)
This routine allows to start connection to device through CAN interface.
checkDeviceConnection
int checkDeviceConnection()
This routine allows to check connection status [maintained or lost].
canConnectParameters::ide
int ide
Definition: CubeProgrammer_API.h:285
OFF
Definition: CubeProgrammer_API.h:214
fileData_C::Type
int Type
Definition: CubeProgrammer_API.h:439
spiConnectParameters::crc
int crc
Definition: CubeProgrammer_API.h:263
fileData_C::segmentsNbr
int segmentsNbr
Definition: CubeProgrammer_API.h:440
spiConnectParameters::cpol
int cpol
Definition: CubeProgrammer_API.h:262
debugConnectParameters::targetVoltage
char targetVoltage[5]
Definition: CubeProgrammer_API.h:381
debugPort
debugPort
Select the debug port interface for connection.
Definition: CubeProgrammer_API.h:351
i2cConnectParameters::df
int df
Definition: CubeProgrammer_API.h:310
dfuDeviceInfo::serialNumber
char serialNumber[100]
Definition: CubeProgrammer_API.h:230
externalLoader::sectors
deviceSector * sectors
Definition: CubeProgrammer_API.h:490
sendOptionBytesCmd
int sendOptionBytesCmd(char *command)
This routine allows program the given Option Byte. The option bytes are configured by the end user de...
frequencies::swdFreqNumber
unsigned int swdFreqNumber
Definition: CubeProgrammer_API.h:367
usartConnectParameters::noinitBits
unsigned char noinitBits
Definition: CubeProgrammer_API.h:246
debugConnectParameters::frequency
int frequency
Definition: CubeProgrammer_API.h:388
i2cConnectParameters::af
int af
Definition: CubeProgrammer_API.h:309
readMemory
int readMemory(unsigned int address, unsigned char **data, unsigned int size)
This routine allows to receive memory data on the used interface with the configration already initia...
debugConnectParameters::firmwareVersion
char firmwareVersion[20]
Definition: CubeProgrammer_API.h:380
EVEN
Definition: CubeProgrammer_API.h:202
saveFileToFile
int saveFileToFile(fileData_C *fileData, const wchar_t *sFileName)
This routine allows to save the data file content to another file.
spiConnectParameters
struct spiConnectParameters spiConnectParameters
externalLoader
Get external Loader parameters to launch the process of programming an external flash memory...
Definition: CubeProgrammer_API.h:481
i2cConnectParameters::ft
int ft
Definition: CubeProgrammer_API.h:313
generalInf::cpu
char cpu[20]
Definition: CubeProgrammer_API.h:454
canConnectParameters::br
int br
Definition: CubeProgrammer_API.h:283
deviceSector::sectorSize
uint32_t sectorSize
Definition: CubeProgrammer_API.h:473
sectorErase
int sectorErase(unsigned int sectors[], unsigned int sectorNbr)
This routine allows to erase specific sectors of the Flash memory.
usartFlowControl
usartFlowControl
UART Flow Control is a method for devices to communicate with each other over UART without the risk o...
Definition: CubeProgrammer_API.h:212
frequencies
struct frequencies frequencies
externalStorageInfo
struct externalStorageInfo externalStorageInfo
canConnectParameters::fs
int fs
Definition: CubeProgrammer_API.h:289
externalLoader::pageSize
uint32_t pageSize
Definition: CubeProgrammer_API.h:487
generalInf
Definition: CubeProgrammer_API.h:449
deviceSector
Get device sectors basic informations.
Definition: CubeProgrammer_API.h:470
getUsartList
int getUsartList(usartConnectParameters **usartList)
This routine allows to get connected serial ports.
frequencies::jtagFreq
unsigned int jtagFreq[12]
Definition: CubeProgrammer_API.h:364
spiConnectParameters::mode
int mode
Definition: CubeProgrammer_API.h:267
usartParity
usartParity
The parity bit in the data frame of the USART communication tells the receiving device if there is an...
Definition: CubeProgrammer_API.h:200
writeMemory
int writeMemory(unsigned int address, char *data, unsigned int size)
This routine allows to write memory data on the user interface with the configration already initiali...
generalInf::series
char series[100]
Definition: CubeProgrammer_API.h:456
fileData_C
Definition: CubeProgrammer_API.h:437
canConnectParameters::rtr
int rtr
Definition: CubeProgrammer_API.h:286
CUBEPROGRAMMER_ERROR_NO_MEM
Definition: CubeProgrammer_API.h:158
CUBEPROGRAMMER_ERROR_INTERFACE_NOT_SUPPORTED
Definition: CubeProgrammer_API.h:155
i2cConnectParameters::sm
int sm
Definition: CubeProgrammer_API.h:307
CAN_INTERFACE
Definition: CubeProgrammer_API.h:409
CUBEPROGRAMMER_ERROR_NOT_SUPPORTED
Definition: CubeProgrammer_API.h:152
canConnectParameters::fbn
char fbn
Definition: CubeProgrammer_API.h:291
SOFTWARE_RESET
Definition: CubeProgrammer_API.h:328
dfuDeviceInfo::dfuVersion
unsigned int dfuVersion
Definition: CubeProgrammer_API.h:231
setLoadersPath
void setLoadersPath(const char *path)
This routine allows to specify the location of Flash Loader.
fileOpen
void * fileOpen(const wchar_t *filePath)
This routine allows to open and get data from any supported file extension.
debugConnectParameters::dbgPort
debugPort dbgPort
Definition: CubeProgrammer_API.h:377
i2cConnectParameters::add
int add
Definition: CubeProgrammer_API.h:305
canConnectParameters::mode
int mode
Definition: CubeProgrammer_API.h:284
spiConnectParameters
Specify the SPI connect parameters.
Definition: CubeProgrammer_API.h:256
initOptionBytesInterface
peripheral_C * initOptionBytesInterface()
This routine allows to get option bytes values of the connected target.
externalLoader::deviceName
char deviceName[100]
Definition: CubeProgrammer_API.h:483
USB_INTERFACE
Definition: CubeProgrammer_API.h:406
downloadFile
int downloadFile(const wchar_t *filePath, unsigned int address, unsigned int skipErase, unsigned int verify, const wchar_t *binPath)
This routine allows to download data from a file to the memory. File formats that are supported : hex...
UNDER_RESET_MODE
Definition: CubeProgrammer_API.h:342
generalInf::type
char type[4]
Definition: CubeProgrammer_API.h:453
debugConnectParameters::resetMode
debugResetMode resetMode
Definition: CubeProgrammer_API.h:385
connectI2cBootloader
int connectI2cBootloader(i2cConnectParameters i2cParameters)
This routine allows to start connection to device through I2C interface.
canConnectParameters::fe
int fe
Definition: CubeProgrammer_API.h:290
generalInf::flashSize
int flashSize
Definition: CubeProgrammer_API.h:452
spiConnectParameters::firstBit
int firstBit
Definition: CubeProgrammer_API.h:264
CUBEPROGRAMMER_ERROR_NO_FILE
Definition: CubeProgrammer_API.h:149
verify
int verify(fileData_C *fileData, unsigned int address)
This routine allows to verfiy if the indicated file data is identical to Flash memory content...
spiConnectParameters::direction
int direction
Definition: CubeProgrammer_API.h:260


STM32CubeProgrammer API: files/DeviceDataStructure.h Source File

  • files
DeviceDataStructure.h
Go to the documentation of this file.
1 #ifndef DEVICEDATASTRUCTURE
2 #define DEVICEDATASTRUCTURE
3
4
5 #ifdef __cplusplus
6 extern "C" {
7 #endif
8
9 #define R_ACCESS 0x0
10 #define W_ACCESS 0x1
11 #define RW_ACCESS 0x2
12 #define RWE_ACCESS 0x3
13
14
15 /* -------------------------------------------------------------------------------------------- */
16 /* OB Data Structures */
17 /* -------------------------------------------------------------------------------------------- */
18
19
24 typedef struct bankSector
25 {
26 unsigned int index ;
27 unsigned int size ;
28 unsigned int address ;
29 }bankSector;
30
31
36 typedef struct deviceBank
37 {
38 unsigned int sectorsNumber;
39 bankSector* sectors;
40 }deviceBank;
41
42
47 typedef struct storageStructure
48 {
49 unsigned int banksNumber;
50 deviceBank* banks;
51 }storageStructure;
52
53
58 typedef struct bitCoefficient_C
59 {
60 unsigned int multiplier;
61 unsigned int offset;
62 }bitCoefficient_C;
63
64
69 typedef struct bitValue_C
70 {
71 unsigned int value;
72 char description[200];
73 }bitValue_C;
74
75
81 typedef struct bit_C
82 {
83 char name[32];
84 char description[300];
85 unsigned int wordOffset;
86 unsigned int bitOffset;
87 unsigned int bitWidth;
88 unsigned char access;
89 unsigned int valuesNbr;
90 bitValue_C** values;
91 bitCoefficient_C equation;
92 unsigned char* reference;
93 unsigned int bitValue;
94 }bit_C;
95
96
101 typedef struct category_C
102 {
103 char name[100];
104 unsigned int bitsNbr;
105 bit_C** bits;
106 }category_C;
107
108
114 typedef struct bank_C
115 {
116 unsigned int size;
117 unsigned int address;
118 unsigned char access;
119 unsigned int categoriesNbr;
120 category_C** categories;
121 }bank_C;
122
123
128 typedef struct peripheral_C
129 {
130 char name[32];
131 char description[200];
132 unsigned int banksNbr;
133 bank_C** banks;
134 }peripheral_C;
135
136
137
138 #ifdef __cplusplus
139 }
140 #endif
141
142
143 #endif // DEVICEDATASTRUCTURE
144
storageStructure::banksNumber
unsigned int banksNumber
Definition: DeviceDataStructure.h:49
bit_C::name
char name[32]
Definition: DeviceDataStructure.h:83
bank_C::categories
category_C ** categories
Definition: DeviceDataStructure.h:120
bitValue_C
struct bitValue_C bitValue_C
bank_C::categoriesNbr
unsigned int categoriesNbr
Definition: DeviceDataStructure.h:119
deviceBank
This stucture defines the memory sectors for each bank.
Definition: DeviceDataStructure.h:36
storageStructure::banks
deviceBank * banks
Definition: DeviceDataStructure.h:50
bit_C
This stucture will be filled by values which characterize the device&#39;s option bytes.
Definition: DeviceDataStructure.h:81
bit_C
struct bit_C bit_C
bit_C::bitValue
unsigned int bitValue
Definition: DeviceDataStructure.h:93
peripheral_C::description
char description[200]
Definition: DeviceDataStructure.h:131
bitCoefficient_C
struct bitCoefficient_C bitCoefficient_C
bank_C::address
unsigned int address
Definition: DeviceDataStructure.h:117
bit_C::values
bitValue_C ** values
Definition: DeviceDataStructure.h:90
bankSector
This stucture indicates the sectors parameters.
Definition: DeviceDataStructure.h:24
peripheral_C
struct peripheral_C peripheral_C
bit_C::access
unsigned char access
Definition: DeviceDataStructure.h:88
category_C::name
char name[100]
Definition: DeviceDataStructure.h:103
peripheral_C
Get peripheral option bytes general informations.
Definition: DeviceDataStructure.h:128
bitValue_C::value
unsigned int value
Definition: DeviceDataStructure.h:71
bank_C
struct bank_C bank_C
bit_C::bitWidth
unsigned int bitWidth
Definition: DeviceDataStructure.h:87
bit_C::reference
unsigned char * reference
Definition: DeviceDataStructure.h:92
peripheral_C::banks
bank_C ** banks
Definition: DeviceDataStructure.h:133
category_C::bits
bit_C ** bits
Definition: DeviceDataStructure.h:105
bitCoefficient_C
This stucture indicates the coefficients to access to the adequate option bit.
Definition: DeviceDataStructure.h:58
bit_C::bitOffset
unsigned int bitOffset
Definition: DeviceDataStructure.h:86
bank_C::size
unsigned int size
Definition: DeviceDataStructure.h:116
category_C
struct category_C category_C
deviceBank
struct deviceBank deviceBank
bit_C::equation
bitCoefficient_C equation
Definition: DeviceDataStructure.h:91
bankSector
struct bankSector bankSector
category_C::bitsNbr
unsigned int bitsNbr
Definition: DeviceDataStructure.h:104
bit_C::wordOffset
unsigned int wordOffset
Definition: DeviceDataStructure.h:85
bankSector::index
unsigned int index
Definition: DeviceDataStructure.h:26
bitCoefficient_C::offset
unsigned int offset
Definition: DeviceDataStructure.h:61
bitValue_C
This stucture describes the option Bit value.
Definition: DeviceDataStructure.h:69
peripheral_C::name
char name[32]
Definition: DeviceDataStructure.h:130
deviceBank::sectorsNumber
unsigned int sectorsNumber
Definition: DeviceDataStructure.h:38
bankSector::address
unsigned int address
Definition: DeviceDataStructure.h:28
bitCoefficient_C::multiplier
unsigned int multiplier
Definition: DeviceDataStructure.h:60
storageStructure
struct storageStructure storageStructure
peripheral_C::banksNbr
unsigned int banksNbr
Definition: DeviceDataStructure.h:132
bitValue_C::description
char description[200]
Definition: DeviceDataStructure.h:72
storageStructure
This stucture describes sotrage characterization.
Definition: DeviceDataStructure.h:47
bit_C::description
char description[300]
Definition: DeviceDataStructure.h:84
bit_C::valuesNbr
unsigned int valuesNbr
Definition: DeviceDataStructure.h:89
deviceBank::sectors
bankSector * sectors
Definition: DeviceDataStructure.h:39
bank_C
Get option bytes banks internal descriptions.
Definition: DeviceDataStructure.h:114
bank_C::access
unsigned char access
Definition: DeviceDataStructure.h:118
bankSector::size
unsigned int size
Definition: DeviceDataStructure.h:27
category_C
Get option bytes banks categories descriptions.
Definition: DeviceDataStructure.h:101