### STM32CubeWL Sigfox Push Button Hardware and Software Environment Setup
Source: https://github.com/stmicroelectronics/stm32cubewl/blob/main/Projects/NUCLEO-WL55JC1/Applications/Sigfox/Sigfox_PushButton/readme.txt
Details the required hardware (STM32WL55JC1 Nucleo board) and software configuration steps for running the Sigfox Push Button example, including physical connections and general software setup.
```APIDOC
@par Hardware and Software environment
- This example runs on the STM32WL55JC1 (HIGH-BAND) Nucleo board. STM32WL55JC2 (LOW-BAND) devices are not suitable.
- STM32WL55JC1 Nucleo board Set-up
- Connect the Nucleo board to your PC with a USB cable type A to micro-B
to ST-LINK connector.
- Please ensure that the ST-LINK connector jumpers are fitted.
- Configure the software via the configuration files:
- sys_conf.h, radio_conf.h, mw_log_conf.h, main.h, etc
```
--------------------------------
### Install Cryptographic Example Executables
Source: https://github.com/stmicroelectronics/stm32cubewl/blob/main/Middlewares/Third_Party/mbed-crypto/programs/pkey/CMakeLists.txt
This CMake command specifies the installation rules for a selection of the previously defined cryptographic example executables. It designates the `bin` directory as the destination and sets specific file permissions (read, write, execute) for the owner, group, and world, ensuring the executables are properly deployed and accessible.
```CMake
install(TARGETS dh_genprime key_app mpi_demo rsa_genkey rsa_sign rsa_verify rsa_encrypt rsa_decrypt pk_encrypt pk_decrypt pk_sign pk_verify gen_key
DESTINATION "bin"
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
```
--------------------------------
### Define Example Project in CMSIS-Pack PDSC
Source: https://github.com/stmicroelectronics/stm32cubewl/blob/main/Drivers/CMSIS/docs/Pack/html/createPack_DFP.html
This XML snippet defines an example project named 'Dummy' within a CMSIS-Pack Description (PDSC) file. It specifies the project's documentation, folder path, target board ('MVCM3 Starter Kit'), development environment ('uv' for µVision), and categorizes it under 'Getting Started'.
```XML
Dummy project
Getting Started
```
--------------------------------
### Page Initialization and Search Box Setup
Source: https://github.com/stmicroelectronics/stm32cubewl/blob/main/Drivers/CMSIS/docs/Pack/html/pack_Example.html
JavaScript snippets for initializing page elements, resizing, and setting up the search box functionality on document load. These scripts ensure the user interface is properly rendered and interactive.
```JavaScript
$(document).ready(initResizable); $(window).load(resizeHeight);
```
```JavaScript
$(document).ready(function() { searchBox.OnSelectItem(0); });
```
```JavaScript
var searchBox = new SearchBox("searchBox", "search",false,'Search');
```
```JavaScript
$(document).ready(function(){initNavTree('pack_Example.html','');});
```
--------------------------------
### Doxygen UI Initialization and Search Box Setup
Source: https://github.com/stmicroelectronics/stm32cubewl/blob/main/Drivers/CMSIS/docs/SVD/html/svd_Example_pg.html
JavaScript code generated by Doxygen for initializing UI elements, handling window resizing, setting up the search box functionality, and initializing the navigation tree within the documentation.
```JavaScript
$(document).ready(initResizable); $(window).load(resizeHeight);
```
```JavaScript
$(document).ready(function() { searchBox.OnSelectItem(0); });
```
```JavaScript
var searchBox = new SearchBox("searchBox", "search",false,'Search');
```
```JavaScript
$(document).ready(function(){initNavTree('svd_Example_pg.html','');});
```
--------------------------------
### Example: Initializing and Starting CMSIS-RTOS Kernel
Source: https://github.com/stmicroelectronics/stm32cubewl/blob/main/Drivers/CMSIS/docs/RTOS2/html/group__CMSIS__RTOS__KernelCtrl.html
Demonstrates the typical usage of osKernelInitialize and osKernelStart within a main function. It checks the kernel state before initialization and starting, ensuring proper RTOS setup.
```C
int main (void) {
// System Initialization
SystemCoreClockUpdate();
// ...
if(osKernelGetState() == osKernelInactive) {
osKernelInitialize();
}
; // ... Start Threads
if (osKernelGetState() == osKernelReady) { // If kernel is ready to run...
osKernelStart(); // ... start thread execution
}
while(1); // only reached in case of error
}
```
--------------------------------
### STM32CubeWL Sigfox Push Button Application Usage Guide
Source: https://github.com/stmicroelectronics/stm32cubewl/blob/main/Projects/NUCLEO-WL55JC1/Applications/Sigfox/Sigfox_PushButton/readme.txt
Provides step-by-step instructions on how to compile, load, run, and interact with the Sigfox Push Button application, including terminal configuration details for communication.
```APIDOC
@par How to use it ?
In order to make the program work, you must do the following :
- Open your preferred toolchain
- Rebuild all files and load your image into target memory
- Run the example
- Open a Terminal, connected the Sigfox Object
- UART Config = 9600, 8b, 1 stopbit, no parity, no flow control
- Terminal Config: Select 'CR+LF' for Transmit New-Line and switch 'Local echo' on
- Push Button 1 (it will send a sigfox message, Blue LED blinking)
```
--------------------------------
### No Code Snippets Found
Source: https://github.com/stmicroelectronics/stm32cubewl/blob/main/Projects/NUCLEO-WL55JC/Examples/I2C/I2C_WakeUpFromStop2/readme.txt
The provided text describes project structure, hardware setup, and usage instructions, but does not contain any executable code snippets or API definitions.
--------------------------------
### Import and manage a key in Mbed Crypto
Source: https://github.com/stmicroelectronics/stm32cubewl/blob/main/Middlewares/Third_Party/mbed-crypto/docs/getting_started.md
Illustrates the process of importing a key into a specific slot using `psa_import_key`, retrieving its type and bit size with `psa_get_key_information`, and finally destroying it with `psa_destroy_key`. It also shows the necessary initialization with `psa_crypto_init()` and cleanup with `mbedtls_psa_crypto_free()`.
```C
int key_slot = 1;
uint8_t *data = "KEYPAIR_KEY_DATA";
size_t data_size;
psa_key_type_t type = PSA_KEY_TYPE_RSA_PUBLIC_KEY;
size_t got_bits;
psa_key_type_t got_type;
size_t expected_bits = data_size;
psa_key_type_t type = PSA_KEY_TYPE_RAW_DATA;
size_t export_size = data_size;
psa_crypto_init();
/* Import the key */
status = psa_import_key(key_slot, type, data, data_size);
/* Test the key information */
status = psa_get_key_information(slot, &got_type, &got_bits);
/* Destroy the key */
psa_destroy_key(key_slot);
mbedtls_psa_crypto_free();
```
--------------------------------
### Mbed Crypto PSA API Reference
Source: https://github.com/stmicroelectronics/stm32cubewl/blob/main/Middlewares/Third_Party/mbed-crypto/docs/getting_started.md
Reference for core Mbed Crypto PSA API functions and key types. These functions are essential for initializing the library, managing cryptographic keys, and cleaning up resources.
```APIDOC
psa_crypto_init(): Initializes the Mbed Crypto library. Must be called before any other API.
psa_import_key(key_slot: int, type: psa_key_type_t, data: uint8_t*, data_size: size_t): Imports a key into a specified key slot.
psa_get_key_information(slot: int, got_type: psa_key_type_t*, got_bits: size_t*): Retrieves information (type and bit size) about a key stored in a slot.
psa_destroy_key(key_slot: int): Destroys the key stored in the specified key slot, freeing resources.
mbedtls_psa_crypto_free(): Frees resources used by the Mbed Crypto library.
PSA_KEY_TYPE_RSA_PUBLIC_KEY: Constant representing an RSA public key type.
PSA_KEY_TYPE_RAW_DATA: Constant representing raw data key type.
```
--------------------------------
### XML Example: Target Memory Configuration
Source: https://github.com/stmicroelectronics/stm32cubewl/blob/main/Drivers/CMSIS/docs/Pack/html/cpdsc_pg.html
This XML snippet demonstrates the configuration of a memory region within a target, specifying its access rights, default state, initialization, name, size, and start address. It's an example of the `` element.
```XML
```
--------------------------------
### Example Project Component Selection XML
Source: https://github.com/stmicroelectronics/stm32cubewl/blob/main/Drivers/CMSIS/docs/Pack/html/cpdsc_pg.html
An example of the 'project' element content, demonstrating the selection of various software components and their associated configuration files within an embedded project setup.
```XML
```
--------------------------------
### Example of Starting a CMSIS-RTOS Timer
Source: https://github.com/stmicroelectronics/stm32cubewl/blob/main/Drivers/CMSIS/docs/RTOS/html/group__CMSIS__RTOS__TimerMgmt.html
This C code demonstrates how to start a CMSIS-RTOS timer using osTimerStart. It includes the timer callback function definition and the main example function that initializes and starts a timer.
```C
#include "cmsis_os.h"
void Time_Callback (void const *arg) { // timer callback function
// arg contains &exec
// called every second after osTimerStart
}
osTimerDef (Timer, Time_Callback); // define timer
uint32_t exec; // argument for the timer call back function
void TimerStart_example (void) {
osTimerId id; // timer id
uint32_t timerDelay; // timer value
osStatus status; // function return status
// Create periodic timer
exec = 1;
```
--------------------------------
### Hardware and Software Environment Setup for STM32WL Sigfox
Source: https://github.com/stmicroelectronics/stm32cubewl/blob/main/Projects/NUCLEO-WL55JC1/Applications/Sigfox/Sigfox_AT_Slave/readme.txt
Outlines the specific hardware requirements, including the STM32WL55JC1 Nucleo board, and initial software configuration steps necessary to run the Sigfox AT Slave example.
```APIDOC
@par Hardware and Software environment
- This example runs on the STM32WL55JC1 (HIGH-BAND) Nucleo board. STM32WL55JC2 (LOW-BAND) devices are not suitable.
- STM32WL55JC1 Nucleo board Set-up
- Connect the Nucleo board to your PC with a USB cable type A to micro-B
to ST-LINK connector.
- Please ensure that the ST-LINK connector jumpers are fitted.
- Configure the software via the configuration files:
- sys_conf.h, radio_conf.h, mw_log_conf.h, main.h, etc
-Set Up:
-------------------------- V V --------------------------
| Sigfox Object | | | | Sigfox Network |
| | | | | |
ComPort<--| |--| |--| |-->Web Server
| | | |
-------------------------- --------------------------
```
--------------------------------
### APIDOC: Hashing Message Overview
Source: https://github.com/stmicroelectronics/stm32cubewl/blob/main/Middlewares/Third_Party/mbed-crypto/docs/getting_started.md
Provides an overview of message hashing using Mbed Crypto, listing supported algorithms and prerequisites. It outlines the general steps for calculating or verifying a hash using the PSA API.
```APIDOC
Supported Hash Algorithms:
- MD2
- MD4
- MD5
- RIPEMD160
- SHA-1
- SHA-224
- SHA-256
- SHA-384
- SHA-512
Prerequisites:
- Initialize the library with a successful call to `psa_crypto_init`.
Steps to Calculate a Hash:
1. Allocate an operation structure (`psa_hash_operation_t`).
2. Call `psa_hash_setup` to initialize the operation structure and specify the hash algorithm.
3. Call `psa_hash_update` one or more times, passing either the whole or a fragment of the message.
4. Call `psa_hash_finish` to calculate the hash, or `psa_hash_verify` to compare the computed hash with an expected hash value.
Utility Macro:
- `PSA_HASH_SIZE(alg)`: Returns the expected hash length (in bytes) for the specified algorithm.
```
--------------------------------
### C Example: Initialize WiFi and Get Module Information
Source: https://github.com/stmicroelectronics/stm32cubewl/blob/main/Drivers/CMSIS/docs/Driver/html/group__wifi__control__gr.html
Demonstrates how to initialize the WiFi module, power it on, and then retrieve its module information using the ARM_DRIVER_WIFI interface and the GetModuleInfo function. It shows typical setup for an embedded system.
```C
extern ARM_DRIVER_WIFI Driver_WiFi0;
static ARM_DRIVER_WIFI *wifi;
void initialize_wifi (void) {
char info[32];
wifi = &Driver_WiFi0;
// Initialize and Power-on WiFi Module
wifi->Initialize (NULL);
wifi->PowerControl (ARM_POWER_FULL);
// Retrieve module information
wifi->GetModuleInfo(&info, sizeof(info));
}
```
--------------------------------
### Provide Board Documentation Links
Source: https://github.com/stmicroelectronics/stm32cubewl/blob/main/Drivers/CMSIS/docs/Pack/html/pdsc_boards_pg.html
Provides information about documentation parts related to a development board, such as user manuals or getting started guides. This element is part of the '/package/boards/board' structure. At least one book must be defined.
```XML
```
```APIDOC
Element: book
Parent: /package/boards/board
Attributes:
category: (Type: , Use: )
name: (Type: , Use: )
title: (Type: , Use: )
```
--------------------------------
### Doxygen Page Initialization and Search Box Setup
Source: https://github.com/stmicroelectronics/stm32cubewl/blob/main/Drivers/CMSIS/docs/DAP/html/group__DAP__Connect.html
These JavaScript snippets handle the initialization of the Doxygen-generated documentation page. They manage UI elements like resizing, setting up the search box functionality, and initializing the navigation tree for specific groups.
```JavaScript
$(document).ready(initResizable); $(window).load(resizeHeight); $(document).ready(function() { searchBox.OnSelectItem(0); });
```
```JavaScript
var searchBox = new SearchBox("searchBox", "search",false,'Search');
```
```JavaScript
$(document).ready(function(){initNavTree('group__DAP__Connect.html','');});
```
--------------------------------
### C: Example to Start a CMSIS-RTOS Timer
Source: https://github.com/stmicroelectronics/stm32cubewl/blob/main/Drivers/CMSIS/docs/RTOS2/html/group__CMSIS__RTOS__TimerMgmt.html
This C code example demonstrates how to create a periodic timer using osTimerNew and then start it with osTimerStart. It includes a callback function that executes periodically.
```C
#include "cmsis_os2.h"
void Timer_Callback (void *arg) { // timer callback function
// arg contains &exec
// called every second after osTimerStart
}
uint32_t exec; // argument for the timer call back function
void TimerStart_example (void) {
osTimerId_t id; // timer id
uint32_t timerDelay; // timer value
osStatus_t status; // function return status
// Create periodic timer
exec = 1U;
id = osTimerNew(Timer_Callback, osTimerPeriodic, &exec, NULL);
if (id != NULL) {
timerDelay = 1000U;
status = osTimerStart(id, timerDelay); // start timer
if (status != osOK) {
// Timer could not be started
}
}
}
```
--------------------------------
### Example: Basic CMSIS-RTOS Timer Creation Setup
Source: https://github.com/stmicroelectronics/stm32cubewl/blob/main/Drivers/CMSIS/docs/RTOS/html/group__CMSIS__RTOS__TimerMgmt.html
This example demonstrates the initial setup for creating CMSIS-RTOS timers. It includes necessary header, prototypes for timer callback functions, osTimerDef calls to define timers, and declaration of variables for timer IDs and callback arguments within an example function.
```C
#include "cmsis_os.h"
void Timer1_Callback (void const *arg);
void Timer2_Callback (void const *arg);
osTimerDef (Timer1, Timer1_Callback);
osTimerDef (Timer2, Timer2_Callback);
uint32_t exec1;
uint32_t exec2;
void TimerCreate_example (void) {
osTimerId id1;
osTimerId id2;
// Create one-shoot timer
exec1 = 1;
}
```
--------------------------------
### Page Initialization and Search Box Setup
Source: https://github.com/stmicroelectronics/stm32cubewl/blob/main/Drivers/CMSIS/docs/Pack/html/configWizard.html
These JavaScript snippets handle the initial setup of the web page, including resizing elements, initializing the search box functionality, and setting up navigation trees. They are standard Doxygen-generated scripts.
```JavaScript
$(document).ready(initResizable); $(window).load(resizeHeight);
```
```JavaScript
$(document).ready(function() { searchBox.OnSelectItem(0); });
```
```JavaScript
var searchBox = new SearchBox("searchBox", "search",false,'Search');
```
```JavaScript
$(document).ready(function(){initNavTree('configWizard.html','');});
```
--------------------------------
### Build Mbed Crypto with custom C compiler and archiver
Source: https://github.com/stmicroelectronics/stm32cubewl/blob/main/Middlewares/Third_Party/mbed-crypto/docs/getting_started.md
Demonstrates how to build the Mbed Crypto library using `make` while specifying a custom C compiler (CC) and archiver (AR) for cross-compilation or specific toolchain requirements. This command overrides the default `cc` and `ar` tools.
```Shell
make CC=arm-linux-gnueabi-gcc AR=arm-linux-gnueabi-ar
```
--------------------------------
### STM32CubeWL Sigfox Push Button Debugging Guide
Source: https://github.com/stmicroelectronics/stm32cubewl/blob/main/Projects/NUCLEO-WL55JC1/Applications/Sigfox/Sigfox_PushButton/readme.txt
Outlines the necessary configuration flags and steps for debugging the Sigfox Push Button application, focusing on enabling the debugger and disabling low power modes for easier analysis.
```APIDOC
@par How to debug ?
- make sure the flag DEBUGGER_ENABLED to 1 in sys_conf.h
- simpler to define the flag LOW_POWER_DISABLE to 1 as well
- compile, download and attach
```
--------------------------------
### JavaScript UI Initialization and Search Setup
Source: https://github.com/stmicroelectronics/stm32cubewl/blob/main/Drivers/CMSIS/docs/Driver/html/globals_defs_m.html
These JavaScript snippets manage the initial setup of the documentation page's user interface, including window resizing, search box instantiation, search item selection, and navigation tree initialization.
```JavaScript
$(document).ready(initResizable); $(window).load(resizeHeight);
```
```JavaScript
$(document).ready(function() { searchBox.OnSelectItem(0); });
```
```JavaScript
var searchBox = new SearchBox("searchBox", "search",false,'Search');
```
```JavaScript
$(document).ready(function(){initNavTree('globals_defs_m.html','');});
```
--------------------------------
### Doxygen UI Initialization Scripts
Source: https://github.com/stmicroelectronics/stm32cubewl/blob/main/Drivers/CMSIS/docs/Zone/html/fm_mpc_setup.html
These JavaScript snippets are used for initializing the user interface elements of the Doxygen-generated documentation, including search box functionality, navigation tree setup, and window resizing handlers.
```JavaScript
$(document).ready(initResizable);
$(window).load(resizeHeight);
$(document).ready(function() { searchBox.OnSelectItem(0); });
var searchBox = new SearchBox("searchBox", "search",false,'Search');
$(document).ready(function(){initNavTree('fm_mpc_setup.html','');});
```
--------------------------------
### C Example: Get FatFs Volume Label
Source: https://github.com/stmicroelectronics/stm32cubewl/blob/main/Middlewares/Third_Party/FatFs/doc/en/getlabel.html
This C code example demonstrates how to use the `f_getlabel` function to retrieve the volume label. It shows two common scenarios: getting the label for the default drive and for a specific drive (drive 2).
```C
char str[24];
/* Get volume label of the default drive */
f_getlabel("", str, 0);
/* Get volume label of the drive 2 */
f_getlabel("2:", str, 0);
```
--------------------------------
### JavaScript Webpage Initialization and Search Box Setup
Source: https://github.com/stmicroelectronics/stm32cubewl/blob/main/Drivers/CMSIS/docs/Core/html/startup_s_pg.html
These JavaScript snippets handle basic webpage initialization tasks, including resizing elements, initializing a search box, and setting up navigation tree functionality. They are part of the Doxygen-generated documentation's interactive features.
```JavaScript
$(document).ready(initResizable); $(window).load(resizeHeight);
```
```JavaScript
$(document).ready(function() { searchBox.OnSelectItem(0); });
```
```JavaScript
var searchBox = new SearchBox("searchBox", "search",false,'Search');
```
```JavaScript
$(document).ready(function(){initNavTree('startup_s_pg.html','');});
```
--------------------------------
### Page Initialization and Search Box Setup
Source: https://github.com/stmicroelectronics/stm32cubewl/blob/main/Drivers/CMSIS/docs/Pack/html/element_taxonomy.html
These JavaScript snippets handle the initial setup of the web page, including resizing elements, initializing a search box, and setting up navigation tree functionality. They rely on jQuery for DOM manipulation.
```JavaScript
$(document).ready(initResizable); $(window).load(resizeHeight);
```
```JavaScript
$(document).ready(function() { searchBox.OnSelectItem(0); });
```
```JavaScript
var searchBox = new SearchBox("searchBox", "search",false,'Search');
```
```JavaScript
$(document).ready(function(){initNavTree('element_taxonomy.html','');});
```
--------------------------------
### STM32WL Dual-Core Security Illegal Access Example Flow
Source: https://github.com/stmicroelectronics/stm32cubewl/blob/main/Projects/NUCLEO-WL55JC/Examples/PWR/PWR_SecurityIllegalAccess_DualCore/readme.txt
Detailed description of the setup, execution flow for CPU1 and CPU2, and peripheral interactions for the PWR_SecurityIllegalAccess_DualCore example. This outlines the system's behavior and hardware API usage.
```APIDOC
Example: PWR_SecurityIllegalAccess_DualCore
Purpose: Manage illegal access in multicore program and low-power modes.
Demonstrates: CPU2 boot/wake up sources (normal vs. illegal access).
Preliminary Steps:
1. Flash Memory Loading:
- Load CPU1 program, then execute (initiates CPU2 boot).
- Load CPU2 program.
- Perform system reset (or SW reset of CPU2).
2. Option Bytes Modification:
- Flash security enabled (FSD = 0), SFSA = 0x40 (half Flash).
- SRAM2 security configured (SBRSA = 0x10, BRSD = 0) to match linker.
- Expected system security status: ESE = 1 (set automatically).
CPU1 Program Execution:
1. Initial State: CPU1 boots, CPU2 remains in reset.
2. Configuration: System clock, CPU1-allocated GPIO (LED1, B1, LED3).
3. Security Check:
- If security activated: Toggle LED1 quickly (10Hz) for 2 sec.
- Else (error): Turn on LED3.
4. Idle State: Toggle LED1 slowly (1Hz), waiting for user action.
5. Illegal Access Event:
- User button B1 press triggers CPU1 to perform illegal access (write to GTZC register).
- LED1 turned on for 2 sec.
6. Loop: Steps 4 and 5 repeat indefinitely.
CPU2 Program Execution:
1. Boot Source: CPU2 boots by GTZC peripheral or CPU1.
2. Configuration: CPU2-allocated GPIO (LED2).
3. Boot Source Check:
- If normal boot (by CPU1, intermediate phase before security activation):
- Go to error handler (toggle LED2 slowly (1Hz) indefinitely).
- If illegal access boot (by GTZC peripheral):
- Use GTZC to process illegal access event, retrieve source.
- If expected source (illegal access to GTZC peripheral): Toggle LED2 quickly (10Hz) for 2 sec.
- Else (error): Go to error handler (toggle LED2 slowly (1Hz) indefinitely).
4. Low-Power Mode: Enter CPU Stop mode (CStop).
- Note: System remains in Run mode if CPU1 is in CRun.
- Note: CPU2 entering DeepSleep (after illegal access) exits illegal access mode and resets CPU2.
5. Loop: At next illegal access, restart from step 1.
Peripherals Used:
- GPIO: LED1 (CPU1 activity), B1 (illegal access generation), LED2 (CPU2 activity/error), LED3 (CPU1 error).
Notes:
- HAL_Delay() considerations: SysTick ISR priority must be higher than peripheral ISRs if called from them.
- SysTick time base must be 1ms for correct HAL operation.
- Disabling Security (reset to initial state):
1. Set RDP level to 0xBB.
2. Program option bytes.
3. Set RDP level to 0xAA, disable system security (ESE=0).
4. Program option bytes.
```
--------------------------------
### JavaScript Page Initialization and Navigation Setup
Source: https://github.com/stmicroelectronics/stm32cubewl/blob/main/Drivers/CMSIS/docs/DSP/html/arm__variance__example_2Abstract_8txt.html
These JavaScript snippets, utilizing jQuery, handle various page initialization tasks. They ensure elements are resized, search box items are selected, and the navigation tree is properly set up once the document is ready or the window has loaded.
```JavaScript
$(document).ready(initResizable);
$(window).load(resizeHeight);
$(document).ready(function() { searchBox.OnSelectItem(0); });
$(document).ready(function(){initNavTree('arm__variance__example_2Abstract__8txt.html','');});
```
--------------------------------
### Install Key Ladder Demo Shell Script in CMake
Source: https://github.com/stmicroelectronics/stm32cubewl/blob/main/Middlewares/Third_Party/mbed-crypto/programs/psa/CMakeLists.txt
This snippet uses the `install` command with the `PROGRAMS` keyword to install the `key_ladder_demo.sh` shell script into the 'bin' directory. This ensures that auxiliary scripts are deployed alongside the main executables.
```CMake
install(PROGRAMS
key_ladder_demo.sh
DESTINATION "bin")
```
--------------------------------
### Verify SHA-256 Hash in C
Source: https://github.com/stmicroelectronics/stm32cubewl/blob/main/Middlewares/Third_Party/mbed-crypto/docs/getting_started.md
Illustrates how to verify the SHA-256 hash of a message against an expected hash value using the Mbed Crypto PSA API in C. It covers setting up the hash operation, updating with input, and using `psa_hash_verify` for comparison.
```C
psa_algorithm_t alg = PSA_ALG_SHA_256;
psa_hash_operation_t operation;
unsigned char input[] = { 'a', 'b', 'c' };
unsigned char expected_hash[] = {
0xba, 0x78, 0x16, 0xbf, 0x8f, 0x01, 0xcf, 0xea, 0x41, 0x41, 0x40, 0xde,
0x5d, 0xae, 0x22, 0x23, 0xb0, 0x03, 0x61, 0xa3, 0x96, 0x17, 0x7a, 0x9c,
0xb4, 0x10, 0xff, 0x61, 0xf2, 0x00, 0x15, 0xad
};
size_t expected_hash_len = PSA_HASH_SIZE(alg);
/* Verify message hash */
psa_hash_setup(&operation, alg);
psa_hash_update(&operation, input, sizeof(input));
psa_hash_verify(&operation, expected_hash, expected_hash_len);
```
--------------------------------
### Initialize and Start CMSIS-RTOS Kernel in C
Source: https://github.com/stmicroelectronics/stm32cubewl/blob/main/Drivers/CMSIS/docs/RTOS/html/group__CMSIS__RTOS__KernelCtrl.html
This C code snippet demonstrates the basic initialization and starting sequence for a CMSIS-RTOS kernel. It initializes the RTOS, allows for peripheral setup and thread creation, and then starts the RTOS kernel to begin thread execution.
```C
int main (void) {
osKernelInitialize (); // initialize CMSIS-RTOS
// initialize peripherals here
// create 'thread' functions that start executing,
// example: tid_name = osThreadCreate (osThread(name), NULL);
osKernelStart (); // start thread execution
}
```
--------------------------------
### JavaScript: Initialize Page and Search Box
Source: https://github.com/stmicroelectronics/stm32cubewl/blob/main/Drivers/CMSIS/docs/SVD/html/elem_peripherals.html
These JavaScript snippets handle the initial setup of the web page, including resizing elements, initializing a search box, and setting up navigation trees. They ensure the page is interactive and responsive upon loading.
```JavaScript
$(document).ready(initResizable); $(window).load(resizeHeight);
```
```JavaScript
$(document).ready(function() { searchBox.OnSelectItem(0); });
```
```JavaScript
var searchBox = new SearchBox("searchBox", "search",false,'Search');
```
```JavaScript
$(document).ready(function(){initNavTree('elem_peripherals.html','');});
```
```JavaScript
javascript:searchBox.CloseResultsWindow\(\)
```
--------------------------------
### Install Cryptographic Executables in CMake
Source: https://github.com/stmicroelectronics/stm32cubewl/blob/main/Middlewares/Third_Party/mbed-crypto/programs/psa/CMakeLists.txt
This snippet uses the `install` command to specify the installation location for the compiled executables: `crypto_examples`, `key_ladder_demo`, and `psa_constant_names`. They are placed in the 'bin' directory with specific file permissions, making them executable by various user groups.
```CMake
install(TARGETS
crypto_examples
key_ladder_demo
psa_constant_names
DESTINATION "bin"
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
```
--------------------------------
### JavaScript Page Initialization and Search Box Setup
Source: https://github.com/stmicroelectronics/stm32cubewl/blob/main/Drivers/CMSIS/docs/Pack/html/packFormat.html
Collection of JavaScript snippets for document readiness, window loading, search box instantiation, and navigation tree initialization, commonly used in web page setup.
```JavaScript
$(document).ready(initResizable); $(window).load(resizeHeight);
```
```JavaScript
$(document).ready(function() { searchBox.OnSelectItem(0); });
```
```JavaScript
var searchBox = new SearchBox("searchBox", "search",false,'Search');
```
```JavaScript
$(document).ready(function(){initNavTree('packFormat.html','');});
```
--------------------------------
### Derive AES-CTR Key using HKDF with Mbed Crypto (C)
Source: https://github.com/stmicroelectronics/stm32cubewl/blob/main/Middlewares/Third_Party/mbed-crypto/docs/getting_started.md
This example illustrates the process of deriving a new AES-CTR 128-bit encryption key from an existing key using HKDF (HMAC-based Key Derivation Function) with SHA-256. It involves setting key policies, importing a base key, setting up a generator, and importing the derived key into a new slot.
```C
psa_key_slot_t base_key = 1;
psa_key_slot_t derived_key = 2;
psa_key_policy_t policy = PSA_KEY_POLICY_INIT;
unsigned char key[] = {
0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b,
0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b,
0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b,
0x0b };
unsigned char salt[] = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06,
0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c };
unsigned char label[] = { 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6,
0xf7, 0xf8, 0xf9 };
psa_algorithm_t alg = PSA_ALG_HKDF(PSA_ALG_SHA_256);
psa_key_policy_t policy = PSA_KEY_POLICY_INIT;
psa_crypto_generator_t generator = PSA_CRYPTO_GENERATOR_INIT;
size_t derived_bits = 128;
size_t capacity = PSA_BITS_TO_BYTES(derived_bits);
status = psa_crypto_init();
/* Import a key for use in key derivation, if such a key has already been imported you can skip this part */
psa_key_policy_set_usage(&policy, PSA_KEY_USAGE_DERIVE, alg);
status = psa_set_key_policy(base_key, &policy);
status = psa_import_key(base_key, PSA_KEY_TYPE_DERIVE, key, sizeof(key));
/* Derive a key into a key slot*/
status = psa_key_derivation(&generator, base_key, alg, salt, sizeof(salt),
label, sizeof(label), capacity);
psa_key_policy_set_usage(&policy, PSA_KEY_USAGE_ENCRYPT, PSA_ALG_CTR);
psa_set_key_policy(derived_key, &policy);
psa_generator_import_key(derived_key, PSA_KEY_TYPE_AES, derived_bits, &generator);
/* Clean up generator and key */
psa_generator_abort(&generator);
/* as part of clean up you may want to clean up the keys used by calling:
* psa_destroy_key( base_key ); or psa_destroy_key( derived_key ); */
mbedtls_psa_crypto_free();
```
--------------------------------
### STM32CubeWL Sigfox Push Button Project File Overview
Source: https://github.com/stmicroelectronics/stm32cubewl/blob/main/Projects/NUCLEO-WL55JC1/Applications/Sigfox/Sigfox_PushButton/readme.txt
This section provides a high-level overview of the C source files within the STM32CubeWL Sigfox Push Button example project, detailing the purpose of each module and its role in the application.
```APIDOC
Project: /stmicroelectronics/stm32cubewl
Content:
- Sigfox_PushButton/Core/Src/sys_debug.c Configure probes pins RealTime debugging and JTAG/SerialWires for LowPower
- Sigfox_PushButton/Core/Src/sys_sensors.c Manages the sensors on the application
- Sigfox_PushButton/Core/Src/timer_if.c Configure RTC Alarm, Tick and Calendar manager
- Sigfox_PushButton/Core/Src/usart.c This file provides code for the configuration
of the USART instances.
- Sigfox_PushButton/Core/Src/usart_if.c Configuration of UART driver interface for hyperterminal communication
- Sigfox_PushButton/Sigfox/App/app_sigfox.c Application of the Sigfox Middleware
- Sigfox_PushButton/Sigfox/App/ee.c Implementation of the EEPROM emulator
- Sigfox_PushButton/Sigfox/App/sgfx_app.c provides code for the application of the sigfox Middleware
- Sigfox_PushButton/Sigfox/App/sgfx_cstimer.c manages carrier sense timer.
- Sigfox_PushButton/Sigfox/App/sgfx_eeprom_if.c eeprom interface to the sigfox component
- Sigfox_PushButton/Sigfox/Target/mcu_api.c mcu library interface
- Sigfox_PushButton/Sigfox/Target/mn_api.c monarch library interface implementation
- Sigfox_PushButton/Sigfox/Target/radio_board_if.c This file provides an interface layer between MW and Radio Board
- Sigfox_PushButton/Sigfox/Target/rf_api.c rf library interface
- Sigfox_PushButton/Sigfox/Target/se_nvm.c manages SE nvm data
- Sigfox_PushButton/Sigfox/Target/sgfx_credentials.c manages keys and encryption algorithm
- Sigfox_PushButton/STM32CubeIDE/Application/User/Core/syscalls.c STM32CubeIDE Minimal System calls file
- Sigfox_PushButton/STM32CubeIDE/Application/User/Core/sysmem.c STM32CubeIDE System Memory calls file
```
--------------------------------
### C: Example to Stop a CMSIS-RTOS Timer
Source: https://github.com/stmicroelectronics/stm32cubewl/blob/main/Drivers/CMSIS/docs/RTOS2/html/group__CMSIS__RTOS__TimerMgmt.html
This C code example demonstrates how to stop an already running timer using osTimerStop. It assumes a timer has been previously created and started.
```C
#include "cmsis_os2.h"
void Timer_Callback (void *arg); // prototype for timer callback function
uint32_t exec; // argument for the timer call back function
void TimerStop_example (void) {
osTimerId_t id; // timer id
osStatus_t status; // function return status
// Create periodic timer
exec = 1U;
id = osTimerNew(Timer_Callback, osTimerPeriodic, &exec, NULL);
osTimerStart(id, 1000U); // start timer
// ... some operations ...
status = osTimerStop(id); // stop timer
if (status != osOK) {
// Timer could not be stopped
}
}
```
--------------------------------
### Define Example Project in PDSC File
Source: https://github.com/stmicroelectronics/stm32cubewl/blob/main/Drivers/CMSIS/docs/Pack/html/cp_SWComponents.html
Shows how to define an example project within the PDSC file, including its name, documentation, folder, description, targeted board, and associated development tool projects. It also specifies related software components required by the example, helping users understand MCU or development board usage.
```XML
CMSIS-RTOS based example
```
--------------------------------
### Install Required Packages in Virtual Environment
Source: https://github.com/stmicroelectronics/stm32cubewl/blob/main/Drivers/CMSIS/DSP/PythonWrapper/README.md
Once the virtual environment is activated, install the necessary Python packages (numpy, scipy, matplotlib) to run the examples provided with the CMSIS-DSP wrapper.
```Shell
pip install numpy
pip install scipy
pip install matplotlib
```
--------------------------------
### JavaScript Page Initialization and Search Box Setup
Source: https://github.com/stmicroelectronics/stm32cubewl/blob/main/Drivers/CMSIS/docs/Pack/html/cp_ZIPTool.html
These JavaScript snippets handle the initial setup of the web page, including resizing elements, initializing a search box, and navigating the content tree. They ensure the page's interactive elements are ready upon document load.
```JavaScript
$(document).ready(initResizable); $(window).load(resizeHeight);
```
```JavaScript
$(document).ready(function() { searchBox.OnSelectItem(0); });
```
```JavaScript
var searchBox = new SearchBox("searchBox", "search",false,'Search');
```
```JavaScript
$(document).ready(function(){initNavTree('cp_ZIPTool.html','');});
```
--------------------------------
### Configure CMake Project for ARM Variance Example
Source: https://github.com/stmicroelectronics/stm32cubewl/blob/main/Drivers/CMSIS/DSP/Examples/ARM/arm_variance_example/CMakeLists.txt
This CMake configuration defines the build process for an ARM variance example application. It includes the CMSIS DSP library, specifies source files, links required libraries, and sets up the installation target for the compiled executable.
```CMake
cmake_minimum_required (VERSION 3.6)
project (arm_variance_example VERSION 0.1)
# Needed to include the configBoot module
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../..)
###################################
#
# LIBRARIES
#
###################################
###########
#
# CMSIS DSP
#
add_subdirectory(../../../Source bin_dsp)
###################################
#
# TEST APPLICATION
#
###################################
add_executable(arm_variance_example)
set(ROOT ${CMAKE_CURRENT_SOURCE_DIR}/../../../../..)
include(configBoot)
target_sources(arm_variance_example PRIVATE arm_variance_example_f32.c)
### Sources and libs
target_link_libraries(arm_variance_example PRIVATE CMSISDSP)
###################################
#
# INSTALLATION
#
###################################
install (TARGETS arm_variance_example DESTINATION "${PROJECT_SOURCE_DIR}/varianceExampleBuild.axf")
```
--------------------------------
### CMSIS-RTOS2 Application Main Function and Kernel Initialization
Source: https://github.com/stmicroelectronics/stm32cubewl/blob/main/Drivers/CMSIS/docs/RTOS2/html/genRTOS2IF.html
This C code example illustrates the fundamental structure of a CMSIS-RTOS2 application. It demonstrates how to include necessary headers, define an application main thread, initialize the RTOS kernel using 'osKernelInitialize()', create a new thread with 'osThreadNew()', and start the RTOS scheduler using 'osKernelStart()'. This setup is essential for any CMSIS-RTOS2 based embedded application.
```C
/*----------------------------------------------------------------------------
* CMSIS-RTOS 'main' function template
*---------------------------------------------------------------------------*/
#include "RTE_Components.h"
#include CMSIS_device_header
#include "cmsis_os2.h"
/*----------------------------------------------------------------------------
* Application main thread
*---------------------------------------------------------------------------*/
void app_main (void *argument) {
// ...
for (;;) {}
}
int main (void) {
// System Initialization
SystemCoreClockUpdate();
// ...
osKernelInitialize(); // Initialize CMSIS-RTOS
osThreadNew(app_main, NULL, NULL); // Create application main thread
osKernelStart(); // Start thread execution
for (;;) {}
}
```
--------------------------------
### Example System Description with DAP and Devices
Source: https://github.com/stmicroelectronics/stm32cubewl/blob/main/Drivers/CMSIS/docs/Pack/html/sdf_pg.html
Provides a comprehensive XML example of a `system_description` including a `dap` element (ARMCS-DP) and its nested `device` elements (AHB-AP, CPU, DWT, FPB), showcasing typical configurations and information items.
```XML
0x0BA01477
0
AHB-AP
0xE00FF000
0xE000E000
0
0xE0001000
0
0xE0002000
0
```
--------------------------------
### Page UI Initialization and Search Functionality
Source: https://github.com/stmicroelectronics/stm32cubewl/blob/main/Drivers/CMSIS/docs/Zone/html/fm_mpu_setup.html
These JavaScript snippets handle the initial setup of the page's user interface, including resizable elements, the search box, and navigation tree initialization. They are typically used for dynamic page rendering in a Doxygen-generated environment.
```JavaScript
$(document).ready(initResizable);
$(window).load(resizeHeight);
$(document).ready(function() { searchBox.OnSelectItem(0); });
var searchBox = new SearchBox("searchBox", "search",false,'Search');
$(document).ready(function(){initNavTree('fm_mpu_setup.html','');});
```
--------------------------------
### Get I2C Driver Capabilities Example in C
Source: https://github.com/stmicroelectronics/stm32cubewl/blob/main/Drivers/CMSIS/docs/Driver/html/group__i2c__interface__gr.html
This C code example illustrates how to retrieve the I2C driver's capabilities using the ARM_I2C_GetCapabilities function. The returned structure can then be interrogated to understand supported features.
```C
extern ARM_DRIVER_I2C Driver_I2C0;
ARM_DRIVER_I2C *drv_info;
void read_capabilities (void) {
ARM_I2C_CAPABILITIES drv_capabilities;
drv_info = &Driver_I2C0;
drv_capabilities = drv_info->GetCapabilities ();
// interrogate capabilities
}
```