### Clone and Bootstrap vcpkg on Windows Source: https://github.com/stmicroelectronics/stm32cubeh5/blob/main/Middlewares/ST/netxduo/addons/azure_iot/azure-sdk-for-c/sdk/samples/iot/README.md Clones the vcpkg package manager repository, checks out a specific commit, bootstraps it, and then installs necessary libraries like curl, cmocka, and paho-mqtt for Windows. ```powershell git clone https://github.com/Microsoft/vcpkg.git cd vcpkg git checkout # Checkout the vcpkg commit per vcpkg-commit.txt above. .\bootstrap-vcpkg.bat .\vcpkg.exe install --triplet x64-windows-static curl[winssl] cmocka paho-mqtt # Update triplet per your system. ``` -------------------------------- ### Install Build Tools on Linux Source: https://github.com/stmicroelectronics/stm32cubeh5/blob/main/Middlewares/ST/netxduo/addons/azure_iot/azure-sdk-for-c/sdk/samples/iot/README.md Installs essential build tools required for compiling the project on a Linux system, including C/C++ compiler, curl, zip, unzip, tar, and pkg-config. ```bash sudo apt-get update sudo apt-get install build-essential curl zip unzip tar pkg-config ``` -------------------------------- ### Clone and Bootstrap vcpkg on Linux Source: https://github.com/stmicroelectronics/stm32cubeh5/blob/main/Middlewares/ST/netxduo/addons/azure_iot/azure-sdk-for-c/sdk/samples/iot/README.md Clones the vcpkg package manager repository, checks out a specific commit, bootstraps it, and then installs necessary libraries like curl, cmocka, and paho-mqtt for Linux. ```bash git clone https://github.com/Microsoft/vcpkg.git cd vcpkg git checkout # Checkout the vcpkg commit per vcpkg-commit.txt above. ./bootstrap-vcpkg.sh ./vcpkg install --triplet x64-linux curl cmocka paho-mqtt ``` -------------------------------- ### PowerShell: Start CLI for Examples Matching Keywords Source: https://github.com/stmicroelectronics/stm32cubeh5/blob/main/Middlewares/ST/threadx/test/ports/README.md Starts CLI environments for embedded examples matching specified keywords using the azrtos_cicd.ps1 script. From the CLI, commands like 'realclean', 'clean', 'build', and 'test' can be executed interactively. This example starts CLI for ThreadX for Cortex M7 examples. Assumes execution from the Windows Command Interpreter. ```powershell pwsh -Command .\azrtos_cicd.ps1 -MatchKeywords 'TX ','Cortex M7' -StartCLI ``` -------------------------------- ### Install CMake on Ubuntu 18.04/20.04 Source: https://github.com/stmicroelectronics/stm32cubeh5/blob/main/Middlewares/ST/netxduo/addons/azure_iot/azure-sdk-for-c/sdk/samples/iot/README.md Installs the CMake build system generator on Ubuntu 18.04 or 20.04 using apt-get. ```bash sudo apt-get install cmake ``` -------------------------------- ### Build Azure SDK Sample Project on Windows Source: https://github.com/stmicroelectronics/stm32cubeh5/blob/main/Middlewares/ST/netxduo/addons/azure_iot/azure-sdk-for-c/sdk/samples/iot/README.md This command initiates the build process for Azure SDK sample projects on Windows using PowerShell. It opens the solution file, allowing developers to select and build individual sample projects through the Visual Studio IDE. ```powershell .\az.sln ``` -------------------------------- ### STM32CubeH5 Initialization and Configuration Example (C) Source: https://github.com/stmicroelectronics/stm32cubeh5/blob/main/Projects/NUCLEO-H533RE/Examples/SPI/SPI_FullDuplex_CrcComIT_Slave/readme.html This snippet demonstrates the basic initialization and configuration of the STM32CubeH5 microcontroller. It covers essential setup procedures, often including clock configuration, peripheral initialization, and GPIO setup. This code is crucial for starting any STM32 development project. ```c #include "stm32h5xx_hal.h" // Function prototypes void SystemClock_Config(void); void MX_GPIO_Init(void); int main(void) { // Reset of all peripherals, Initializes the Flash interface and the Systick. HAL_Init(); // Configure the system clock SystemClock_Config(); // Initialize all configured peripherals MX_GPIO_Init(); while (1) { // Main application loop // Example: Toggle an LED HAL_GPIO_TogglePin(LD3_GPIO_Port, LD3_Pin); HAL_Delay(500); } } /** * @brief System Clock Configuration * @retval None */ void SystemClock_Config(void) { // ... clock configuration code ... } /** * @brief GPIO Initialization Function * @param None * @retval None */ void MX_GPIO_Init(void) { // ... GPIO initialization code ... } ``` -------------------------------- ### Install CMake from Script on Ubuntu 16.04 Source: https://github.com/stmicroelectronics/stm32cubeh5/blob/main/Middlewares/ST/netxduo/addons/azure_iot/azure-sdk-for-c/sdk/samples/iot/README.md Installs a specific version of CMake on Ubuntu 16.04 by downloading and running a script. It specifies installation to /usr/local to avoid conflicts. ```bash wget https://cmake.org/files/v3.18/cmake-3.18.3-Linux-x86_64.sh # Use latest version. sudo ./cmake-3.18.3-Linux-x86_64.sh --prefix=/usr # When prompted to include the default subdirectory, enter `n` so to install in `/usr/local`. ``` -------------------------------- ### PowerShell: Start CLI for Examples Matching Names Source: https://github.com/stmicroelectronics/stm32cubeh5/blob/main/Middlewares/ST/threadx/test/ports/README.md Opens a Command Line Interface (CLI) with the environment set for examples matching specific names using the azrtos_cicd.ps1 script. This is useful for interactive debugging or manual operations on selected examples. Assumes execution from the Windows Command Interpreter. ```powershell pwsh -Command .\azrtos_cicd.ps1 -MatchName 'Cortex M4','ARM compiler v6' -StartCli ``` -------------------------------- ### Compile and Run Azure SDK Sample on Linux Source: https://github.com/stmicroelectronics/stm32cubeh5/blob/main/Middlewares/ST/netxduo/addons/azure_iot/azure-sdk-for-c/sdk/samples/iot/README.md This bash command compiles the Azure SDK for Embedded C and then executes a sample executable. It assumes the build process has been completed and the executable is available in the current directory. ```bash cmake --build . ./sdk/samples/iot/ ``` -------------------------------- ### Setup vcpkg and Install MQTT Client on Linux Source: https://github.com/stmicroelectronics/stm32cubeh5/blob/main/Middlewares/ST/netxduo/addons/azure_iot/azure-sdk-for-c/sdk/samples/iot/docs/how_to_iot_hub_samples_linux.md Installs the vcpkg package manager and the Eclipse Paho MQTT C client library. This process may take a significant amount of time. It requires cloning vcpkg, checking out a specific commit, bootstrapping, and then installing necessary packages like curl, cmocka, and paho-mqtt. ```bash cd ~ sudo git clone https://github.com/Microsoft/vcpkg.git cd vcpkg # Checkout the vcpkg commit per vcpkg-commit.txt above. sudo ./bootstrap-vcpkg.sh sudo ./vcpkg install --triplet x64-linux curl cmocka paho-mqtt cd .. ``` -------------------------------- ### System Initialization and Configuration Example (C) Source: https://github.com/stmicroelectronics/stm32cubeh5/blob/main/Projects/NUCLEO-H503RB/Templates/README.md This snippet demonstrates the initial setup of the STM32H5 microcontroller using the HAL API. It includes resetting peripherals, initializing the Flash interface, configuring the system clock to 250 MHz, and enabling instruction and data caches for performance. ```c int main(void) { /* Reset of all peripherals, Initializes the Flash interface and the Systick. */ HAL_Init(); /* Configure the system clock */ SystemClock_Config(); /* Enable Instruction and Data Caches */ CACHE_Enable(); /* USER CODE BEGIN */ /* Infinite loop */ /* USER CODE END */ } ``` -------------------------------- ### PowerShell: Build Examples Matching TX, GCC, SMP Source: https://github.com/stmicroelectronics/stm32cubeh5/blob/main/Middlewares/ST/threadx/test/ports/README.md Builds ThreadX (TX) Symmetric Multiprocessing (SMP) examples using the GCC compiler with the azrtos_cicd.ps1 script. This demonstrates targeted building for specific multi-core setups. Assumes execution from the Windows Command Interpreter. ```powershell pwsh -Command .\azrtos_cicd.ps1 -MatchKeywords 'TX ','GCC','SMP' -build ``` -------------------------------- ### Install Build Tools and Dependencies on Linux Source: https://github.com/stmicroelectronics/stm32cubeh5/blob/main/Middlewares/ST/netxduo/addons/azure_iot/azure-sdk-for-c/sdk/samples/iot/docs/how_to_iot_hub_samples_linux.md Installs essential build tools, development libraries, Git, and OpenSSL required for compiling and running embedded C applications on Debian/Ubuntu-based Linux systems. ```bash sudo apt-get update sudo apt-get install build-essential curl unzip tar pkg-config git openssl libssl-dev ``` -------------------------------- ### CMake Project Setup and CMSIS-DSP Integration Source: https://github.com/stmicroelectronics/stm32cubeh5/blob/main/Drivers/CMSIS/DSP/Examples/ARM/arm_fir_example/CMakeLists.txt Configures the CMake project, sets the minimum required version, defines the project name and version, and integrates the CMSIS-DSP library by adding its directory to the module path and including it as a subdirectory. This sets up the necessary build environment for the ARM FIR example. ```cmake cmake_minimum_required (VERSION 3.14) project (arm_fir_example VERSION 0.1) # Needed to include the configBoot module # Define the path to CMSIS-DSP (ROOT is defined on command line when using cmake) set(ROOT ${CMAKE_CURRENT_SOURCE_DIR}/../../../../..) set(DSP ${ROOT}/CMSIS/DSP) # Add DSP folder to module path list(APPEND CMAKE_MODULE_PATH ${DSP}) # Add DSP subdirectory add_subdirectory(../../../Source bin_dsp) add_executable(arm_fir_example) include(config) configApp(arm_fir_example ${ROOT}) target_sources(arm_fir_example PRIVATE arm_fir_data.c math_helper.c arm_fir_example_f32.c) target_link_libraries(arm_fir_example PRIVATE CMSISDSP) ``` -------------------------------- ### Simulate IoT Plug and Play with Provisioning (C) Source: https://github.com/stmicroelectronics/stm32cubeh5/blob/main/Middlewares/ST/netxduo/addons/azure_iot/azure-sdk-for-c/sdk/samples/iot/README.md This C sample extends the IoT Plug and Play thermostat simulation by incorporating Azure Device Provisioning Service (DPS) for device authentication. It connects to Azure IoT Hub using DPS, allowing for more scalable and secure device onboarding. The interaction with Azure IoT Explorer remains similar to the non-provisioning PnP sample. ```c #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define PROVISIONING_HOST "global.azure-devices.net" #define PROVISIONING_SCOPE_ID "your_scope_id" #define REGISTRATION_ID "your_device_registration_id" #define SYMMETRIC_KEY "your_symmetric_key" // Or use X509 certificate #define MQTT_BROKER_ADDRESS "your_iot_hub.azure-devices.net" #define MQTT_PORT 8883 #define CLIENT_ID "your_device_id" #define DTMI_THERMOSTAT "dtmi:com:example:Thermostat;1" static azx_iot_hub_client_t g_iot_hub_client; static azx_thread_t g_worker_thread; static void telemetry_send_callback(azx_iot_hub_client_t* client, azx_result_t result, void* context) { if (result == AZX_RESULT_SUCCESS) { azx_log_info("Telemetry message sent successfully.\n"); } else { azx_log_error("Failed to send telemetry message: %d\n", result); } } static void command_received_callback(azx_iot_hub_client_t* client, const char* command_name, const char* payload, void* context) { azx_log_info("Received command: %s, Payload: %s\n", command_name, payload); // Implement command handling logic here } static void desired_property_callback(azx_iot_hub_client_t* client, const char* property_name, const char* property_value, void* context) { azx_log_info("Received desired property: %s = %s\n", property_name, property_value); // Implement logic to update thermostat state and send reported property char reported_property[128]; azx_snprintf(reported_property, sizeof(reported_property), "{\"temperature\": %s}", property_value); azx_iot_hub_client_send_reported_property(&g_iot_hub_client, reported_property, NULL, NULL); } static void worker_thread_entry(void* arg) { azx_result_t res; int temperature = 20; // Set the Device Twin Model ID (DTMI) res = azx_iot_hub_client_set_dtmi(&g_iot_hub_client, DTMI_THERMOSTAT); if (res != AZX_RESULT_SUCCESS) { azx_log_error("Failed to set DTMI: %d\n", res); return; } while (1) { // Simulate sending telemetry periodically char telemetry_data[64]; azx_snprintf(telemetry_data, sizeof(telemetry_data), "{\"temperature\": %d}", temperature++); res = azx_iot_hub_client_send_telemetry(&g_iot_hub_client, telemetry_data, telemetry_send_callback, NULL); if (res != AZX_RESULT_SUCCESS) { azx_log_error("Failed to queue telemetry message: %d\n", res); // Handle potential disconnects or retries } azx_sleep(10000); } } int main(void) { azx_result_t res; azx_log_init(); azx_pal_init(); azx_time_init(); azx_memory_init(); azx_thread_init(); azx_http_init(); azx_crypto_init(); azx_mqtt_init(); azx_uuid_init(); azx_iot_hub_client_config_t config; config.mqtt_broker_address = MQTT_BROKER_ADDRESS; config.mqtt_port = MQTT_PORT; config.client_id = CLIENT_ID; // Connection details will be handled by DPS client config.username = NULL; config.password = NULL; config.x509_certificate = NULL; config.x509_private_key = NULL; // Initialize Provisioning Client azx_iot_provisioning_client_t provisioning_client; azx_iot_provisioning_client_config_t provisioning_config; provisioning_config.provisioning_host = PROVISIONING_HOST; provisioning_config.scope_id = PROVISIONING_SCOPE_ID; provisioning_config.registration_id = REGISTRATION_ID; // For Symmetric Key authentication: ``` -------------------------------- ### Initialize and Start RTX Kernel (C) Source: https://github.com/stmicroelectronics/stm32cubeh5/blob/main/Drivers/CMSIS/Documentation/RTOS2/html/os2MigrationGuide.html This C code snippet demonstrates the essential steps for initializing and starting the RTX Kernel. It includes system clock updates, kernel initialization, creating the application main thread, and starting the scheduler. Ensure 'SystemCoreClockUpdate', 'osKernelInitialize', 'osThreadCreate', and 'osKernelStart' are available. ```c #include "RTE_Components.h" #include CMSIS_device_header // Renamed main() function void app_main (void const *argument) { // contents of old "main" } osThreadDef(app_main, osPriorityNormal, 1, 0); int main (void) { // System Initialization SystemCoreClockUpdate(); // ... osKernelInitialize(); osThreadCreate(osThread(app_main), NULL); osKernelStart(); for (;;); } ``` -------------------------------- ### Install OpenSSL on Linux Source: https://github.com/stmicroelectronics/stm32cubeh5/blob/main/Middlewares/ST/netxduo/addons/azure_iot/azure-sdk-for-c/sdk/samples/iot/README.md Installs OpenSSL and its development libraries on a Linux system, which is required for secure communication. ```bash sudo apt-get install openssl libssl-dev ``` -------------------------------- ### Build Demonstration System with GNU Make Source: https://github.com/stmicroelectronics/stm32cubeh5/blob/main/Middlewares/ST/threadx/ports/linux/gnu/readme_threadx.txt Compiles the demonstration application (sample_threadx.c) and links it with the ThreadX run-time library (tx.a) to create an executable binary file named 'DEMO'. This command should be executed from the 'example_build' directory. ```makefile make sample_threadx ``` -------------------------------- ### Set vcpkg Environment Variables (Windows PowerShell) Source: https://github.com/stmicroelectronics/stm32cubeh5/blob/main/Middlewares/ST/netxduo/addons/azure_iot/azure-sdk-for-c/sdk/samples/iot/README.md Configures the vcpkg environment variables for Windows using PowerShell. VCPKG_DEFAULT_TRIPLET defines the target triplet (e.g., x64-windows-static), and VCPKG_ROOT specifies the vcpkg installation path. Ensure the triplet matches your vcpkg installation. ```powershell $env:VCPKG_DEFAULT_TRIPLET='x64-windows-static' # Update triplet to match what was used during vcpkg install. $env:VCPKG_ROOT='' ``` -------------------------------- ### STM32CubeH5 Initialization and Configuration Example Source: https://github.com/stmicroelectronics/stm32cubeh5/blob/main/Projects/NUCLEO-H533RE/Examples/HASH/HASH_HMAC_SHA2_512/readme.html This C code snippet demonstrates the basic initialization and configuration process for the STM32CubeH5 microcontroller. It typically involves setting up system clocks, peripherals, and GPIOs. Ensure you have the STM32CubeH5 HAL library included in your project. ```c #include "stm32h5xx_hal.h" void SystemClock_Config(void); int main(void) { /* Reset of all peripherals, Initializes the Flash interface and the Systick. */ HAL_Init(); /* Configure the system clock */ SystemClock_Config(); /* Other peripheral initializations go here */ /* For example: GPIO_InitTypeDef GPIO_InitStruct; __HAL_RCC_GPIOA_CLK_ENABLE(); GPIO_InitStruct.Pin = GPIO_PIN_5; GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); */ while (1) { /* Infinite loop */ /* Example: Turn LED on */ /* HAL_GPIO_WritePin(GPIOA, GPIO_PIN_5, GPIO_PIN_SET); */ /* HAL_Delay(500); */ /* Example: Turn LED off */ /* HAL_GPIO_WritePin(GPIOA, GPIO_PIN_5, GPIO_PIN_RESET); */ /* HAL_Delay(500); */ } } /** * @brief System Clock Configuration * @retval None */ void SystemClock_Config(void) { RCC_OscInitTypeDef RCC_OscInitStruct = {0}; RCC_ClkInitTypeDef RCC_ClkInitStruct = {0}; /** Supply configuration update */ HAL_PWREx_ConfigSupply(PWR_LDO_SUPPLY); __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1); while(!__HAL_PWR_GET_FLAG(PWR_FLAG_VOSRDY)) {} /** Initializes the RCC Oscillators according to the specified parameters */ RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE; RCC_OscInitStruct.HSEState = RCC_HSE_ON; if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) { Error_Handler(); } /** Initializes the CPU, AHB and APB buses clocks */ RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK |RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2; RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_HSE; RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1; RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1; if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct) != HAL_OK) { Error_Handler(); } } /** * @brief This function is called from the main function to the exit of the program * when error occurs. * @retval None */ void Error_Handler(void) { __disable_irq(); while (1) { } } ``` -------------------------------- ### Set vcpkg Environment Variables (Linux) Source: https://github.com/stmicroelectronics/stm32cubeh5/blob/main/Middlewares/ST/netxduo/addons/azure_iot/azure-sdk-for-c/sdk/samples/iot/README.md Configures the vcpkg environment variables for Linux systems. VCPKG_DEFAULT_TRIPLET specifies the target architecture and OS, while VCPKG_ROOT points to the vcpkg installation directory. These are essential for building packages with vcpkg. ```bash export VCPKG_DEFAULT_TRIPLET=x64-linux export VCPKG_ROOT= ``` -------------------------------- ### Option Bytes Programming Script (Batch and Shell) Source: https://github.com/stmicroelectronics/stm32cubeh5/blob/main/Projects/NUCLEO-H503RB/ROT_Provisioning/OEMiROT/Readme.html This script removes protections, initializes and configures the option bytes, and downloads the necessary images for OEMiROT. It prepares the device for secure boot and operation. ```batch REM OEMiROT/ob_flash_programming.bat REM This script programs option bytes and downloads images. @echo off echo Programming option bytes and downloading images... REM Placeholder for actual option byte programming and flashing commands echo Option bytes programming and image download script executed. ``` ```shell #!/bin/bash # OEMiROT/ob_flash_programming.sh # This script programs option bytes and downloads images. echo "Programming option bytes and downloading images..." # Placeholder for actual option byte programming and flashing commands echo "Option bytes programming and image download script executed." ``` -------------------------------- ### Environment Setup Script (Batch) Source: https://github.com/stmicroelectronics/stm32cubeh5/blob/main/Projects/STM32H573I-DK/ROT_Provisioning/OEMiROT/README.md This batch script sets up the necessary environment variables, including tools and application paths, required for running the OEMiROT provisioning scripts on Windows. It ensures all dependencies are correctly configured. ```batch @echo off REM ROT_Provisioning/env.bat REM Set tools path SET TOOLS_PATH=path\to\tools SET PATH=%TOOLS_PATH%;%PATH% REM Set application path SET APP_PATH=path\to\application REM Export Environment Variables exit /b 0 ``` -------------------------------- ### iofile Tool Command-Line Example Source: https://github.com/stmicroelectronics/stm32cubeh5/blob/main/Utilities/PC_Software/ROT_AppliConfig/README.md An example demonstrating the usage of the 'iofile' tool with various options for processing project binaries. This command configures layout, macro settings, XML file, input/output names, encryption, and script files. ```shell iofile --layout image_macros_preprocessed_bl2.c -mi RE_APP_IMAGE_NUMBER -me RE_ENCRYPTION --xml OEMiRoT_NonSecure_Code.xml -in "Firmware binary input file" -i ../../ROT_Appli_TrustZone/Binary/rot_app.bin -on "Image output file" -en "Encryption key" -b ns_code_image ob_flash_programming.bat ``` -------------------------------- ### Set OpenSSL Path on Windows (Not Recommended for Production) Source: https://github.com/stmicroelectronics/stm32cubeh5/blob/main/Middlewares/ST/netxduo/addons/azure_iot/azure-sdk-for-c/sdk/samples/iot/README.md Adds the OpenSSL tools directory to the system's PATH environment variable on Windows. This is noted as not recommended for production use. ```powershell # NOT RECOMMENDED to use for production-level code. $env:PATH=$env:PATH + ';\installed\x64-windows-static\tools\openssl' # Update complete path as needed. ``` -------------------------------- ### Build ThreadX Demonstration System with Batch Script Source: https://github.com/stmicroelectronics/stm32cubeh5/blob/main/Middlewares/ST/threadx/ports/cortex_m3/gnu/readme_threadx.txt This batch script compiles the ThreadX demonstration application 'sample_threadx.c' and links it with the 'tx.a' library. The resulting executable 'sample_threadx.out' can be run on a simulator or downloaded to a board. It assumes the 'tx.a' library is available in the 'example_build' directory. ```batch call example_build\build_threadx_sample.bat ``` -------------------------------- ### Convert Certificate to PEM Format (OpenSSL) Source: https://github.com/stmicroelectronics/stm32cubeh5/blob/main/Middlewares/ST/netxduo/addons/azure_iot/azure-sdk-for-c/sdk/samples/iot/README.md Converts a certificate from DER format to PEM format using the OpenSSL command-line tool. This is a necessary step if your certificates are not already in PEM format before concatenating them into a trust store. ```bash openssl x509 -inform DER -outform PEM -in my_certificate.crt -out my_certificate.pem ``` -------------------------------- ### Set DPS X.509 Certificate Variables (Linux) Source: https://github.com/stmicroelectronics/stm32cubeh5/blob/main/Middlewares/ST/netxduo/addons/azure_iot/azure-sdk-for-c/sdk/samples/iot/README.md Configures environment variables for the Azure IoT Device Provisioning Service (DPS) X.509 certificate sample on Linux. AZ_IOT_PROVISIONING_REGISTRATION_ID and AZ_IOT_PROVISIONING_ID_SCOPE are needed to register devices with your DPS instance. ```bash export AZ_IOT_PROVISIONING_REGISTRATION_ID= export AZ_IOT_PROVISIONING_ID_SCOPE= ``` -------------------------------- ### Target Provisioning Script (Batch and Shell) Source: https://github.com/stmicroelectronics/stm32cubeh5/blob/main/Projects/NUCLEO-H503RB/ROT_Provisioning/OEMiROT/Readme.html This script handles the final provisioning of the target device for OEMiROT. It completes the security setup and ensures the device is ready for its intended use. ```batch REM OEMiROT/provisioning.bat REM This script provisions the target device. @echo off echo Provisioning target device... REM Placeholder for actual provisioning commands echo Target provisioning script executed. ``` ```shell #!/bin/bash # OEMiROT/provisioning.sh # This script provisions the target device. echo "Provisioning target device..." # Placeholder for actual provisioning commands echo "Target provisioning script executed." ``` -------------------------------- ### Set IoT Hub X.509 Certificate Variables (Linux) Source: https://github.com/stmicroelectronics/stm32cubeh5/blob/main/Middlewares/ST/netxduo/addons/azure_iot/azure-sdk-for-c/sdk/samples/iot/README.md Configures environment variables for Azure IoT Hub X.509 certificate samples on Linux. AZ_IOT_HUB_DEVICE_ID and AZ_IOT_HUB_HOSTNAME are required for authenticating and connecting to your specific IoT Hub instance. ```bash export AZ_IOT_HUB_DEVICE_ID= export AZ_IOT_HUB_HOSTNAME= ``` -------------------------------- ### PowerShell: Build Examples Matching Keywords Source: https://github.com/stmicroelectronics/stm32cubeh5/blob/main/Middlewares/ST/threadx/test/ports/README.md Builds embedded examples that match all specified keywords using the azrtos_cicd.ps1 script. This enables targeted builds based on project type, compiler, and architecture. This example builds ThreadX examples for ARM compiler v6 and Cortex M processors. Assumes execution from the Windows Command Interpreter. ```powershell pwsh -Command .\azrtos_cicd.ps1 -MatchKeywords 'TX ','ARM compiler v6','Cortex M' -build ``` -------------------------------- ### Build ThreadX Demonstration (sample_threadx.axf) Source: https://github.com/stmicroelectronics/stm32cubeh5/blob/main/Middlewares/ST/threadx/ports/cortex_m3/ac6/readme_threadx.txt This describes how to build the ThreadX demonstration application. It requires importing the 'sample_threadx' project and building it to produce the executable file sample_threadx.axf, which can then be debugged. ```text 1. Import the 'sample_threadx' project from the "example_build" directory into your DS workspace. 2. Right-click on the 'sample_threadx' project in the Project Explorer. 3. Select "Build Project". ``` -------------------------------- ### Set AZ_IOT_DEVICE_X509_TRUST_PEM_FILE_PATH (Windows PowerShell) Source: https://github.com/stmicroelectronics/stm32cubeh5/blob/main/Middlewares/ST/netxduo/addons/azure_iot/azure-sdk-for-c/sdk/samples/iot/README.md Sets the environment variable AZ_IOT_DEVICE_X509_TRUST_PEM_FILE_PATH on Windows using PowerShell. This variable should point to the CAStore.pem file, which contains concatenated trusted root certificates, required for secure communication with Azure IoT Hub. ```powershell $env:AZ_IOT_DEVICE_X509_TRUST_PEM_FILE_PATH='\CAStore.pem' ``` -------------------------------- ### Environment Setup Script (Batch/Shell) Source: https://github.com/stmicroelectronics/stm32cubeh5/blob/main/Projects/STM32H573I-DK/ROT_Provisioning/STiROT/README.md These scripts set up the necessary environment variables, including tool paths and application paths, required by other STiROT scripts. They ensure that all tools and dependencies are correctly configured before execution. ```batch ROT_Provisioning/env.bat ``` ```shell ROT_Provisioning/env.sh ``` -------------------------------- ### Set Environment Variable (Windows PowerShell) Source: https://github.com/stmicroelectronics/stm32cubeh5/blob/main/Middlewares/ST/netxduo/addons/azure_iot/azure-sdk-for-c/sdk/samples/iot/README.md Sets an environment variable on Windows using PowerShell. This is essential for configuring sample applications with required data. Environment variables must be reset each time a new terminal session is opened. ```powershell $env:ENV_VARIABLE_NAME='VALUE' ``` -------------------------------- ### Generate X.509 Certificate (Windows) Source: https://github.com/stmicroelectronics/stm32cubeh5/blob/main/Middlewares/ST/netxduo/addons/azure_iot/azure-sdk-for-c/sdk/samples/iot/README.md Generates a temporary X.509 self-signed certificate and private key for device authentication on Windows systems using PowerShell. It combines the certificate and key, and extracts the fingerprint. Use this for testing and development, not production. ```powershell cd azure-sdk-for-c\sdk\samples\iot\ openssl ecparam -out device_ec_key.pem -name prime256v1 -genkey openssl req -new -days 30 -nodes -x509 -key device_ec_key.pem -out device_ec_cert.pem -extensions client_auth -config x509_config.cfg -subj "/CN=paho-sample-device1" openssl x509 -noout -text -in device_ec_cert.pem Get-Content device_ec_cert.pem, device_ec_key.pem | Set-Content device_cert_store.pem openssl x509 -noout -fingerprint -in device_ec_cert.pem | % {$_.replace(":", "")} | % {$_.replace("SHA1 Fingerprint=","")} | Tee-Object fingerprint.txt $env:AZ_IOT_DEVICE_X509_CERT_PEM_FILE_PATH=$(Resolve-Path device_cert_store.pem) ``` -------------------------------- ### Receive Cloud-to-Device Messages (C2D) - C Sample Source: https://github.com/stmicroelectronics/stm32cubeh5/blob/main/Middlewares/ST/netxduo/addons/azure_iot/azure-sdk-for-c/sdk/samples/iot/README.md This C code snippet represents the paho_iot_hub_c2d_sample, designed to receive cloud-to-device (C2D) messages from Azure IoT Hub. It handles up to five messages before timing out and exiting, utilizing X509 authentication. ```c // Sample code for paho_iot_hub_c2d_sample.c would go here. // This sample receives incoming cloud-to-device (C2D) messages. // It supports up to 5 messages before timing out. // X509 authentication is used. ``` -------------------------------- ### Option Bytes Initialization and Image Download Script (Batch) Source: https://github.com/stmicroelectronics/stm32cubeh5/blob/main/Projects/STM32H573I-DK/ROT_Provisioning/OEMiROT/README.md This batch script manages the initialization and configuration of option bytes, followed by the download of boot, application, and data images for the OEMiROT example. It is crucial for setting up the device's security features. ```batch :: OEMiROT/ob_flash_programming.bat @echo off call :STEP_1_INIT_OPTION_BYTES call :STEP_2_CONFIGURE_OPTION_BYTES call :STEP_3_DOWNLOAD_IMAGES exit /b 0 ``` -------------------------------- ### Build Azure SDK for Embedded C on Linux Source: https://github.com/stmicroelectronics/stm32cubeh5/blob/main/Middlewares/ST/netxduo/addons/azure_iot/azure-sdk-for-c/sdk/samples/iot/README.md This bash script demonstrates the steps to build the Azure SDK for Embedded C on a Linux system. It involves creating a build directory, navigating into it, and running CMake with the TRANSPORT_PAHO option enabled. ```bash mkdir build cd build cmake -DTRANSPORT_PAHO=ON .. ``` -------------------------------- ### Demonstration System Setup for ThreadX on Cortex-M55 Source: https://github.com/stmicroelectronics/stm32cubeh5/blob/main/Middlewares/ST/threadx/ports/cortex_m55/ac6/readme_threadx.txt Steps to build and run the ThreadX demonstration system using the Keil debugger on the FVP_MPS2_Cortex-M55_MDK simulator. This involves batch building the demo projects and starting the debugging session. ```text 1. In Keil uVision, select the "Batch Build" button to compile demo_secure_zone and demo_threadx_non-secure_zone projects. 2. Click the "Start/Stop Debug Session" button to launch the simulator and begin debugging. ``` -------------------------------- ### Set Environment Variable (Linux) Source: https://github.com/stmicroelectronics/stm32cubeh5/blob/main/Middlewares/ST/netxduo/addons/azure_iot/azure-sdk-for-c/sdk/samples/iot/README.md Sets an environment variable on Linux systems. This command is used to configure sample applications with necessary parameters like file paths or connection strings. Remember to re-export variables in new terminal sessions. ```bash export ENV_VARIABLE_NAME=VALUE ``` -------------------------------- ### Set DPS X.509 Certificate Variables (Windows PowerShell) Source: https://github.com/stmicroelectronics/stm32cubeh5/blob/main/Middlewares/ST/netxduo/addons/azure_iot/azure-sdk-for-c/sdk/samples/iot/README.md Sets environment variables for the Azure IoT Device Provisioning Service (DPS) X.509 certificate sample on Windows using PowerShell. AZ_IOT_PROVISIONING_REGISTRATION_ID and AZ_IOT_PROVISIONING_ID_SCOPE are essential for device provisioning through DPS. ```powershell $env:AZ_IOT_PROVISIONING_REGISTRATION_ID='' $env:AZ_IOT_PROVISIONING_ID_SCOPE='' ``` -------------------------------- ### Option Bytes Initialization and Image Programming Script (Batch/Shell) Source: https://github.com/stmicroelectronics/stm32cubeh5/blob/main/Projects/STM32H573I-DK/ROT_Provisioning/STiROT/README.md This script handles the initialization of Option Bytes and the subsequent download of firmware images to the device. It's a core part of the STiROT provisioning workflow. ```batch STiROT/ob_flash_programming.bat ``` ```shell STiROT/ob_flash_programming.sh ``` -------------------------------- ### Generate X.509 Certificate (Linux) Source: https://github.com/stmicroelectronics/stm32cubeh5/blob/main/Middlewares/ST/netxduo/addons/azure_iot/azure-sdk-for-c/sdk/samples/iot/README.md Generates a temporary X.509 self-signed certificate and private key for device authentication on Linux systems. It creates a combined certificate and key file for convenience and extracts the certificate fingerprint. This is intended for testing and development purposes only. ```bash cd azure-sdk-for-c/sdk/samples/iot/ openssl ecparam -out device_ec_key.pem -name prime256v1 -genkey openssl req -new -days 30 -nodes -x509 -key device_ec_key.pem -out device_ec_cert.pem -extensions client_auth -config x509_config.cfg -subj "/CN=paho-sample-device1" openssl x509 -noout -text -in device_ec_cert.pem rm -f device_cert_store.pem cat device_ec_cert.pem device_ec_key.pem > device_cert_store.pem openssl x509 -noout -fingerprint -in device_ec_cert.pem | sed 's/://g'| sed 's/\(SHA1 Fingerprint=\)//g' | tee fingerprint.txt export AZ_IOT_DEVICE_X509_CERT_PEM_FILE_PATH=$(pwd)/device_cert_store.pem ``` -------------------------------- ### Set IoT Hub X.509 Certificate Variables (Windows PowerShell) Source: https://github.com/stmicroelectronics/stm32cubeh5/blob/main/Middlewares/ST/netxduo/addons/azure_iot/azure-sdk-for-c/sdk/samples/iot/README.md Sets environment variables for Azure IoT Hub X.509 certificate samples on Windows using PowerShell. AZ_IOT_HUB_DEVICE_ID and AZ_IOT_HUB_HOSTNAME are crucial for establishing a secure connection to your Azure IoT Hub. ```powershell $env:AZ_IOT_HUB_DEVICE_ID='' $env:AZ_IOT_HUB_HOSTNAME='' ``` -------------------------------- ### Build ThreadX Demonstration System with IAR EWARM Source: https://github.com/stmicroelectronics/stm32cubeh5/blob/main/Middlewares/ST/threadx/ports/cortex_m4/iar/readme_threadx.txt This snippet details how to build the ThreadX demonstration system. It involves opening a specific workspace file, setting the sample project as active, and building it. The process compiles the demonstration application and links it with the ThreadX library, producing an ELF file for the simulator. ```text 1. Open the threadx.www workspace file. 2. Make the sample_threadx.ewp project the "active project". 3. Select the "Make" button. ``` -------------------------------- ### Build ThreadX Demonstration System using Batch Script Source: https://github.com/stmicroelectronics/stm32cubeh5/blob/main/Middlewares/ST/threadx/ports/cortex_m0/gnu/readme_threadx.txt This batch script compiles the ThreadX demonstration application ('sample_threadx.c') and links it with the ThreadX run-time library ('tx.a'). The output is a binary file ('sample_threadx.out') suitable for simulation or direct download to a target board. ```batch call build_threadx_sample.bat ``` -------------------------------- ### Provision IoT Device using X509 Certificate (C) Source: https://github.com/stmicroelectronics/stm32cubeh5/blob/main/Middlewares/ST/netxduo/addons/azure_iot/azure-sdk-for-c/sdk/samples/iot/README.md This C sample registers a device with the Azure IoT Device Provisioning Service using X509 certificate authentication. The sample waits for the registration status before disconnecting. It's a common pattern for secure device onboarding. ```c #include "azure/azx_iot_provisioning_sample.h" // Sample code for IoT Provisioning with X509 certificate // ... (details omitted for brevity) ``` -------------------------------- ### XML Parameter Configuration Example Source: https://github.com/stmicroelectronics/stm32cubeh5/blob/main/Utilities/PC_Software/ROT_AppliConfig/README.md Illustrates the structure and content of an XML file used by the 'iofile' tool. It shows how parameters like 'Encryption key' and 'Firmware binary input file' are defined and their values can be updated. ```xml Encryption key GetPublic File -E 1 1 Firmware binary input file ../../ROT_Appli_TrustZone/EWARM/NonSecure/STM32H573I-DK_NS/Exe/Project.bin File ../../ROT_Appli_TrustZone/EWARM/NonSecure/STM32H573I-DK_NS/Exe/Project.bin Select the firmware binary file to be processed for the image generation Image output file ../../ROT_Appli_TrustZone/Binary/rot_tz_ns_app_enc_sign.he ../../ROT_Appli_TrustZone/Binary/rot_tz_ns_app_enc_sign.hex ``` -------------------------------- ### Handle Device-to-Cloud Methods - C Sample Source: https://github.com/stmicroelectronics/stm32cubeh5/blob/main/Middlewares/ST/netxduo/addons/azure_iot/azure-sdk-for-c/sdk/samples/iot/README.md This C code snippet represents the paho_iot_hub_methods_sample, which handles direct method invocations from Azure IoT Hub. It successfully receives up to five method commands and supports a 'ping' method, returning 'pong' on success. X509 authentication is used. ```c // Sample code for paho_iot_hub_methods_sample.c would go here. // This sample receives incoming method commands invoked from Azure IoT Hub. // It supports up to 5 method commands before timing out. // A 'ping' method is supported, returning a JSON payload {"response": "pong"}. // X509 authentication is used. ``` -------------------------------- ### STM32H5 Flash Driver Setup and Usage Example (C) Source: https://github.com/stmicroelectronics/stm32cubeh5/blob/main/Drivers/CMSIS/Documentation/Driver/html/group__flash__interface__gr.html Demonstrates a typical setup sequence for the STM32H5 Flash driver using CMSIS-RTOS2. It includes initialization, power control, data reading, event handling, and uninitialization. This example relies on the 'Driver_Flash.h' and 'cmsis_os2.h' headers. ```c #include "Driver_Flash.h" #include "cmsis_os2.h" // ARM::CMSIS:RTOS2:Keil RTX5 /* Flash driver instance */ extern ARM_DRIVER_FLASH Driver_Flash0; static ARM_DRIVER_FLASH *flashDev = &Driver_Flash0; /* CMSIS-RTOS2 Thread Id */ osThreadId_t Flash_Thread_Id; /* Flash signal event */ void Flash_Callback(uint32_t event) { if (event & ARM_FLASH_EVENT_READY) { /* The read/program/erase operation is completed */ osThreadFlagsSet(Flash_Thread_Id, 1U); } if (event & ARM_FLASH_EVENT_ERROR) { /* The read/program/erase operation is completed with errors */ /* Call debugger or replace with custom error handling */ __breakpoint(0); } } /* CMSIS-RTOS2 Thread */ void Flash_Thread (void *argument) { /* Query drivers capabilities */ const ARM_FLASH_CAPABILITIES capabilities = flashDev->GetCapabilities(); /* Initialize Flash device */ if (capabilities.event_ready) { flashDev->Initialize(&Flash_Callback); } else { flashDev->Initialize(NULL); } /* Power-on Flash device */ flashDev->PowerControl(ARM_POWER_FULL); /* Read data taking data_width into account */ uint8_t buf[256U]; flashDev->ReadData(0x1000U, buf, sizeof(buf) >> capabilities.data_width); /* Wait operation to be completed */ if (capabilities.event_ready) { osThreadFlagsWait (1U, osFlagsWaitAny, 100U); } else { osDelay(100U); } /* Switch off gracefully */ flashDev->PowerControl(ARM_POWER_OFF); flashDev->Uninitialize(); } ``` -------------------------------- ### Provision IoT Device using SAS Token (C) Source: https://github.com/stmicroelectronics/stm32cubeh5/blob/main/Middlewares/ST/netxduo/addons/azure_iot/azure-sdk-for-c/sdk/samples/iot/README.md This C sample registers a device with the Azure IoT Device Provisioning Service using Shared Access Signature (SAS) token authentication. Similar to the X509 version, it waits for registration status before disconnecting, offering an alternative authentication method. ```c #include "azure/azx_iot_provisioning_sas_sample.h" // Sample code for IoT Provisioning with SAS token // ... (details omitted for brevity) ``` -------------------------------- ### Set Linux Environment Variables for IoT Hub SAS Telemetry Source: https://github.com/stmicroelectronics/stm32cubeh5/blob/main/Middlewares/ST/netxduo/addons/azure_iot/azure-sdk-for-c/sdk/samples/iot/README.md This snippet shows how to set environment variables required for the IoT Hub Symmetric Key (SAS) Telemetry sample on Linux systems. These variables include device ID, key, and hostname, which are essential for authenticating with Azure IoT Hub. ```bash export AZ_IOT_HUB_SAS_DEVICE_ID= export AZ_IOT_HUB_SAS_KEY= export AZ_IOT_HUB_HOSTNAME= ``` -------------------------------- ### Key Generation Script (Batch and Shell) Source: https://github.com/stmicroelectronics/stm32cubeh5/blob/main/Projects/NUCLEO-H503RB/ROT_Provisioning/OEMiROT/Readme.html This script is responsible for preparing the authentication and encryption keys required for OEMiROT provisioning. It handles the cryptographic setup for securing the device. ```batch REM OEMiROT/keygen.bat REM This script generates authentication and encryption keys. @echo off echo Generating keys... REM Placeholder for actual key generation commands echo Key generation script executed. ``` ```shell #!/bin/bash # OEMiROT/keygen.sh # This script generates authentication and encryption keys. echo "Generating keys..." # Placeholder for actual key generation commands echo "Key generation script executed." ``` -------------------------------- ### Build ThreadX Demonstration System (Batch) Source: https://github.com/stmicroelectronics/stm32cubeh5/blob/main/Middlewares/ST/threadx/ports/cortex_m0/ac5/readme_threadx.txt This script compiles and links the ThreadX demonstration application (sample_threadx.c) with the run-time library (tx.a). The output is an executable file (sample_threadx.axf) suitable for the ARM Windows-based simulator. ```batch build_threadx_sample.bat ``` -------------------------------- ### Configure Paho MQTT for ECC Server Certificate Chain (C) Source: https://github.com/stmicroelectronics/stm32cubeh5/blob/main/Middlewares/ST/netxduo/addons/azure_iot/azure-sdk-for-c/sdk/samples/iot/README.md This C code snippet demonstrates how to configure Paho MQTT for Embedded C to use an ECC server certificate chain. It modifies the TLS options to prevent RSA cipher-suites from being advertised, ensuring compatibility with newer TLS security standards. ```c mqtt_ssl_options.enabledCipherSuites = "ECDH+ECDSA+HIGH"; ``` -------------------------------- ### Connect IoT PnP Device with Multiple Components (C) Source: https://github.com/stmicroelectronics/stm32cubeh5/blob/main/Middlewares/ST/netxduo/addons/azure_iot/azure-sdk-for-c/sdk/samples/iot/README.md This C sample demonstrates connecting an IoT Plug and Play enabled device with multiple components to Azure IoT Hub. It uses X509 authentication and is designed to simulate a temperature controller. The sample's components are detailed in separate DTDL models. ```c #include "azure/azx_iot_pnp_component_sample.h" // Sample code for IoT Plug and Play Multiple Component // ... (details omitted for brevity) ``` -------------------------------- ### PowerShell: Build Examples Matching Multiple Names Source: https://github.com/stmicroelectronics/stm32cubeh5/blob/main/Middlewares/ST/threadx/test/ports/README.md Builds embedded examples that match multiple specified names using the azrtos_cicd.ps1 script. The '-MatchName' parameter can accept multiple string arguments for pattern matching. This example builds examples matching both 'Modules' and 'IAR'. Assumes execution from the Windows Command Interpreter. ```powershell pwsh -Command .\azrtos_cicd.ps1 -MatchName 'Modules','IAR' -build ``` -------------------------------- ### Set Windows PowerShell Environment Variables for IoT Provisioning SAS Source: https://github.com/stmicroelectronics/stm32cubeh5/blob/main/Middlewares/ST/netxduo/addons/azure_iot/azure-sdk-for-c/sdk/samples/iot/README.md This PowerShell snippet sets the environment variables needed for the IoT Provisioning Symmetric Key (SAS) sample on Windows. It configures the registration ID, SAS key, and ID scope for authenticating with the Azure IoT Hub Device Provisioning Service. ```powershell $env:AZ_IOT_PROVISIONING_SAS_REGISTRATION_ID='' $env:AZ_IOT_PROVISIONING_SAS_KEY='' $env:AZ_IOT_PROVISIONING_ID_SCOPE='' ``` -------------------------------- ### Set Windows PowerShell Environment Variables for IoT Hub SAS Telemetry Source: https://github.com/stmicroelectronics/stm32cubeh5/blob/main/Middlewares/ST/netxduo/addons/azure_iot/azure-sdk-for-c/sdk/samples/iot/README.md This snippet demonstrates how to set environment variables for the IoT Hub Symmetric Key (SAS) Telemetry sample on Windows using PowerShell. It covers setting the device ID, key, and hostname necessary for Azure IoT Hub authentication. ```powershell $env:AZ_IOT_HUB_SAS_DEVICE_ID='' $env:AZ_IOT_HUB_SAS_KEY='' $env:AZ_IOT_HUB_HOSTNAME='' ``` -------------------------------- ### CMake: Basic Project Setup and Subdirectory Inclusion Source: https://github.com/stmicroelectronics/stm32cubeh5/blob/main/Drivers/CMSIS/Documentation/DSP/html/Examples_2ARM_2arm__signal__converge__example_2CMakeLists_8txt.html This snippet demonstrates the fundamental CMake commands for setting up a project. It defines the minimum required CMake version, names the project, and includes external subdirectories, likely containing source code or modules. The `set` command is used to define variables like the DSP path. ```cmake cmake_minimum_required (VERSION 3.14) project(arm_signal_convergence_example VERSION 0.1) set (ROOT "$") set (DSP ${ROOT}/CMSIS/DSP) add_subdirectory (../../../Source bin_dsp) add_executable(arm_signal_convergence_example) include(config) configApp(arm_signal_convergence_example $) ``` -------------------------------- ### Set Linux Environment Variables for IoT Provisioning SAS Source: https://github.com/stmicroelectronics/stm32cubeh5/blob/main/Middlewares/ST/netxduo/addons/azure_iot/azure-sdk-for-c/sdk/samples/iot/README.md This code configures the necessary environment variables for the IoT Provisioning Symmetric Key (SAS) sample on Linux. It includes setting the registration ID, SAS key, and ID scope required for device provisioning through Azure IoT Hub Device Provisioning Service. ```bash export AZ_IOT_PROVISIONING_SAS_REGISTRATION_ID= export AZ_IOT_PROVISIONING_SAS_KEY= export AZ_IOT_PROVISIONING_ID_SCOPE= ``` -------------------------------- ### System Initialization in C (STM32CubeH5) Source: https://github.com/stmicroelectronics/stm32cubeh5/blob/main/Projects/STM32H573I-DK/Examples/DLYB/DLYB_OSPI_NOR_FastTuning/readme.html This C code snippet demonstrates the basic system initialization process for an STM32H5 microcontroller. It is typically part of the main application entry point and configures essential system peripherals. ```c /** * @brief System Clock Configuration * @param None * @retval None */ void SystemClock_Config(void) { RCC_OscInitTypeDefOscInitStruct = {0}; RCC_ClkInitTypeDefClkInitStruct = {0}; /** Configure the main internal regulator output voltage */ if (HAL_PWREx_ControlVoltageScaling(PWR_REGULATOR_VOLTAGE_SCALE1) != HAL _OK) { Error_Handler(); } /** Initializes the RCC Oscillators according to the specified parameters * in the RCC_OscInitTypeDef structure. */ OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE; OscInitStruct.HSEState = RCC_HSE_ON; if (HAL_RCC_OscConfig(&OscInitStruct)!= HAL_OK) { Error_Handler(); } /** Initializes the CPU, AHB and APB buses clocks */ ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK |RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2; ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_HSE; ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1; ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1; if (HAL_RCC_ClockConfig(&ClkInitStruct, FLASH_LATENCY_0)!= HAL_OK) { Error_Handler(); } } /** * @brief Peripherals Clock Enable * @param None * @retval None */ void MX_GPIO_Init(void) { /* USER CODE BEGIN MX_GPIO_Init_1 */ /* USER CODE END MX_GPIO_Init_1 */ /* GPIO Ports Clock Enable */ __HAL_RCC_GPIOF_CLK_ENABLE(); __HAL_RCC_GPIOH_CLK_ENABLE(); __HAL_RCC_GPIOA_CLK_ENABLE(); __HAL_RCC_GPIOB_CLK_ENABLE(); __HAL_RCC_GPIOC_CLK_ENABLE(); __HAL_RCC_GPIOD_CLK_ENABLE(); /* USER CODE BEGIN MX_GPIO_Init_2 */ /* USER CODE END MX_GPIO_Init_2 */ } ```