stm32_patch_user_code
Insert or replace custom code within STM32CubeMX USER CODE BEGIN/END markers, leaving generated init functions untouched. Safely patch C/C++ sources in specified sections.
Instructions
Args: file, section (e.g. PD, 2, WHILE, 4), content, mode (replace/append). Writes only between /* USER CODE BEGIN x / and / USER CODE END x */. Must fail loudly if the markers are missing or unbalanced, and must never touch generated init functions.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| file | Yes | Relative or absolute path to C/C++ source file | |
| mode | No | Mode: replace or append | replace |
| content | Yes | Code content to insert between markers | |
| section | Yes | Section tag identifier (e.g. 0, 1, 2, WHILE, PV, PD, Includes) |