├── .gitignore ├── 01_base_project ├── .mxproject ├── Core │ ├── Inc │ │ ├── gpio.h │ │ ├── main.h │ │ ├── stm32f7xx_hal_conf.h │ │ └── stm32f7xx_it.h │ └── Src │ │ ├── gpio.c │ │ ├── main.c │ │ ├── stm32f7xx_hal_msp.c │ │ ├── stm32f7xx_it.c │ │ ├── syscalls.c │ │ ├── sysmem.c │ │ └── system_stm32f7xx.c ├── Drivers │ ├── CMSIS │ │ ├── Device │ │ │ └── ST │ │ │ │ └── STM32F7xx │ │ │ │ ├── Include │ │ │ │ ├── stm32f750xx.h │ │ │ │ ├── stm32f7xx.h │ │ │ │ └── system_stm32f7xx.h │ │ │ │ └── LICENSE.txt │ │ ├── Include │ │ │ ├── cmsis_armcc.h │ │ │ ├── cmsis_armclang.h │ │ │ ├── cmsis_compiler.h │ │ │ ├── cmsis_gcc.h │ │ │ ├── cmsis_iccarm.h │ │ │ ├── cmsis_version.h │ │ │ ├── core_armv8mbl.h │ │ │ ├── core_armv8mml.h │ │ │ ├── core_cm0.h │ │ │ ├── core_cm0plus.h │ │ │ ├── core_cm1.h │ │ │ ├── core_cm23.h │ │ │ ├── core_cm3.h │ │ │ ├── core_cm33.h │ │ │ ├── core_cm4.h │ │ │ ├── core_cm7.h │ │ │ ├── core_sc000.h │ │ │ ├── core_sc300.h │ │ │ ├── mpu_armv7.h │ │ │ ├── mpu_armv8.h │ │ │ └── tz_context.h │ │ └── LICENSE.txt │ └── STM32F7xx_HAL_Driver │ │ ├── Inc │ │ ├── Legacy │ │ │ └── stm32_hal_legacy.h │ │ ├── stm32f7xx_hal.h │ │ ├── stm32f7xx_hal_cortex.h │ │ ├── stm32f7xx_hal_def.h │ │ ├── stm32f7xx_hal_dma.h │ │ ├── stm32f7xx_hal_dma_ex.h │ │ ├── stm32f7xx_hal_exti.h │ │ ├── stm32f7xx_hal_flash.h │ │ ├── stm32f7xx_hal_flash_ex.h │ │ ├── stm32f7xx_hal_gpio.h │ │ ├── stm32f7xx_hal_gpio_ex.h │ │ ├── stm32f7xx_hal_i2c.h │ │ ├── stm32f7xx_hal_i2c_ex.h │ │ ├── stm32f7xx_hal_pwr.h │ │ ├── stm32f7xx_hal_pwr_ex.h │ │ ├── stm32f7xx_hal_rcc.h │ │ ├── stm32f7xx_hal_rcc_ex.h │ │ ├── stm32f7xx_hal_tim.h │ │ ├── stm32f7xx_hal_tim_ex.h │ │ ├── stm32f7xx_ll_bus.h │ │ ├── stm32f7xx_ll_cortex.h │ │ ├── stm32f7xx_ll_dma.h │ │ ├── stm32f7xx_ll_exti.h │ │ ├── stm32f7xx_ll_gpio.h │ │ ├── stm32f7xx_ll_pwr.h │ │ ├── stm32f7xx_ll_rcc.h │ │ ├── stm32f7xx_ll_system.h │ │ └── stm32f7xx_ll_utils.h │ │ ├── LICENSE.txt │ │ └── Src │ │ ├── stm32f7xx_hal.c │ │ ├── stm32f7xx_hal_cortex.c │ │ ├── stm32f7xx_hal_dma.c │ │ ├── stm32f7xx_hal_dma_ex.c │ │ ├── stm32f7xx_hal_exti.c │ │ ├── stm32f7xx_hal_flash.c │ │ ├── stm32f7xx_hal_flash_ex.c │ │ ├── stm32f7xx_hal_gpio.c │ │ ├── stm32f7xx_hal_i2c.c │ │ ├── stm32f7xx_hal_i2c_ex.c │ │ ├── stm32f7xx_hal_pwr.c │ │ ├── stm32f7xx_hal_pwr_ex.c │ │ ├── stm32f7xx_hal_rcc.c │ │ ├── stm32f7xx_hal_rcc_ex.c │ │ ├── stm32f7xx_hal_tim.c │ │ └── stm32f7xx_hal_tim_ex.c ├── Makefile ├── README.md ├── STM32F750N8Hx_FLASH.ld ├── blink_example.ioc └── startup_stm32f750xx.s ├── 02_drop_in_compiler ├── .mxproject ├── Core │ ├── Inc │ │ ├── gpio.h │ │ ├── main.h │ │ ├── stm32f7xx_hal_conf.h │ │ └── stm32f7xx_it.h │ └── Src │ │ ├── gpio.c │ │ ├── main.c │ │ ├── stm32f7xx_hal_msp.c │ │ ├── stm32f7xx_it.c │ │ ├── syscalls.c │ │ ├── sysmem.c │ │ └── system_stm32f7xx.c ├── Drivers │ ├── CMSIS │ │ ├── Device │ │ │ └── ST │ │ │ │ └── STM32F7xx │ │ │ │ ├── Include │ │ │ │ ├── stm32f750xx.h │ │ │ │ ├── stm32f7xx.h │ │ │ │ └── system_stm32f7xx.h │ │ │ │ └── LICENSE.txt │ │ ├── Include │ │ │ ├── cmsis_armcc.h │ │ │ ├── cmsis_armclang.h │ │ │ ├── cmsis_compiler.h │ │ │ ├── cmsis_gcc.h │ │ │ ├── cmsis_iccarm.h │ │ │ ├── cmsis_version.h │ │ │ ├── core_armv8mbl.h │ │ │ ├── core_armv8mml.h │ │ │ ├── core_cm0.h │ │ │ ├── core_cm0plus.h │ │ │ ├── core_cm1.h │ │ │ ├── core_cm23.h │ │ │ ├── core_cm3.h │ │ │ ├── core_cm33.h │ │ │ ├── core_cm4.h │ │ │ ├── core_cm7.h │ │ │ ├── core_sc000.h │ │ │ ├── core_sc300.h │ │ │ ├── mpu_armv7.h │ │ │ ├── mpu_armv8.h │ │ │ └── tz_context.h │ │ └── LICENSE.txt │ └── STM32F7xx_HAL_Driver │ │ ├── Inc │ │ ├── Legacy │ │ │ └── stm32_hal_legacy.h │ │ ├── stm32f7xx_hal.h │ │ ├── stm32f7xx_hal_cortex.h │ │ ├── stm32f7xx_hal_def.h │ │ ├── stm32f7xx_hal_dma.h │ │ ├── stm32f7xx_hal_dma_ex.h │ │ ├── stm32f7xx_hal_exti.h │ │ ├── stm32f7xx_hal_flash.h │ │ ├── stm32f7xx_hal_flash_ex.h │ │ ├── stm32f7xx_hal_gpio.h │ │ ├── stm32f7xx_hal_gpio_ex.h │ │ ├── stm32f7xx_hal_i2c.h │ │ ├── stm32f7xx_hal_i2c_ex.h │ │ ├── stm32f7xx_hal_pwr.h │ │ ├── stm32f7xx_hal_pwr_ex.h │ │ ├── stm32f7xx_hal_rcc.h │ │ ├── stm32f7xx_hal_rcc_ex.h │ │ ├── stm32f7xx_hal_tim.h │ │ ├── stm32f7xx_hal_tim_ex.h │ │ ├── stm32f7xx_ll_bus.h │ │ ├── stm32f7xx_ll_cortex.h │ │ ├── stm32f7xx_ll_dma.h │ │ ├── stm32f7xx_ll_exti.h │ │ ├── stm32f7xx_ll_gpio.h │ │ ├── stm32f7xx_ll_pwr.h │ │ ├── stm32f7xx_ll_rcc.h │ │ ├── stm32f7xx_ll_system.h │ │ └── stm32f7xx_ll_utils.h │ │ ├── LICENSE.txt │ │ └── Src │ │ ├── stm32f7xx_hal.c │ │ ├── stm32f7xx_hal_cortex.c │ │ ├── stm32f7xx_hal_dma.c │ │ ├── stm32f7xx_hal_dma_ex.c │ │ ├── stm32f7xx_hal_exti.c │ │ ├── stm32f7xx_hal_flash.c │ │ ├── stm32f7xx_hal_flash_ex.c │ │ ├── stm32f7xx_hal_gpio.c │ │ ├── stm32f7xx_hal_i2c.c │ │ ├── stm32f7xx_hal_i2c_ex.c │ │ ├── stm32f7xx_hal_pwr.c │ │ ├── stm32f7xx_hal_pwr_ex.c │ │ ├── stm32f7xx_hal_rcc.c │ │ ├── stm32f7xx_hal_rcc_ex.c │ │ ├── stm32f7xx_hal_tim.c │ │ └── stm32f7xx_hal_tim_ex.c ├── Makefile ├── README.md ├── STM32F750N8Hx_FLASH.ld ├── blink_example.ioc └── startup_stm32f750xx.s ├── 03_with_zig_build ├── .mxproject ├── Core │ ├── Inc │ │ ├── gpio.h │ │ ├── main.h │ │ ├── stm32f7xx_hal_conf.h │ │ └── stm32f7xx_it.h │ └── Src │ │ ├── gpio.c │ │ ├── main.c │ │ ├── stm32f7xx_hal_msp.c │ │ ├── stm32f7xx_it.c │ │ ├── syscalls.c │ │ ├── sysmem.c │ │ └── system_stm32f7xx.c ├── Drivers │ ├── CMSIS │ │ ├── Device │ │ │ └── ST │ │ │ │ └── STM32F7xx │ │ │ │ ├── Include │ │ │ │ ├── stm32f750xx.h │ │ │ │ ├── stm32f7xx.h │ │ │ │ └── system_stm32f7xx.h │ │ │ │ └── LICENSE.txt │ │ ├── Include │ │ │ ├── cmsis_armcc.h │ │ │ ├── cmsis_armclang.h │ │ │ ├── cmsis_compiler.h │ │ │ ├── cmsis_gcc.h │ │ │ ├── cmsis_iccarm.h │ │ │ ├── cmsis_version.h │ │ │ ├── core_armv8mbl.h │ │ │ ├── core_armv8mml.h │ │ │ ├── core_cm0.h │ │ │ ├── core_cm0plus.h │ │ │ ├── core_cm1.h │ │ │ ├── core_cm23.h │ │ │ ├── core_cm3.h │ │ │ ├── core_cm33.h │ │ │ ├── core_cm4.h │ │ │ ├── core_cm7.h │ │ │ ├── core_sc000.h │ │ │ ├── core_sc300.h │ │ │ ├── mpu_armv7.h │ │ │ ├── mpu_armv8.h │ │ │ └── tz_context.h │ │ └── LICENSE.txt │ └── STM32F7xx_HAL_Driver │ │ ├── Inc │ │ ├── Legacy │ │ │ └── stm32_hal_legacy.h │ │ ├── stm32f7xx_hal.h │ │ ├── stm32f7xx_hal_cortex.h │ │ ├── stm32f7xx_hal_def.h │ │ ├── stm32f7xx_hal_dma.h │ │ ├── stm32f7xx_hal_dma_ex.h │ │ ├── stm32f7xx_hal_exti.h │ │ ├── stm32f7xx_hal_flash.h │ │ ├── stm32f7xx_hal_flash_ex.h │ │ ├── stm32f7xx_hal_gpio.h │ │ ├── stm32f7xx_hal_gpio_ex.h │ │ ├── stm32f7xx_hal_i2c.h │ │ ├── stm32f7xx_hal_i2c_ex.h │ │ ├── stm32f7xx_hal_pwr.h │ │ ├── stm32f7xx_hal_pwr_ex.h │ │ ├── stm32f7xx_hal_rcc.h │ │ ├── stm32f7xx_hal_rcc_ex.h │ │ ├── stm32f7xx_hal_tim.h │ │ ├── stm32f7xx_hal_tim_ex.h │ │ ├── stm32f7xx_ll_bus.h │ │ ├── stm32f7xx_ll_cortex.h │ │ ├── stm32f7xx_ll_dma.h │ │ ├── stm32f7xx_ll_exti.h │ │ ├── stm32f7xx_ll_gpio.h │ │ ├── stm32f7xx_ll_pwr.h │ │ ├── stm32f7xx_ll_rcc.h │ │ ├── stm32f7xx_ll_system.h │ │ └── stm32f7xx_ll_utils.h │ │ ├── LICENSE.txt │ │ └── Src │ │ ├── stm32f7xx_hal.c │ │ ├── stm32f7xx_hal_cortex.c │ │ ├── stm32f7xx_hal_dma.c │ │ ├── stm32f7xx_hal_dma_ex.c │ │ ├── stm32f7xx_hal_exti.c │ │ ├── stm32f7xx_hal_flash.c │ │ ├── stm32f7xx_hal_flash_ex.c │ │ ├── stm32f7xx_hal_gpio.c │ │ ├── stm32f7xx_hal_i2c.c │ │ ├── stm32f7xx_hal_i2c_ex.c │ │ ├── stm32f7xx_hal_pwr.c │ │ ├── stm32f7xx_hal_pwr_ex.c │ │ ├── stm32f7xx_hal_rcc.c │ │ ├── stm32f7xx_hal_rcc_ex.c │ │ ├── stm32f7xx_hal_tim.c │ │ └── stm32f7xx_hal_tim_ex.c ├── README.md ├── STM32F750N8Hx_FLASH.ld ├── blink_example.ioc ├── build.zig └── startup_stm32f750xx.s ├── 04_advanced_zig_project ├── README.md ├── build.zig ├── build.zig.zon ├── src │ └── main.zig └── stm32_hal │ ├── .mxproject │ ├── Core │ ├── Inc │ │ ├── gpio.h │ │ ├── main.h │ │ ├── stm32f7xx_hal_conf.h │ │ └── stm32f7xx_it.h │ └── Src │ │ ├── gpio.c │ │ ├── main.c │ │ ├── stm32f7xx_hal_msp.c │ │ ├── stm32f7xx_it.c │ │ ├── syscalls.c │ │ ├── sysmem.c │ │ └── system_stm32f7xx.c │ ├── Drivers │ ├── CMSIS │ │ ├── Device │ │ │ └── ST │ │ │ │ └── STM32F7xx │ │ │ │ ├── Include │ │ │ │ ├── stm32f750xx.h │ │ │ │ ├── stm32f7xx.h │ │ │ │ └── system_stm32f7xx.h │ │ │ │ └── LICENSE.txt │ │ ├── Include │ │ │ ├── cmsis_armcc.h │ │ │ ├── cmsis_armclang.h │ │ │ ├── cmsis_compiler.h │ │ │ ├── cmsis_gcc.h │ │ │ ├── cmsis_iccarm.h │ │ │ ├── cmsis_version.h │ │ │ ├── core_armv8mbl.h │ │ │ ├── core_armv8mml.h │ │ │ ├── core_cm0.h │ │ │ ├── core_cm0plus.h │ │ │ ├── core_cm1.h │ │ │ ├── core_cm23.h │ │ │ ├── core_cm3.h │ │ │ ├── core_cm33.h │ │ │ ├── core_cm4.h │ │ │ ├── core_cm7.h │ │ │ ├── core_sc000.h │ │ │ ├── core_sc300.h │ │ │ ├── mpu_armv7.h │ │ │ ├── mpu_armv8.h │ │ │ └── tz_context.h │ │ └── LICENSE.txt │ └── STM32F7xx_HAL_Driver │ │ ├── Inc │ │ ├── Legacy │ │ │ └── stm32_hal_legacy.h │ │ ├── stm32f7xx_hal.h │ │ ├── stm32f7xx_hal_cortex.h │ │ ├── stm32f7xx_hal_def.h │ │ ├── stm32f7xx_hal_dma.h │ │ ├── stm32f7xx_hal_dma_ex.h │ │ ├── stm32f7xx_hal_exti.h │ │ ├── stm32f7xx_hal_flash.h │ │ ├── stm32f7xx_hal_flash_ex.h │ │ ├── stm32f7xx_hal_gpio.h │ │ ├── stm32f7xx_hal_gpio_ex.h │ │ ├── stm32f7xx_hal_i2c.h │ │ ├── stm32f7xx_hal_i2c_ex.h │ │ ├── stm32f7xx_hal_pwr.h │ │ ├── stm32f7xx_hal_pwr_ex.h │ │ ├── stm32f7xx_hal_rcc.h │ │ ├── stm32f7xx_hal_rcc_ex.h │ │ ├── stm32f7xx_hal_tim.h │ │ ├── stm32f7xx_hal_tim_ex.h │ │ ├── stm32f7xx_ll_bus.h │ │ ├── stm32f7xx_ll_cortex.h │ │ ├── stm32f7xx_ll_dma.h │ │ ├── stm32f7xx_ll_exti.h │ │ ├── stm32f7xx_ll_gpio.h │ │ ├── stm32f7xx_ll_pwr.h │ │ ├── stm32f7xx_ll_rcc.h │ │ ├── stm32f7xx_ll_system.h │ │ └── stm32f7xx_ll_utils.h │ │ ├── LICENSE.txt │ │ └── Src │ │ ├── stm32f7xx_hal.c │ │ ├── stm32f7xx_hal_cortex.c │ │ ├── stm32f7xx_hal_dma.c │ │ ├── stm32f7xx_hal_dma_ex.c │ │ ├── stm32f7xx_hal_exti.c │ │ ├── stm32f7xx_hal_flash.c │ │ ├── stm32f7xx_hal_flash_ex.c │ │ ├── stm32f7xx_hal_gpio.c │ │ ├── stm32f7xx_hal_i2c.c │ │ ├── stm32f7xx_hal_i2c_ex.c │ │ ├── stm32f7xx_hal_pwr.c │ │ ├── stm32f7xx_hal_pwr_ex.c │ │ ├── stm32f7xx_hal_rcc.c │ │ ├── stm32f7xx_hal_rcc_ex.c │ │ ├── stm32f7xx_hal_tim.c │ │ └── stm32f7xx_hal_tim_ex.c │ ├── STM32F750N8Hx_FLASH.ld │ ├── blink_example.ioc │ ├── build.zig │ ├── build.zig.zon │ └── startup_stm32f750xx.s └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | .zig-cache 2 | zig-out 3 | build 4 | build_dropinzigcc -------------------------------------------------------------------------------- /01_base_project/Core/Inc/gpio.h: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file gpio.h 5 | * @brief This file contains all the function prototypes for 6 | * the gpio.c file 7 | ****************************************************************************** 8 | * @attention 9 | * 10 | * Copyright (c) 2024 STMicroelectronics. 11 | * All rights reserved. 12 | * 13 | * This software is licensed under terms that can be found in the LICENSE file 14 | * in the root directory of this software component. 15 | * If no LICENSE file comes with this software, it is provided AS-IS. 16 | * 17 | ****************************************************************************** 18 | */ 19 | /* USER CODE END Header */ 20 | /* Define to prevent recursive inclusion -------------------------------------*/ 21 | #ifndef __GPIO_H__ 22 | #define __GPIO_H__ 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | /* Includes ------------------------------------------------------------------*/ 29 | #include "main.h" 30 | 31 | /* USER CODE BEGIN Includes */ 32 | 33 | /* USER CODE END Includes */ 34 | 35 | /* USER CODE BEGIN Private defines */ 36 | 37 | /* USER CODE END Private defines */ 38 | 39 | void MX_GPIO_Init(void); 40 | 41 | /* USER CODE BEGIN Prototypes */ 42 | 43 | /* USER CODE END Prototypes */ 44 | 45 | #ifdef __cplusplus 46 | } 47 | #endif 48 | #endif /*__ GPIO_H__ */ 49 | 50 | -------------------------------------------------------------------------------- /01_base_project/Core/Inc/main.h: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file : main.h 5 | * @brief : Header for main.c file. 6 | * This file contains the common defines of the application. 7 | ****************************************************************************** 8 | * @attention 9 | * 10 | * Copyright (c) 2024 STMicroelectronics. 11 | * All rights reserved. 12 | * 13 | * This software is licensed under terms that can be found in the LICENSE file 14 | * in the root directory of this software component. 15 | * If no LICENSE file comes with this software, it is provided AS-IS. 16 | * 17 | ****************************************************************************** 18 | */ 19 | /* USER CODE END Header */ 20 | 21 | /* Define to prevent recursive inclusion -------------------------------------*/ 22 | #ifndef __MAIN_H 23 | #define __MAIN_H 24 | 25 | #ifdef __cplusplus 26 | extern "C" { 27 | #endif 28 | 29 | /* Includes ------------------------------------------------------------------*/ 30 | #include "stm32f7xx_hal.h" 31 | 32 | /* Private includes ----------------------------------------------------------*/ 33 | /* USER CODE BEGIN Includes */ 34 | 35 | /* USER CODE END Includes */ 36 | 37 | /* Exported types ------------------------------------------------------------*/ 38 | /* USER CODE BEGIN ET */ 39 | 40 | /* USER CODE END ET */ 41 | 42 | /* Exported constants --------------------------------------------------------*/ 43 | /* USER CODE BEGIN EC */ 44 | 45 | /* USER CODE END EC */ 46 | 47 | /* Exported macro ------------------------------------------------------------*/ 48 | /* USER CODE BEGIN EM */ 49 | 50 | /* USER CODE END EM */ 51 | 52 | /* Exported functions prototypes ---------------------------------------------*/ 53 | void Error_Handler(void); 54 | 55 | /* USER CODE BEGIN EFP */ 56 | void hal_initialization_code(void); 57 | 58 | /* USER CODE END EFP */ 59 | 60 | /* Private defines -----------------------------------------------------------*/ 61 | #define LED_BLINK_Pin GPIO_PIN_15 62 | #define LED_BLINK_GPIO_Port GPIOA 63 | 64 | /* USER CODE BEGIN Private defines */ 65 | 66 | /* USER CODE END Private defines */ 67 | 68 | #ifdef __cplusplus 69 | } 70 | #endif 71 | 72 | #endif /* __MAIN_H */ 73 | -------------------------------------------------------------------------------- /01_base_project/Core/Inc/stm32f7xx_it.h: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file stm32f7xx_it.h 5 | * @brief This file contains the headers of the interrupt handlers. 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | * Copyright (c) 2024 STMicroelectronics. 10 | * All rights reserved. 11 | * 12 | * This software is licensed under terms that can be found in the LICENSE file 13 | * in the root directory of this software component. 14 | * If no LICENSE file comes with this software, it is provided AS-IS. 15 | * 16 | ****************************************************************************** 17 | */ 18 | /* USER CODE END Header */ 19 | 20 | /* Define to prevent recursive inclusion -------------------------------------*/ 21 | #ifndef __STM32F7xx_IT_H 22 | #define __STM32F7xx_IT_H 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | /* Private includes ----------------------------------------------------------*/ 29 | /* USER CODE BEGIN Includes */ 30 | 31 | /* USER CODE END Includes */ 32 | 33 | /* Exported types ------------------------------------------------------------*/ 34 | /* USER CODE BEGIN ET */ 35 | 36 | /* USER CODE END ET */ 37 | 38 | /* Exported constants --------------------------------------------------------*/ 39 | /* USER CODE BEGIN EC */ 40 | 41 | /* USER CODE END EC */ 42 | 43 | /* Exported macro ------------------------------------------------------------*/ 44 | /* USER CODE BEGIN EM */ 45 | 46 | /* USER CODE END EM */ 47 | 48 | /* Exported functions prototypes ---------------------------------------------*/ 49 | void SysTick_Handler(void); 50 | /* USER CODE BEGIN EFP */ 51 | 52 | /* USER CODE END EFP */ 53 | 54 | #ifdef __cplusplus 55 | } 56 | #endif 57 | 58 | #endif /* __STM32F7xx_IT_H */ 59 | -------------------------------------------------------------------------------- /01_base_project/Core/Src/gpio.c: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file gpio.c 5 | * @brief This file provides code for the configuration 6 | * of all used GPIO pins. 7 | ****************************************************************************** 8 | * @attention 9 | * 10 | * Copyright (c) 2024 STMicroelectronics. 11 | * All rights reserved. 12 | * 13 | * This software is licensed under terms that can be found in the LICENSE file 14 | * in the root directory of this software component. 15 | * If no LICENSE file comes with this software, it is provided AS-IS. 16 | * 17 | ****************************************************************************** 18 | */ 19 | /* USER CODE END Header */ 20 | 21 | /* Includes ------------------------------------------------------------------*/ 22 | #include "gpio.h" 23 | 24 | /* USER CODE BEGIN 0 */ 25 | 26 | /* USER CODE END 0 */ 27 | 28 | /*----------------------------------------------------------------------------*/ 29 | /* Configure GPIO */ 30 | /*----------------------------------------------------------------------------*/ 31 | /* USER CODE BEGIN 1 */ 32 | 33 | /* USER CODE END 1 */ 34 | 35 | /** Configure pins 36 | PE2 ------> QUADSPI_BK1_IO2 37 | PB6 ------> QUADSPI_BK1_NCS 38 | PB2 ------> QUADSPI_CLK 39 | PD12 ------> QUADSPI_BK1_IO1 40 | PD13 ------> QUADSPI_BK1_IO3 41 | PD11 ------> QUADSPI_BK1_IO0 42 | */ 43 | void MX_GPIO_Init(void) 44 | { 45 | 46 | GPIO_InitTypeDef GPIO_InitStruct = {0}; 47 | 48 | /* GPIO Ports Clock Enable */ 49 | __HAL_RCC_GPIOE_CLK_ENABLE(); 50 | __HAL_RCC_GPIOA_CLK_ENABLE(); 51 | __HAL_RCC_GPIOB_CLK_ENABLE(); 52 | __HAL_RCC_GPIOH_CLK_ENABLE(); 53 | __HAL_RCC_GPIOD_CLK_ENABLE(); 54 | 55 | /*Configure GPIO pin Output Level */ 56 | HAL_GPIO_WritePin(LED_BLINK_GPIO_Port, LED_BLINK_Pin, GPIO_PIN_RESET); 57 | 58 | /*Configure GPIO pin : PE2 */ 59 | GPIO_InitStruct.Pin = GPIO_PIN_2; 60 | GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; 61 | GPIO_InitStruct.Pull = GPIO_NOPULL; 62 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; 63 | GPIO_InitStruct.Alternate = GPIO_AF9_QUADSPI; 64 | HAL_GPIO_Init(GPIOE, &GPIO_InitStruct); 65 | 66 | /*Configure GPIO pin : PtPin */ 67 | GPIO_InitStruct.Pin = LED_BLINK_Pin; 68 | GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; 69 | GPIO_InitStruct.Pull = GPIO_NOPULL; 70 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; 71 | HAL_GPIO_Init(LED_BLINK_GPIO_Port, &GPIO_InitStruct); 72 | 73 | /*Configure GPIO pin : PB6 */ 74 | GPIO_InitStruct.Pin = GPIO_PIN_6; 75 | GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; 76 | GPIO_InitStruct.Pull = GPIO_NOPULL; 77 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; 78 | GPIO_InitStruct.Alternate = GPIO_AF10_QUADSPI; 79 | HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); 80 | 81 | /*Configure GPIO pin : PB2 */ 82 | GPIO_InitStruct.Pin = GPIO_PIN_2; 83 | GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; 84 | GPIO_InitStruct.Pull = GPIO_NOPULL; 85 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; 86 | GPIO_InitStruct.Alternate = GPIO_AF9_QUADSPI; 87 | HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); 88 | 89 | /*Configure GPIO pins : PD12 PD13 PD11 */ 90 | GPIO_InitStruct.Pin = GPIO_PIN_12|GPIO_PIN_13|GPIO_PIN_11; 91 | GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; 92 | GPIO_InitStruct.Pull = GPIO_NOPULL; 93 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; 94 | GPIO_InitStruct.Alternate = GPIO_AF9_QUADSPI; 95 | HAL_GPIO_Init(GPIOD, &GPIO_InitStruct); 96 | 97 | } 98 | 99 | /* USER CODE BEGIN 2 */ 100 | 101 | /* USER CODE END 2 */ 102 | -------------------------------------------------------------------------------- /01_base_project/Core/Src/stm32f7xx_hal_msp.c: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file stm32f7xx_hal_msp.c 5 | * @brief This file provides code for the MSP Initialization 6 | * and de-Initialization codes. 7 | ****************************************************************************** 8 | * @attention 9 | * 10 | * Copyright (c) 2024 STMicroelectronics. 11 | * All rights reserved. 12 | * 13 | * This software is licensed under terms that can be found in the LICENSE file 14 | * in the root directory of this software component. 15 | * If no LICENSE file comes with this software, it is provided AS-IS. 16 | * 17 | ****************************************************************************** 18 | */ 19 | /* USER CODE END Header */ 20 | 21 | /* Includes ------------------------------------------------------------------*/ 22 | #include "main.h" 23 | /* USER CODE BEGIN Includes */ 24 | 25 | /* USER CODE END Includes */ 26 | 27 | /* Private typedef -----------------------------------------------------------*/ 28 | /* USER CODE BEGIN TD */ 29 | 30 | /* USER CODE END TD */ 31 | 32 | /* Private define ------------------------------------------------------------*/ 33 | /* USER CODE BEGIN Define */ 34 | 35 | /* USER CODE END Define */ 36 | 37 | /* Private macro -------------------------------------------------------------*/ 38 | /* USER CODE BEGIN Macro */ 39 | 40 | /* USER CODE END Macro */ 41 | 42 | /* Private variables ---------------------------------------------------------*/ 43 | /* USER CODE BEGIN PV */ 44 | 45 | /* USER CODE END PV */ 46 | 47 | /* Private function prototypes -----------------------------------------------*/ 48 | /* USER CODE BEGIN PFP */ 49 | 50 | /* USER CODE END PFP */ 51 | 52 | /* External functions --------------------------------------------------------*/ 53 | /* USER CODE BEGIN ExternalFunctions */ 54 | 55 | /* USER CODE END ExternalFunctions */ 56 | 57 | /* USER CODE BEGIN 0 */ 58 | 59 | /* USER CODE END 0 */ 60 | /** 61 | * Initializes the Global MSP. 62 | */ 63 | void HAL_MspInit(void) 64 | { 65 | 66 | /* USER CODE BEGIN MspInit 0 */ 67 | 68 | /* USER CODE END MspInit 0 */ 69 | 70 | __HAL_RCC_PWR_CLK_ENABLE(); 71 | __HAL_RCC_SYSCFG_CLK_ENABLE(); 72 | 73 | /* System interrupt init*/ 74 | 75 | /* USER CODE BEGIN MspInit 1 */ 76 | 77 | /* USER CODE END MspInit 1 */ 78 | } 79 | 80 | /* USER CODE BEGIN 1 */ 81 | 82 | /* USER CODE END 1 */ 83 | -------------------------------------------------------------------------------- /01_base_project/Core/Src/stm32f7xx_it.c: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file stm32f7xx_it.c 5 | * @brief Interrupt Service Routines. 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | * Copyright (c) 2024 STMicroelectronics. 10 | * All rights reserved. 11 | * 12 | * This software is licensed under terms that can be found in the LICENSE file 13 | * in the root directory of this software component. 14 | * If no LICENSE file comes with this software, it is provided AS-IS. 15 | * 16 | ****************************************************************************** 17 | */ 18 | /* USER CODE END Header */ 19 | 20 | /* Includes ------------------------------------------------------------------*/ 21 | #include "main.h" 22 | #include "stm32f7xx_it.h" 23 | /* Private includes ----------------------------------------------------------*/ 24 | /* USER CODE BEGIN Includes */ 25 | /* USER CODE END Includes */ 26 | 27 | /* Private typedef -----------------------------------------------------------*/ 28 | /* USER CODE BEGIN TD */ 29 | 30 | /* USER CODE END TD */ 31 | 32 | /* Private define ------------------------------------------------------------*/ 33 | /* USER CODE BEGIN PD */ 34 | 35 | /* USER CODE END PD */ 36 | 37 | /* Private macro -------------------------------------------------------------*/ 38 | /* USER CODE BEGIN PM */ 39 | 40 | /* USER CODE END PM */ 41 | 42 | /* Private variables ---------------------------------------------------------*/ 43 | /* USER CODE BEGIN PV */ 44 | 45 | /* USER CODE END PV */ 46 | 47 | /* Private function prototypes -----------------------------------------------*/ 48 | /* USER CODE BEGIN PFP */ 49 | 50 | /* USER CODE END PFP */ 51 | 52 | /* Private user code ---------------------------------------------------------*/ 53 | /* USER CODE BEGIN 0 */ 54 | 55 | /* USER CODE END 0 */ 56 | 57 | /* External variables --------------------------------------------------------*/ 58 | 59 | /* USER CODE BEGIN EV */ 60 | 61 | /* USER CODE END EV */ 62 | 63 | /******************************************************************************/ 64 | /* Cortex-M7 Processor Interruption and Exception Handlers */ 65 | /******************************************************************************/ 66 | /** 67 | * @brief This function handles System tick timer. 68 | */ 69 | void SysTick_Handler(void) 70 | { 71 | /* USER CODE BEGIN SysTick_IRQn 0 */ 72 | 73 | /* USER CODE END SysTick_IRQn 0 */ 74 | HAL_IncTick(); 75 | /* USER CODE BEGIN SysTick_IRQn 1 */ 76 | 77 | /* USER CODE END SysTick_IRQn 1 */ 78 | } 79 | 80 | /******************************************************************************/ 81 | /* STM32F7xx Peripheral Interrupt Handlers */ 82 | /* Add here the Interrupt Handlers for the used peripherals. */ 83 | /* For the available peripheral interrupt handler names, */ 84 | /* please refer to the startup file (startup_stm32f7xx.s). */ 85 | /******************************************************************************/ 86 | 87 | /* USER CODE BEGIN 1 */ 88 | 89 | /* USER CODE END 1 */ 90 | -------------------------------------------------------------------------------- /01_base_project/Core/Src/syscalls.c: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file syscalls.c 4 | * @author Auto-generated by STM32CubeMX 5 | * @brief Minimal System calls file 6 | * 7 | * For more information about which c-functions 8 | * need which of these lowlevel functions 9 | * please consult the Newlib libc-manual 10 | ****************************************************************************** 11 | * @attention 12 | * 13 | * Copyright (c) 2020-2024 STMicroelectronics. 14 | * All rights reserved. 15 | * 16 | * This software is licensed under terms that can be found in the LICENSE file 17 | * in the root directory of this software component. 18 | * If no LICENSE file comes with this software, it is provided AS-IS. 19 | * 20 | ****************************************************************************** 21 | */ 22 | 23 | /* Includes */ 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | 33 | /* Variables */ 34 | extern int __io_putchar(int ch) __attribute__((weak)); 35 | extern int __io_getchar(void) __attribute__((weak)); 36 | 37 | char *__env[1] = {0}; 38 | char **environ = __env; 39 | 40 | /* Functions */ 41 | void initialise_monitor_handles() 42 | { 43 | } 44 | 45 | int _getpid(void) 46 | { 47 | return 1; 48 | } 49 | 50 | int _kill(int pid, int sig) 51 | { 52 | (void)pid; 53 | (void)sig; 54 | errno = EINVAL; 55 | return -1; 56 | } 57 | 58 | void _exit(int status) 59 | { 60 | _kill(status, -1); 61 | while (1) 62 | { 63 | } /* Make sure we hang here */ 64 | } 65 | 66 | __attribute__((weak)) int _read(int file, char *ptr, int len) 67 | { 68 | (void)file; 69 | int DataIdx; 70 | 71 | for (DataIdx = 0; DataIdx < len; DataIdx++) 72 | { 73 | *ptr++ = __io_getchar(); 74 | } 75 | 76 | return len; 77 | } 78 | 79 | __attribute__((weak)) int _write(int file, char *ptr, int len) 80 | { 81 | (void)file; 82 | int DataIdx; 83 | 84 | for (DataIdx = 0; DataIdx < len; DataIdx++) 85 | { 86 | __io_putchar(*ptr++); 87 | } 88 | return len; 89 | } 90 | 91 | int _close(int file) 92 | { 93 | (void)file; 94 | return -1; 95 | } 96 | 97 | int _fstat(int file, struct stat *st) 98 | { 99 | (void)file; 100 | st->st_mode = S_IFCHR; 101 | return 0; 102 | } 103 | 104 | int _isatty(int file) 105 | { 106 | (void)file; 107 | return 1; 108 | } 109 | 110 | int _lseek(int file, int ptr, int dir) 111 | { 112 | (void)file; 113 | (void)ptr; 114 | (void)dir; 115 | return 0; 116 | } 117 | 118 | int _open(char *path, int flags, ...) 119 | { 120 | (void)path; 121 | (void)flags; 122 | /* Pretend like we always fail */ 123 | return -1; 124 | } 125 | 126 | int _wait(int *status) 127 | { 128 | (void)status; 129 | errno = ECHILD; 130 | return -1; 131 | } 132 | 133 | int _unlink(char *name) 134 | { 135 | (void)name; 136 | errno = ENOENT; 137 | return -1; 138 | } 139 | 140 | int _times(struct tms *buf) 141 | { 142 | (void)buf; 143 | return -1; 144 | } 145 | 146 | int _stat(char *file, struct stat *st) 147 | { 148 | (void)file; 149 | st->st_mode = S_IFCHR; 150 | return 0; 151 | } 152 | 153 | int _link(char *old, char *new) 154 | { 155 | (void)old; 156 | (void)new; 157 | errno = EMLINK; 158 | return -1; 159 | } 160 | 161 | int _fork(void) 162 | { 163 | errno = EAGAIN; 164 | return -1; 165 | } 166 | 167 | int _execve(char *name, char **argv, char **env) 168 | { 169 | (void)name; 170 | (void)argv; 171 | (void)env; 172 | errno = ENOMEM; 173 | return -1; 174 | } 175 | -------------------------------------------------------------------------------- /01_base_project/Core/Src/sysmem.c: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file sysmem.c 4 | * @author Generated by STM32CubeMX 5 | * @brief System Memory calls file 6 | * 7 | * For more information about which C functions 8 | * need which of these lowlevel functions 9 | * please consult the newlib libc manual 10 | ****************************************************************************** 11 | * @attention 12 | * 13 | * Copyright (c) 2024 STMicroelectronics. 14 | * All rights reserved. 15 | * 16 | * This software is licensed under terms that can be found in the LICENSE file 17 | * in the root directory of this software component. 18 | * If no LICENSE file comes with this software, it is provided AS-IS. 19 | * 20 | ****************************************************************************** 21 | */ 22 | 23 | /* Includes */ 24 | #include 25 | #include 26 | 27 | /** 28 | * Pointer to the current high watermark of the heap usage 29 | */ 30 | static uint8_t *__sbrk_heap_end = NULL; 31 | 32 | /** 33 | * @brief _sbrk() allocates memory to the newlib heap and is used by malloc 34 | * and others from the C library 35 | * 36 | * @verbatim 37 | * ############################################################################ 38 | * # .data # .bss # newlib heap # MSP stack # 39 | * # # # # Reserved by _Min_Stack_Size # 40 | * ############################################################################ 41 | * ^-- RAM start ^-- _end _estack, RAM end --^ 42 | * @endverbatim 43 | * 44 | * This implementation starts allocating at the '_end' linker symbol 45 | * The '_Min_Stack_Size' linker symbol reserves a memory for the MSP stack 46 | * The implementation considers '_estack' linker symbol to be RAM end 47 | * NOTE: If the MSP stack, at any point during execution, grows larger than the 48 | * reserved size, please increase the '_Min_Stack_Size'. 49 | * 50 | * @param incr Memory size 51 | * @return Pointer to allocated memory 52 | */ 53 | void *_sbrk(ptrdiff_t incr) 54 | { 55 | extern uint8_t _end; /* Symbol defined in the linker script */ 56 | extern uint8_t _estack; /* Symbol defined in the linker script */ 57 | extern uint32_t _Min_Stack_Size; /* Symbol defined in the linker script */ 58 | const uint32_t stack_limit = (uint32_t)&_estack - (uint32_t)&_Min_Stack_Size; 59 | const uint8_t *max_heap = (uint8_t *)stack_limit; 60 | uint8_t *prev_heap_end; 61 | 62 | /* Initialize heap end at first call */ 63 | if (NULL == __sbrk_heap_end) 64 | { 65 | __sbrk_heap_end = &_end; 66 | } 67 | 68 | /* Protect heap from growing into the reserved MSP stack */ 69 | if (__sbrk_heap_end + incr > max_heap) 70 | { 71 | errno = ENOMEM; 72 | return (void *)-1; 73 | } 74 | 75 | prev_heap_end = __sbrk_heap_end; 76 | __sbrk_heap_end += incr; 77 | 78 | return (void *)prev_heap_end; 79 | } 80 | -------------------------------------------------------------------------------- /01_base_project/Drivers/CMSIS/Device/ST/STM32F7xx/Include/system_stm32f7xx.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file system_stm32f7xx.h 4 | * @author MCD Application Team 5 | * @brief CMSIS Cortex-M7 Device System Source File for STM32F7xx devices. 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | * Copyright (c) 2016 STMicroelectronics. 10 | * All rights reserved. 11 | * 12 | * This software is licensed under terms that can be found in the LICENSE file 13 | * in the root directory of this software component. 14 | * If no LICENSE file comes with this software, it is provided AS-IS. 15 | * 16 | ****************************************************************************** 17 | */ 18 | 19 | /** @addtogroup CMSIS 20 | * @{ 21 | */ 22 | 23 | /** @addtogroup stm32f7xx_system 24 | * @{ 25 | */ 26 | 27 | /** 28 | * @brief Define to prevent recursive inclusion 29 | */ 30 | #ifndef __SYSTEM_STM32F7XX_H 31 | #define __SYSTEM_STM32F7XX_H 32 | 33 | #ifdef __cplusplus 34 | extern "C" { 35 | #endif 36 | 37 | /** @addtogroup STM32F7xx_System_Includes 38 | * @{ 39 | */ 40 | 41 | /** 42 | * @} 43 | */ 44 | 45 | 46 | /** @addtogroup STM32F7xx_System_Exported_Variables 47 | * @{ 48 | */ 49 | /* The SystemCoreClock variable is updated in three ways: 50 | 1) by calling CMSIS function SystemCoreClockUpdate() 51 | 2) by calling HAL API function HAL_RCC_GetSysClockFreq() 52 | 3) each time HAL_RCC_ClockConfig() is called to configure the system clock frequency 53 | Note: If you use this function to configure the system clock; then there 54 | is no need to call the 2 first functions listed above, since SystemCoreClock 55 | variable is updated automatically. 56 | */ 57 | extern uint32_t SystemCoreClock; /*!< System Clock Frequency (Core Clock) */ 58 | 59 | extern const uint8_t AHBPrescTable[16]; /*!< AHB prescalers table values */ 60 | extern const uint8_t APBPrescTable[8]; /*!< APB prescalers table values */ 61 | 62 | 63 | /** 64 | * @} 65 | */ 66 | 67 | /** @addtogroup STM32F7xx_System_Exported_Constants 68 | * @{ 69 | */ 70 | 71 | /** 72 | * @} 73 | */ 74 | 75 | /** @addtogroup STM32F7xx_System_Exported_Macros 76 | * @{ 77 | */ 78 | 79 | /** 80 | * @} 81 | */ 82 | 83 | /** @addtogroup STM32F7xx_System_Exported_Functions 84 | * @{ 85 | */ 86 | 87 | extern void SystemInit(void); 88 | extern void SystemCoreClockUpdate(void); 89 | /** 90 | * @} 91 | */ 92 | 93 | #ifdef __cplusplus 94 | } 95 | #endif 96 | 97 | #endif /*__SYSTEM_STM32F7XX_H */ 98 | 99 | /** 100 | * @} 101 | */ 102 | 103 | /** 104 | * @} 105 | */ 106 | -------------------------------------------------------------------------------- /01_base_project/Drivers/CMSIS/Device/ST/STM32F7xx/LICENSE.txt: -------------------------------------------------------------------------------- 1 | This software component is provided to you as part of a software package and 2 | applicable license terms are in the Package_license file. If you received this 3 | software component outside of a package or without applicable license terms, 4 | the terms of the Apache-2.0 license shall apply. 5 | You may obtain a copy of the Apache-2.0 at: 6 | https://opensource.org/licenses/Apache-2.0 7 | -------------------------------------------------------------------------------- /01_base_project/Drivers/CMSIS/Include/cmsis_version.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************//** 2 | * @file cmsis_version.h 3 | * @brief CMSIS Core(M) Version definitions 4 | * @version V5.0.2 5 | * @date 19. April 2017 6 | ******************************************************************************/ 7 | /* 8 | * Copyright (c) 2009-2017 ARM Limited. All rights reserved. 9 | * 10 | * SPDX-License-Identifier: Apache-2.0 11 | * 12 | * Licensed under the Apache License, Version 2.0 (the License); you may 13 | * not use this file except in compliance with the License. 14 | * You may obtain a copy of the License at 15 | * 16 | * www.apache.org/licenses/LICENSE-2.0 17 | * 18 | * Unless required by applicable law or agreed to in writing, software 19 | * distributed under the License is distributed on an AS IS BASIS, WITHOUT 20 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 21 | * See the License for the specific language governing permissions and 22 | * limitations under the License. 23 | */ 24 | 25 | #if defined ( __ICCARM__ ) 26 | #pragma system_include /* treat file as system include file for MISRA check */ 27 | #elif defined (__clang__) 28 | #pragma clang system_header /* treat file as system include file */ 29 | #endif 30 | 31 | #ifndef __CMSIS_VERSION_H 32 | #define __CMSIS_VERSION_H 33 | 34 | /* CMSIS Version definitions */ 35 | #define __CM_CMSIS_VERSION_MAIN ( 5U) /*!< [31:16] CMSIS Core(M) main version */ 36 | #define __CM_CMSIS_VERSION_SUB ( 1U) /*!< [15:0] CMSIS Core(M) sub version */ 37 | #define __CM_CMSIS_VERSION ((__CM_CMSIS_VERSION_MAIN << 16U) | \ 38 | __CM_CMSIS_VERSION_SUB ) /*!< CMSIS Core(M) version number */ 39 | #endif 40 | -------------------------------------------------------------------------------- /01_base_project/Drivers/CMSIS/Include/tz_context.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * @file tz_context.h 3 | * @brief Context Management for Armv8-M TrustZone 4 | * @version V1.0.1 5 | * @date 10. January 2018 6 | ******************************************************************************/ 7 | /* 8 | * Copyright (c) 2017-2018 Arm Limited. All rights reserved. 9 | * 10 | * SPDX-License-Identifier: Apache-2.0 11 | * 12 | * Licensed under the Apache License, Version 2.0 (the License); you may 13 | * not use this file except in compliance with the License. 14 | * You may obtain a copy of the License at 15 | * 16 | * www.apache.org/licenses/LICENSE-2.0 17 | * 18 | * Unless required by applicable law or agreed to in writing, software 19 | * distributed under the License is distributed on an AS IS BASIS, WITHOUT 20 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 21 | * See the License for the specific language governing permissions and 22 | * limitations under the License. 23 | */ 24 | 25 | #if defined ( __ICCARM__ ) 26 | #pragma system_include /* treat file as system include file for MISRA check */ 27 | #elif defined (__clang__) 28 | #pragma clang system_header /* treat file as system include file */ 29 | #endif 30 | 31 | #ifndef TZ_CONTEXT_H 32 | #define TZ_CONTEXT_H 33 | 34 | #include 35 | 36 | #ifndef TZ_MODULEID_T 37 | #define TZ_MODULEID_T 38 | /// \details Data type that identifies secure software modules called by a process. 39 | typedef uint32_t TZ_ModuleId_t; 40 | #endif 41 | 42 | /// \details TZ Memory ID identifies an allocated memory slot. 43 | typedef uint32_t TZ_MemoryId_t; 44 | 45 | /// Initialize secure context memory system 46 | /// \return execution status (1: success, 0: error) 47 | uint32_t TZ_InitContextSystem_S (void); 48 | 49 | /// Allocate context memory for calling secure software modules in TrustZone 50 | /// \param[in] module identifies software modules called from non-secure mode 51 | /// \return value != 0 id TrustZone memory slot identifier 52 | /// \return value 0 no memory available or internal error 53 | TZ_MemoryId_t TZ_AllocModuleContext_S (TZ_ModuleId_t module); 54 | 55 | /// Free context memory that was previously allocated with \ref TZ_AllocModuleContext_S 56 | /// \param[in] id TrustZone memory slot identifier 57 | /// \return execution status (1: success, 0: error) 58 | uint32_t TZ_FreeModuleContext_S (TZ_MemoryId_t id); 59 | 60 | /// Load secure context (called on RTOS thread context switch) 61 | /// \param[in] id TrustZone memory slot identifier 62 | /// \return execution status (1: success, 0: error) 63 | uint32_t TZ_LoadContext_S (TZ_MemoryId_t id); 64 | 65 | /// Store secure context (called on RTOS thread context switch) 66 | /// \param[in] id TrustZone memory slot identifier 67 | /// \return execution status (1: success, 0: error) 68 | uint32_t TZ_StoreContext_S (TZ_MemoryId_t id); 69 | 70 | #endif // TZ_CONTEXT_H 71 | -------------------------------------------------------------------------------- /01_base_project/Drivers/STM32F7xx_HAL_Driver/Inc/stm32f7xx_hal_dma_ex.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f7xx_hal_dma_ex.h 4 | * @author MCD Application Team 5 | * @brief Header file of DMA HAL extension module. 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | * Copyright (c) 2017 STMicroelectronics. 10 | * All rights reserved. 11 | * 12 | * This software is licensed under terms that can be found in the LICENSE file in 13 | * the root directory of this software component. 14 | * If no LICENSE file comes with this software, it is provided AS-IS. 15 | * 16 | ****************************************************************************** 17 | */ 18 | 19 | /* Define to prevent recursive inclusion -------------------------------------*/ 20 | #ifndef __STM32F7xx_HAL_DMA_EX_H 21 | #define __STM32F7xx_HAL_DMA_EX_H 22 | 23 | #ifdef __cplusplus 24 | extern "C" { 25 | #endif 26 | 27 | /* Includes ------------------------------------------------------------------*/ 28 | #include "stm32f7xx_hal_def.h" 29 | 30 | /** @addtogroup STM32F7xx_HAL_Driver 31 | * @{ 32 | */ 33 | 34 | /** @addtogroup DMAEx 35 | * @{ 36 | */ 37 | 38 | /* Exported types ------------------------------------------------------------*/ 39 | /** @defgroup DMAEx_Exported_Types DMAEx Exported Types 40 | * @brief DMAEx Exported types 41 | * @{ 42 | */ 43 | 44 | /** 45 | * @brief HAL DMA Memory definition 46 | */ 47 | typedef enum 48 | { 49 | MEMORY0 = 0x00U, /*!< Memory 0 */ 50 | MEMORY1 = 0x01U, /*!< Memory 1 */ 51 | 52 | }HAL_DMA_MemoryTypeDef; 53 | 54 | /** 55 | * @} 56 | */ 57 | 58 | /* Exported constants --------------------------------------------------------*/ 59 | 60 | /** @defgroup DMA_Exported_Constants DMA Exported Constants 61 | * @brief DMA Exported constants 62 | * @{ 63 | */ 64 | 65 | /** @defgroup DMAEx_Channel_selection DMA Channel selection 66 | * @brief DMAEx channel selection 67 | * @{ 68 | */ 69 | #define DMA_CHANNEL_0 0x00000000U /*!< DMA Channel 0 */ 70 | #define DMA_CHANNEL_1 0x02000000U /*!< DMA Channel 1 */ 71 | #define DMA_CHANNEL_2 0x04000000U /*!< DMA Channel 2 */ 72 | #define DMA_CHANNEL_3 0x06000000U /*!< DMA Channel 3 */ 73 | #define DMA_CHANNEL_4 0x08000000U /*!< DMA Channel 4 */ 74 | #define DMA_CHANNEL_5 0x0A000000U /*!< DMA Channel 5 */ 75 | #define DMA_CHANNEL_6 0x0C000000U /*!< DMA Channel 6 */ 76 | #define DMA_CHANNEL_7 0x0E000000U /*!< DMA Channel 7 */ 77 | #if defined (STM32F722xx) || defined (STM32F723xx) || defined (STM32F732xx) || defined (STM32F733xx) ||\ 78 | defined (STM32F765xx) || defined (STM32F767xx) || defined (STM32F769xx) || defined (STM32F777xx) ||\ 79 | defined (STM32F779xx) || defined (STM32F730xx) 80 | #define DMA_CHANNEL_8 0x10000000U /*!< DMA Channel 8 */ 81 | #define DMA_CHANNEL_9 0x12000000U /*!< DMA Channel 9 */ 82 | #define DMA_CHANNEL_10 0x14000000U /*!< DMA Channel 10*/ 83 | #define DMA_CHANNEL_11 0x16000000U /*!< DMA Channel 11*/ 84 | #define DMA_CHANNEL_12 0x18000000U /*!< DMA Channel 12*/ 85 | #define DMA_CHANNEL_13 0x1A000000U /*!< DMA Channel 13*/ 86 | #define DMA_CHANNEL_14 0x1C000000U /*!< DMA Channel 14*/ 87 | #define DMA_CHANNEL_15 0x1E000000U /*!< DMA Channel 15*/ 88 | #endif /* STM32F722xx || STM32F723xx || STM32F732xx || STM32F733xx || STM32F765xx || STM32F767xx || 89 | STM32F769xx || STM32F777xx || STM32F779xx || STM32F730xx */ 90 | 91 | /** 92 | * @} 93 | */ 94 | 95 | /** 96 | * @} 97 | */ 98 | 99 | /* Exported functions --------------------------------------------------------*/ 100 | /** @defgroup DMAEx_Exported_Functions DMAEx Exported Functions 101 | * @brief DMAEx Exported functions 102 | * @{ 103 | */ 104 | 105 | /** @defgroup DMAEx_Exported_Functions_Group1 Extended features functions 106 | * @brief Extended features functions 107 | * @{ 108 | */ 109 | 110 | /* IO operation functions *******************************************************/ 111 | HAL_StatusTypeDef HAL_DMAEx_MultiBufferStart(DMA_HandleTypeDef *hdma, uint32_t SrcAddress, uint32_t DstAddress, uint32_t SecondMemAddress, uint32_t DataLength); 112 | HAL_StatusTypeDef HAL_DMAEx_MultiBufferStart_IT(DMA_HandleTypeDef *hdma, uint32_t SrcAddress, uint32_t DstAddress, uint32_t SecondMemAddress, uint32_t DataLength); 113 | HAL_StatusTypeDef HAL_DMAEx_ChangeMemory(DMA_HandleTypeDef *hdma, uint32_t Address, HAL_DMA_MemoryTypeDef memory); 114 | 115 | /** 116 | * @} 117 | */ 118 | /** 119 | * @} 120 | */ 121 | 122 | /* Private macros ------------------------------------------------------------*/ 123 | /** @defgroup DMAEx_Private_Macros DMA Private Macros 124 | * @brief DMAEx private macros 125 | * @{ 126 | */ 127 | #if defined (STM32F722xx) || defined (STM32F723xx) || defined (STM32F732xx) || defined (STM32F733xx) ||\ 128 | defined (STM32F765xx) || defined (STM32F767xx) || defined (STM32F769xx) || defined (STM32F777xx) ||\ 129 | defined (STM32F779xx) || defined (STM32F730xx) 130 | #define IS_DMA_CHANNEL(CHANNEL) (((CHANNEL) == DMA_CHANNEL_0) || \ 131 | ((CHANNEL) == DMA_CHANNEL_1) || \ 132 | ((CHANNEL) == DMA_CHANNEL_2) || \ 133 | ((CHANNEL) == DMA_CHANNEL_3) || \ 134 | ((CHANNEL) == DMA_CHANNEL_4) || \ 135 | ((CHANNEL) == DMA_CHANNEL_5) || \ 136 | ((CHANNEL) == DMA_CHANNEL_6) || \ 137 | ((CHANNEL) == DMA_CHANNEL_7) || \ 138 | ((CHANNEL) == DMA_CHANNEL_8) || \ 139 | ((CHANNEL) == DMA_CHANNEL_9) || \ 140 | ((CHANNEL) == DMA_CHANNEL_10) || \ 141 | ((CHANNEL) == DMA_CHANNEL_11) || \ 142 | ((CHANNEL) == DMA_CHANNEL_12) || \ 143 | ((CHANNEL) == DMA_CHANNEL_13) || \ 144 | ((CHANNEL) == DMA_CHANNEL_14) || \ 145 | ((CHANNEL) == DMA_CHANNEL_15)) 146 | #else 147 | #define IS_DMA_CHANNEL(CHANNEL) (((CHANNEL) == DMA_CHANNEL_0) || \ 148 | ((CHANNEL) == DMA_CHANNEL_1) || \ 149 | ((CHANNEL) == DMA_CHANNEL_2) || \ 150 | ((CHANNEL) == DMA_CHANNEL_3) || \ 151 | ((CHANNEL) == DMA_CHANNEL_4) || \ 152 | ((CHANNEL) == DMA_CHANNEL_5) || \ 153 | ((CHANNEL) == DMA_CHANNEL_6) || \ 154 | ((CHANNEL) == DMA_CHANNEL_7)) 155 | #endif /* STM32F722xx || STM32F723xx || STM32F732xx || STM32F733xx || STM32F765xx || STM32F767xx || 156 | STM32F769xx || STM32F777xx || STM32F779xx || STM32F730xx*/ 157 | /** 158 | * @} 159 | */ 160 | 161 | /* Private functions ---------------------------------------------------------*/ 162 | /** @defgroup DMAEx_Private_Functions DMAEx Private Functions 163 | * @brief DMAEx Private functions 164 | * @{ 165 | */ 166 | /** 167 | * @} 168 | */ 169 | 170 | /** 171 | * @} 172 | */ 173 | 174 | /** 175 | * @} 176 | */ 177 | 178 | #ifdef __cplusplus 179 | } 180 | #endif 181 | 182 | #endif /* __STM32F7xx_HAL_DMA_H */ 183 | 184 | -------------------------------------------------------------------------------- /01_base_project/Drivers/STM32F7xx_HAL_Driver/LICENSE.txt: -------------------------------------------------------------------------------- 1 | This software component is provided to you as part of a software package and 2 | applicable license terms are in the Package_license file. If you received this 3 | software component outside of a package or without applicable license terms, 4 | the terms of the BSD-3-Clause license shall apply. 5 | You may obtain a copy of the BSD-3-Clause at: 6 | https://opensource.org/licenses/BSD-3-Clause 7 | -------------------------------------------------------------------------------- /01_base_project/Makefile: -------------------------------------------------------------------------------- 1 | ########################################################################################################################## 2 | # File automatically-generated by tool: [projectgenerator] version: [4.3.0-B58] date: [Tue Jun 25 15:17:07 PDT 2024] 3 | ########################################################################################################################## 4 | 5 | # ------------------------------------------------ 6 | # Generic Makefile (based on gcc) 7 | # 8 | # ChangeLog : 9 | # 2017-02-10 - Several enhancements + project update mode 10 | # 2015-07-22 - first version 11 | # ------------------------------------------------ 12 | 13 | ###################################### 14 | # target 15 | ###################################### 16 | TARGET = blink_example 17 | 18 | 19 | ###################################### 20 | # building variables 21 | ###################################### 22 | # debug build? 23 | DEBUG = 0 24 | # optimization 25 | OPT = -Og 26 | 27 | 28 | ####################################### 29 | # paths 30 | ####################################### 31 | # Build path 32 | BUILD_DIR = build 33 | 34 | ###################################### 35 | # source 36 | ###################################### 37 | # C sources 38 | C_SOURCES = \ 39 | Core/Src/main.c \ 40 | Core/Src/gpio.c \ 41 | Core/Src/stm32f7xx_it.c \ 42 | Core/Src/stm32f7xx_hal_msp.c \ 43 | Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_cortex.c \ 44 | Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_rcc.c \ 45 | Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_rcc_ex.c \ 46 | Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_flash.c \ 47 | Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_flash_ex.c \ 48 | Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_gpio.c \ 49 | Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_dma.c \ 50 | Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_dma_ex.c \ 51 | Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_pwr.c \ 52 | Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_pwr_ex.c \ 53 | Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal.c \ 54 | Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_i2c.c \ 55 | Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_i2c_ex.c \ 56 | Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_exti.c \ 57 | Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_tim.c \ 58 | Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_tim_ex.c \ 59 | Core/Src/system_stm32f7xx.c \ 60 | Core/Src/sysmem.c \ 61 | Core/Src/syscalls.c 62 | 63 | # ASM sources 64 | ASM_SOURCES = \ 65 | startup_stm32f750xx.s 66 | 67 | # ASM sources 68 | ASMM_SOURCES = 69 | 70 | 71 | ####################################### 72 | # binaries 73 | ####################################### 74 | PREFIX = arm-none-eabi- 75 | # The gcc compiler bin path can be either defined in make command via GCC_PATH variable (> make GCC_PATH=xxx) 76 | # either it can be added to the PATH environment variable. 77 | ifdef GCC_PATH 78 | CC = $(GCC_PATH)/$(PREFIX)gcc 79 | AS = $(GCC_PATH)/$(PREFIX)gcc -x assembler-with-cpp 80 | CP = $(GCC_PATH)/$(PREFIX)objcopy 81 | SZ = $(GCC_PATH)/$(PREFIX)size 82 | else 83 | CC = $(PREFIX)gcc 84 | AS = $(PREFIX)gcc -x assembler-with-cpp 85 | CP = $(PREFIX)objcopy 86 | SZ = $(PREFIX)size 87 | endif 88 | HEX = $(CP) -O ihex 89 | BIN = $(CP) -O binary -S 90 | 91 | ####################################### 92 | # CFLAGS 93 | ####################################### 94 | # cpu 95 | CPU = -mcpu=cortex-m7 96 | 97 | # fpu 98 | FPU = -mfpu=fpv5-sp-d16 99 | 100 | # float-abi 101 | FLOAT-ABI = -mfloat-abi=hard 102 | 103 | # mcu 104 | MCU = $(CPU) -mthumb $(FPU) $(FLOAT-ABI) 105 | 106 | # macros for gcc 107 | # AS defines 108 | AS_DEFS = 109 | 110 | # C defines 111 | C_DEFS = \ 112 | -DUSE_HAL_DRIVER \ 113 | -DSTM32F750xx 114 | 115 | 116 | # AS includes 117 | AS_INCLUDES = 118 | 119 | # C includes 120 | C_INCLUDES = \ 121 | -ICore/Inc \ 122 | -IDrivers/STM32F7xx_HAL_Driver/Inc \ 123 | -IDrivers/STM32F7xx_HAL_Driver/Inc/Legacy \ 124 | -IDrivers/CMSIS/Device/ST/STM32F7xx/Include \ 125 | -IDrivers/CMSIS/Include 126 | 127 | 128 | # compile gcc flags 129 | ASFLAGS = $(MCU) $(AS_DEFS) $(AS_INCLUDES) $(OPT) -Wall -fdata-sections -ffunction-sections 130 | 131 | CFLAGS += $(MCU) $(C_DEFS) $(C_INCLUDES) $(OPT) -Wall -fdata-sections -ffunction-sections 132 | 133 | ifeq ($(DEBUG), 1) 134 | CFLAGS += -g -gdwarf-2 135 | endif 136 | 137 | 138 | # Generate dependency information 139 | CFLAGS += -MMD -MP -MF"$(@:%.o=%.d)" 140 | 141 | 142 | ####################################### 143 | # LDFLAGS 144 | ####################################### 145 | # link script 146 | LDSCRIPT = STM32F750N8Hx_FLASH.ld 147 | 148 | # libraries 149 | LIBS = -lc -lm -lnosys 150 | LIBDIR = 151 | LDFLAGS = $(MCU) -specs=nano.specs -T$(LDSCRIPT) $(LIBDIR) $(LIBS) -Wl,-Map=$(BUILD_DIR)/$(TARGET).map,--cref -Wl,--gc-sections,--verbose 152 | 153 | # default action: build all 154 | all: $(BUILD_DIR)/$(TARGET).elf $(BUILD_DIR)/$(TARGET).hex $(BUILD_DIR)/$(TARGET).bin 155 | 156 | 157 | ####################################### 158 | # build the application 159 | ####################################### 160 | # list of objects 161 | OBJECTS = $(addprefix $(BUILD_DIR)/,$(notdir $(C_SOURCES:.c=.o))) 162 | vpath %.c $(sort $(dir $(C_SOURCES))) 163 | # list of ASM program objects 164 | OBJECTS += $(addprefix $(BUILD_DIR)/,$(notdir $(ASM_SOURCES:.s=.o))) 165 | vpath %.s $(sort $(dir $(ASM_SOURCES))) 166 | OBJECTS += $(addprefix $(BUILD_DIR)/,$(notdir $(ASMM_SOURCES:.S=.o))) 167 | vpath %.S $(sort $(dir $(ASMM_SOURCES))) 168 | 169 | $(BUILD_DIR)/%.o: %.c Makefile | $(BUILD_DIR) 170 | $(CC) -c $(CFLAGS) -Wa,-a,-ad,-alms=$(BUILD_DIR)/$(notdir $(<:.c=.lst)) $< -o $@ 171 | 172 | $(BUILD_DIR)/%.o: %.s Makefile | $(BUILD_DIR) 173 | $(AS) -c $(CFLAGS) $< -o $@ 174 | $(BUILD_DIR)/%.o: %.S Makefile | $(BUILD_DIR) 175 | $(AS) -c $(CFLAGS) $< -o $@ 176 | 177 | $(BUILD_DIR)/$(TARGET).elf: $(OBJECTS) Makefile 178 | $(CC) $(OBJECTS) $(LDFLAGS) -o $@ 179 | $(SZ) $@ 180 | 181 | $(BUILD_DIR)/%.hex: $(BUILD_DIR)/%.elf | $(BUILD_DIR) 182 | $(HEX) $< $@ 183 | 184 | $(BUILD_DIR)/%.bin: $(BUILD_DIR)/%.elf | $(BUILD_DIR) 185 | $(BIN) $< $@ 186 | 187 | $(BUILD_DIR): 188 | mkdir $@ 189 | 190 | ####################################### 191 | # clean up 192 | ####################################### 193 | clean: 194 | -rm -fR $(BUILD_DIR) 195 | 196 | ####################################### 197 | # dependencies 198 | ####################################### 199 | -include $(wildcard $(BUILD_DIR)/*.d) 200 | 201 | # *** EOF *** 202 | -------------------------------------------------------------------------------- /01_base_project/README.md: -------------------------------------------------------------------------------- 1 | # Baseline STM32CubeMX Project 2 | 3 | This is a simple project for the STM32F750N8 microcontroller generated using STM32CubeMX. 4 | The only user code that's been added is to [main.c](Core/Src/main.c) which blinks an LED on my particular board: 5 | ```C 6 | HAL_GPIO_WritePin(LED_BLINK_GPIO_Port, LED_BLINK_Pin, GPIO_PIN_RESET); 7 | HAL_Delay(1000); 8 | HAL_GPIO_WritePin(LED_BLINK_GPIO_Port, LED_BLINK_Pin, GPIO_PIN_SET); 9 | HAL_Delay(1000); 10 | ``` 11 | -------------------------------------------------------------------------------- /01_base_project/STM32F750N8Hx_FLASH.ld: -------------------------------------------------------------------------------- 1 | /* 2 | ****************************************************************************** 3 | ** 4 | 5 | ** File : LinkerScript.ld 6 | ** 7 | ** Author : STM32CubeMX 8 | ** 9 | ** Abstract : Linker script for STM32F750N8Hx series 10 | ** 64Kbytes FLASH and 320Kbytes RAM 11 | ** 12 | ** Set heap size, stack size and stack location according 13 | ** to application requirements. 14 | ** 15 | ** Set memory bank area and size if external memory is used. 16 | ** 17 | ** Target : STMicroelectronics STM32 18 | ** 19 | ** Distribution: The file is distributed “as is,” without any warranty 20 | ** of any kind. 21 | ** 22 | ***************************************************************************** 23 | ** @attention 24 | ** 25 | **

© COPYRIGHT(c) 2019 STMicroelectronics

26 | ** 27 | ** Redistribution and use in source and binary forms, with or without modification, 28 | ** are permitted provided that the following conditions are met: 29 | ** 1. Redistributions of source code must retain the above copyright notice, 30 | ** this list of conditions and the following disclaimer. 31 | ** 2. Redistributions in binary form must reproduce the above copyright notice, 32 | ** this list of conditions and the following disclaimer in the documentation 33 | ** and/or other materials provided with the distribution. 34 | ** 3. Neither the name of STMicroelectronics nor the names of its contributors 35 | ** may be used to endorse or promote products derived from this software 36 | ** without specific prior written permission. 37 | ** 38 | ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 39 | ** AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 40 | ** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 41 | ** DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 42 | ** FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 43 | ** DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 44 | ** SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 45 | ** CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 46 | ** OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 47 | ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 48 | ** 49 | ***************************************************************************** 50 | */ 51 | 52 | /* Entry Point */ 53 | ENTRY(Reset_Handler) 54 | 55 | /* Highest address of the user mode stack */ 56 | _estack = ORIGIN(RAM) + LENGTH(RAM); /* end of RAM */ 57 | /* Generate a link error if heap and stack don't fit into RAM */ 58 | _Min_Heap_Size = 0x200; /* required amount of heap */ 59 | _Min_Stack_Size = 0x400; /* required amount of stack */ 60 | 61 | /* Specify the memory areas */ 62 | MEMORY 63 | { 64 | RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 320K 65 | FLASH (rx) : ORIGIN = 0x8000000, LENGTH = 64K 66 | } 67 | 68 | /* Define output sections */ 69 | SECTIONS 70 | { 71 | /* The startup code goes first into FLASH */ 72 | .isr_vector : 73 | { 74 | . = ALIGN(4); 75 | KEEP(*(.isr_vector)) /* Startup code */ 76 | . = ALIGN(4); 77 | } >FLASH 78 | 79 | /* The program code and other data goes into FLASH */ 80 | .text : 81 | { 82 | . = ALIGN(4); 83 | *(.text) /* .text sections (code) */ 84 | *(.text*) /* .text* sections (code) */ 85 | *(.glue_7) /* glue arm to thumb code */ 86 | *(.glue_7t) /* glue thumb to arm code */ 87 | *(.eh_frame) 88 | 89 | KEEP (*(.init)) 90 | KEEP (*(.fini)) 91 | 92 | . = ALIGN(4); 93 | _etext = .; /* define a global symbols at end of code */ 94 | } >FLASH 95 | 96 | /* Constant data goes into FLASH */ 97 | .rodata : 98 | { 99 | . = ALIGN(4); 100 | *(.rodata) /* .rodata sections (constants, strings, etc.) */ 101 | *(.rodata*) /* .rodata* sections (constants, strings, etc.) */ 102 | . = ALIGN(4); 103 | } >FLASH 104 | 105 | .ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) } >FLASH 106 | .ARM : { 107 | __exidx_start = .; 108 | *(.ARM.exidx*) 109 | __exidx_end = .; 110 | } >FLASH 111 | 112 | .preinit_array : 113 | { 114 | PROVIDE_HIDDEN (__preinit_array_start = .); 115 | KEEP (*(.preinit_array*)) 116 | PROVIDE_HIDDEN (__preinit_array_end = .); 117 | } >FLASH 118 | .init_array : 119 | { 120 | PROVIDE_HIDDEN (__init_array_start = .); 121 | KEEP (*(SORT(.init_array.*))) 122 | KEEP (*(.init_array*)) 123 | PROVIDE_HIDDEN (__init_array_end = .); 124 | } >FLASH 125 | .fini_array : 126 | { 127 | PROVIDE_HIDDEN (__fini_array_start = .); 128 | KEEP (*(SORT(.fini_array.*))) 129 | KEEP (*(.fini_array*)) 130 | PROVIDE_HIDDEN (__fini_array_end = .); 131 | } >FLASH 132 | 133 | /* used by the startup to initialize data */ 134 | _sidata = LOADADDR(.data); 135 | 136 | /* Initialized data sections goes into RAM, load LMA copy after code */ 137 | .data : 138 | { 139 | . = ALIGN(4); 140 | _sdata = .; /* create a global symbol at data start */ 141 | *(.data) /* .data sections */ 142 | *(.data*) /* .data* sections */ 143 | 144 | . = ALIGN(4); 145 | _edata = .; /* define a global symbol at data end */ 146 | } >RAM AT> FLASH 147 | 148 | 149 | /* Uninitialized data section */ 150 | . = ALIGN(4); 151 | .bss : 152 | { 153 | /* This is used by the startup in order to initialize the .bss secion */ 154 | _sbss = .; /* define a global symbol at bss start */ 155 | __bss_start__ = _sbss; 156 | *(.bss) 157 | *(.bss*) 158 | *(COMMON) 159 | 160 | . = ALIGN(4); 161 | _ebss = .; /* define a global symbol at bss end */ 162 | __bss_end__ = _ebss; 163 | } >RAM 164 | 165 | /* User_heap_stack section, used to check that there is enough RAM left */ 166 | ._user_heap_stack : 167 | { 168 | . = ALIGN(8); 169 | PROVIDE ( end = . ); 170 | PROVIDE ( _end = . ); 171 | . = . + _Min_Heap_Size; 172 | . = . + _Min_Stack_Size; 173 | . = ALIGN(8); 174 | } >RAM 175 | 176 | 177 | 178 | /* Remove information from the standard libraries */ 179 | /DISCARD/ : 180 | { 181 | libc.a ( * ) 182 | libm.a ( * ) 183 | libgcc.a ( * ) 184 | } 185 | 186 | .ARM.attributes 0 : { *(.ARM.attributes) } 187 | } 188 | 189 | 190 | -------------------------------------------------------------------------------- /02_drop_in_compiler/Core/Inc/gpio.h: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file gpio.h 5 | * @brief This file contains all the function prototypes for 6 | * the gpio.c file 7 | ****************************************************************************** 8 | * @attention 9 | * 10 | * Copyright (c) 2024 STMicroelectronics. 11 | * All rights reserved. 12 | * 13 | * This software is licensed under terms that can be found in the LICENSE file 14 | * in the root directory of this software component. 15 | * If no LICENSE file comes with this software, it is provided AS-IS. 16 | * 17 | ****************************************************************************** 18 | */ 19 | /* USER CODE END Header */ 20 | /* Define to prevent recursive inclusion -------------------------------------*/ 21 | #ifndef __GPIO_H__ 22 | #define __GPIO_H__ 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | /* Includes ------------------------------------------------------------------*/ 29 | #include "main.h" 30 | 31 | /* USER CODE BEGIN Includes */ 32 | 33 | /* USER CODE END Includes */ 34 | 35 | /* USER CODE BEGIN Private defines */ 36 | 37 | /* USER CODE END Private defines */ 38 | 39 | void MX_GPIO_Init(void); 40 | 41 | /* USER CODE BEGIN Prototypes */ 42 | 43 | /* USER CODE END Prototypes */ 44 | 45 | #ifdef __cplusplus 46 | } 47 | #endif 48 | #endif /*__ GPIO_H__ */ 49 | 50 | -------------------------------------------------------------------------------- /02_drop_in_compiler/Core/Inc/main.h: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file : main.h 5 | * @brief : Header for main.c file. 6 | * This file contains the common defines of the application. 7 | ****************************************************************************** 8 | * @attention 9 | * 10 | * Copyright (c) 2024 STMicroelectronics. 11 | * All rights reserved. 12 | * 13 | * This software is licensed under terms that can be found in the LICENSE file 14 | * in the root directory of this software component. 15 | * If no LICENSE file comes with this software, it is provided AS-IS. 16 | * 17 | ****************************************************************************** 18 | */ 19 | /* USER CODE END Header */ 20 | 21 | /* Define to prevent recursive inclusion -------------------------------------*/ 22 | #ifndef __MAIN_H 23 | #define __MAIN_H 24 | 25 | #ifdef __cplusplus 26 | extern "C" { 27 | #endif 28 | 29 | /* Includes ------------------------------------------------------------------*/ 30 | #include "stm32f7xx_hal.h" 31 | 32 | /* Private includes ----------------------------------------------------------*/ 33 | /* USER CODE BEGIN Includes */ 34 | 35 | /* USER CODE END Includes */ 36 | 37 | /* Exported types ------------------------------------------------------------*/ 38 | /* USER CODE BEGIN ET */ 39 | 40 | /* USER CODE END ET */ 41 | 42 | /* Exported constants --------------------------------------------------------*/ 43 | /* USER CODE BEGIN EC */ 44 | 45 | /* USER CODE END EC */ 46 | 47 | /* Exported macro ------------------------------------------------------------*/ 48 | /* USER CODE BEGIN EM */ 49 | 50 | /* USER CODE END EM */ 51 | 52 | /* Exported functions prototypes ---------------------------------------------*/ 53 | void Error_Handler(void); 54 | 55 | /* USER CODE BEGIN EFP */ 56 | void hal_initialization_code(void); 57 | 58 | /* USER CODE END EFP */ 59 | 60 | /* Private defines -----------------------------------------------------------*/ 61 | #define LED_BLINK_Pin GPIO_PIN_15 62 | #define LED_BLINK_GPIO_Port GPIOA 63 | 64 | /* USER CODE BEGIN Private defines */ 65 | 66 | /* USER CODE END Private defines */ 67 | 68 | #ifdef __cplusplus 69 | } 70 | #endif 71 | 72 | #endif /* __MAIN_H */ 73 | -------------------------------------------------------------------------------- /02_drop_in_compiler/Core/Inc/stm32f7xx_it.h: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file stm32f7xx_it.h 5 | * @brief This file contains the headers of the interrupt handlers. 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | * Copyright (c) 2024 STMicroelectronics. 10 | * All rights reserved. 11 | * 12 | * This software is licensed under terms that can be found in the LICENSE file 13 | * in the root directory of this software component. 14 | * If no LICENSE file comes with this software, it is provided AS-IS. 15 | * 16 | ****************************************************************************** 17 | */ 18 | /* USER CODE END Header */ 19 | 20 | /* Define to prevent recursive inclusion -------------------------------------*/ 21 | #ifndef __STM32F7xx_IT_H 22 | #define __STM32F7xx_IT_H 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | /* Private includes ----------------------------------------------------------*/ 29 | /* USER CODE BEGIN Includes */ 30 | 31 | /* USER CODE END Includes */ 32 | 33 | /* Exported types ------------------------------------------------------------*/ 34 | /* USER CODE BEGIN ET */ 35 | 36 | /* USER CODE END ET */ 37 | 38 | /* Exported constants --------------------------------------------------------*/ 39 | /* USER CODE BEGIN EC */ 40 | 41 | /* USER CODE END EC */ 42 | 43 | /* Exported macro ------------------------------------------------------------*/ 44 | /* USER CODE BEGIN EM */ 45 | 46 | /* USER CODE END EM */ 47 | 48 | /* Exported functions prototypes ---------------------------------------------*/ 49 | void SysTick_Handler(void); 50 | /* USER CODE BEGIN EFP */ 51 | 52 | /* USER CODE END EFP */ 53 | 54 | #ifdef __cplusplus 55 | } 56 | #endif 57 | 58 | #endif /* __STM32F7xx_IT_H */ 59 | -------------------------------------------------------------------------------- /02_drop_in_compiler/Core/Src/gpio.c: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file gpio.c 5 | * @brief This file provides code for the configuration 6 | * of all used GPIO pins. 7 | ****************************************************************************** 8 | * @attention 9 | * 10 | * Copyright (c) 2024 STMicroelectronics. 11 | * All rights reserved. 12 | * 13 | * This software is licensed under terms that can be found in the LICENSE file 14 | * in the root directory of this software component. 15 | * If no LICENSE file comes with this software, it is provided AS-IS. 16 | * 17 | ****************************************************************************** 18 | */ 19 | /* USER CODE END Header */ 20 | 21 | /* Includes ------------------------------------------------------------------*/ 22 | #include "gpio.h" 23 | 24 | /* USER CODE BEGIN 0 */ 25 | 26 | /* USER CODE END 0 */ 27 | 28 | /*----------------------------------------------------------------------------*/ 29 | /* Configure GPIO */ 30 | /*----------------------------------------------------------------------------*/ 31 | /* USER CODE BEGIN 1 */ 32 | 33 | /* USER CODE END 1 */ 34 | 35 | /** Configure pins 36 | PE2 ------> QUADSPI_BK1_IO2 37 | PB6 ------> QUADSPI_BK1_NCS 38 | PB2 ------> QUADSPI_CLK 39 | PD12 ------> QUADSPI_BK1_IO1 40 | PD13 ------> QUADSPI_BK1_IO3 41 | PD11 ------> QUADSPI_BK1_IO0 42 | */ 43 | void MX_GPIO_Init(void) 44 | { 45 | 46 | GPIO_InitTypeDef GPIO_InitStruct = {0}; 47 | 48 | /* GPIO Ports Clock Enable */ 49 | __HAL_RCC_GPIOE_CLK_ENABLE(); 50 | __HAL_RCC_GPIOA_CLK_ENABLE(); 51 | __HAL_RCC_GPIOB_CLK_ENABLE(); 52 | __HAL_RCC_GPIOH_CLK_ENABLE(); 53 | __HAL_RCC_GPIOD_CLK_ENABLE(); 54 | 55 | /*Configure GPIO pin Output Level */ 56 | HAL_GPIO_WritePin(LED_BLINK_GPIO_Port, LED_BLINK_Pin, GPIO_PIN_RESET); 57 | 58 | /*Configure GPIO pin : PE2 */ 59 | GPIO_InitStruct.Pin = GPIO_PIN_2; 60 | GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; 61 | GPIO_InitStruct.Pull = GPIO_NOPULL; 62 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; 63 | GPIO_InitStruct.Alternate = GPIO_AF9_QUADSPI; 64 | HAL_GPIO_Init(GPIOE, &GPIO_InitStruct); 65 | 66 | /*Configure GPIO pin : PtPin */ 67 | GPIO_InitStruct.Pin = LED_BLINK_Pin; 68 | GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; 69 | GPIO_InitStruct.Pull = GPIO_NOPULL; 70 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; 71 | HAL_GPIO_Init(LED_BLINK_GPIO_Port, &GPIO_InitStruct); 72 | 73 | /*Configure GPIO pin : PB6 */ 74 | GPIO_InitStruct.Pin = GPIO_PIN_6; 75 | GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; 76 | GPIO_InitStruct.Pull = GPIO_NOPULL; 77 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; 78 | GPIO_InitStruct.Alternate = GPIO_AF10_QUADSPI; 79 | HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); 80 | 81 | /*Configure GPIO pin : PB2 */ 82 | GPIO_InitStruct.Pin = GPIO_PIN_2; 83 | GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; 84 | GPIO_InitStruct.Pull = GPIO_NOPULL; 85 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; 86 | GPIO_InitStruct.Alternate = GPIO_AF9_QUADSPI; 87 | HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); 88 | 89 | /*Configure GPIO pins : PD12 PD13 PD11 */ 90 | GPIO_InitStruct.Pin = GPIO_PIN_12|GPIO_PIN_13|GPIO_PIN_11; 91 | GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; 92 | GPIO_InitStruct.Pull = GPIO_NOPULL; 93 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; 94 | GPIO_InitStruct.Alternate = GPIO_AF9_QUADSPI; 95 | HAL_GPIO_Init(GPIOD, &GPIO_InitStruct); 96 | 97 | } 98 | 99 | /* USER CODE BEGIN 2 */ 100 | 101 | /* USER CODE END 2 */ 102 | -------------------------------------------------------------------------------- /02_drop_in_compiler/Core/Src/stm32f7xx_hal_msp.c: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file stm32f7xx_hal_msp.c 5 | * @brief This file provides code for the MSP Initialization 6 | * and de-Initialization codes. 7 | ****************************************************************************** 8 | * @attention 9 | * 10 | * Copyright (c) 2024 STMicroelectronics. 11 | * All rights reserved. 12 | * 13 | * This software is licensed under terms that can be found in the LICENSE file 14 | * in the root directory of this software component. 15 | * If no LICENSE file comes with this software, it is provided AS-IS. 16 | * 17 | ****************************************************************************** 18 | */ 19 | /* USER CODE END Header */ 20 | 21 | /* Includes ------------------------------------------------------------------*/ 22 | #include "main.h" 23 | /* USER CODE BEGIN Includes */ 24 | 25 | /* USER CODE END Includes */ 26 | 27 | /* Private typedef -----------------------------------------------------------*/ 28 | /* USER CODE BEGIN TD */ 29 | 30 | /* USER CODE END TD */ 31 | 32 | /* Private define ------------------------------------------------------------*/ 33 | /* USER CODE BEGIN Define */ 34 | 35 | /* USER CODE END Define */ 36 | 37 | /* Private macro -------------------------------------------------------------*/ 38 | /* USER CODE BEGIN Macro */ 39 | 40 | /* USER CODE END Macro */ 41 | 42 | /* Private variables ---------------------------------------------------------*/ 43 | /* USER CODE BEGIN PV */ 44 | 45 | /* USER CODE END PV */ 46 | 47 | /* Private function prototypes -----------------------------------------------*/ 48 | /* USER CODE BEGIN PFP */ 49 | 50 | /* USER CODE END PFP */ 51 | 52 | /* External functions --------------------------------------------------------*/ 53 | /* USER CODE BEGIN ExternalFunctions */ 54 | 55 | /* USER CODE END ExternalFunctions */ 56 | 57 | /* USER CODE BEGIN 0 */ 58 | 59 | /* USER CODE END 0 */ 60 | /** 61 | * Initializes the Global MSP. 62 | */ 63 | void HAL_MspInit(void) 64 | { 65 | 66 | /* USER CODE BEGIN MspInit 0 */ 67 | 68 | /* USER CODE END MspInit 0 */ 69 | 70 | __HAL_RCC_PWR_CLK_ENABLE(); 71 | __HAL_RCC_SYSCFG_CLK_ENABLE(); 72 | 73 | /* System interrupt init*/ 74 | 75 | /* USER CODE BEGIN MspInit 1 */ 76 | 77 | /* USER CODE END MspInit 1 */ 78 | } 79 | 80 | /* USER CODE BEGIN 1 */ 81 | 82 | /* USER CODE END 1 */ 83 | -------------------------------------------------------------------------------- /02_drop_in_compiler/Core/Src/stm32f7xx_it.c: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file stm32f7xx_it.c 5 | * @brief Interrupt Service Routines. 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | * Copyright (c) 2024 STMicroelectronics. 10 | * All rights reserved. 11 | * 12 | * This software is licensed under terms that can be found in the LICENSE file 13 | * in the root directory of this software component. 14 | * If no LICENSE file comes with this software, it is provided AS-IS. 15 | * 16 | ****************************************************************************** 17 | */ 18 | /* USER CODE END Header */ 19 | 20 | /* Includes ------------------------------------------------------------------*/ 21 | #include "main.h" 22 | #include "stm32f7xx_it.h" 23 | /* Private includes ----------------------------------------------------------*/ 24 | /* USER CODE BEGIN Includes */ 25 | /* USER CODE END Includes */ 26 | 27 | /* Private typedef -----------------------------------------------------------*/ 28 | /* USER CODE BEGIN TD */ 29 | 30 | /* USER CODE END TD */ 31 | 32 | /* Private define ------------------------------------------------------------*/ 33 | /* USER CODE BEGIN PD */ 34 | 35 | /* USER CODE END PD */ 36 | 37 | /* Private macro -------------------------------------------------------------*/ 38 | /* USER CODE BEGIN PM */ 39 | 40 | /* USER CODE END PM */ 41 | 42 | /* Private variables ---------------------------------------------------------*/ 43 | /* USER CODE BEGIN PV */ 44 | 45 | /* USER CODE END PV */ 46 | 47 | /* Private function prototypes -----------------------------------------------*/ 48 | /* USER CODE BEGIN PFP */ 49 | 50 | /* USER CODE END PFP */ 51 | 52 | /* Private user code ---------------------------------------------------------*/ 53 | /* USER CODE BEGIN 0 */ 54 | 55 | /* USER CODE END 0 */ 56 | 57 | /* External variables --------------------------------------------------------*/ 58 | 59 | /* USER CODE BEGIN EV */ 60 | 61 | /* USER CODE END EV */ 62 | 63 | /******************************************************************************/ 64 | /* Cortex-M7 Processor Interruption and Exception Handlers */ 65 | /******************************************************************************/ 66 | /** 67 | * @brief This function handles System tick timer. 68 | */ 69 | void SysTick_Handler(void) 70 | { 71 | /* USER CODE BEGIN SysTick_IRQn 0 */ 72 | 73 | /* USER CODE END SysTick_IRQn 0 */ 74 | HAL_IncTick(); 75 | /* USER CODE BEGIN SysTick_IRQn 1 */ 76 | 77 | /* USER CODE END SysTick_IRQn 1 */ 78 | } 79 | 80 | /******************************************************************************/ 81 | /* STM32F7xx Peripheral Interrupt Handlers */ 82 | /* Add here the Interrupt Handlers for the used peripherals. */ 83 | /* For the available peripheral interrupt handler names, */ 84 | /* please refer to the startup file (startup_stm32f7xx.s). */ 85 | /******************************************************************************/ 86 | 87 | /* USER CODE BEGIN 1 */ 88 | 89 | /* USER CODE END 1 */ 90 | -------------------------------------------------------------------------------- /02_drop_in_compiler/Core/Src/syscalls.c: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file syscalls.c 4 | * @author Auto-generated by STM32CubeMX 5 | * @brief Minimal System calls file 6 | * 7 | * For more information about which c-functions 8 | * need which of these lowlevel functions 9 | * please consult the Newlib libc-manual 10 | ****************************************************************************** 11 | * @attention 12 | * 13 | * Copyright (c) 2020-2024 STMicroelectronics. 14 | * All rights reserved. 15 | * 16 | * This software is licensed under terms that can be found in the LICENSE file 17 | * in the root directory of this software component. 18 | * If no LICENSE file comes with this software, it is provided AS-IS. 19 | * 20 | ****************************************************************************** 21 | */ 22 | 23 | /* Includes */ 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | 33 | /* Variables */ 34 | extern int __io_putchar(int ch) __attribute__((weak)); 35 | extern int __io_getchar(void) __attribute__((weak)); 36 | 37 | char *__env[1] = {0}; 38 | char **environ = __env; 39 | 40 | /* Functions */ 41 | void initialise_monitor_handles() 42 | { 43 | } 44 | 45 | int _getpid(void) 46 | { 47 | return 1; 48 | } 49 | 50 | int _kill(int pid, int sig) 51 | { 52 | (void)pid; 53 | (void)sig; 54 | errno = EINVAL; 55 | return -1; 56 | } 57 | 58 | void _exit(int status) 59 | { 60 | _kill(status, -1); 61 | while (1) 62 | { 63 | } /* Make sure we hang here */ 64 | } 65 | 66 | __attribute__((weak)) int _read(int file, char *ptr, int len) 67 | { 68 | (void)file; 69 | int DataIdx; 70 | 71 | for (DataIdx = 0; DataIdx < len; DataIdx++) 72 | { 73 | *ptr++ = __io_getchar(); 74 | } 75 | 76 | return len; 77 | } 78 | 79 | __attribute__((weak)) int _write(int file, char *ptr, int len) 80 | { 81 | (void)file; 82 | int DataIdx; 83 | 84 | for (DataIdx = 0; DataIdx < len; DataIdx++) 85 | { 86 | __io_putchar(*ptr++); 87 | } 88 | return len; 89 | } 90 | 91 | int _close(int file) 92 | { 93 | (void)file; 94 | return -1; 95 | } 96 | 97 | int _fstat(int file, struct stat *st) 98 | { 99 | (void)file; 100 | st->st_mode = S_IFCHR; 101 | return 0; 102 | } 103 | 104 | int _isatty(int file) 105 | { 106 | (void)file; 107 | return 1; 108 | } 109 | 110 | int _lseek(int file, int ptr, int dir) 111 | { 112 | (void)file; 113 | (void)ptr; 114 | (void)dir; 115 | return 0; 116 | } 117 | 118 | int _open(char *path, int flags, ...) 119 | { 120 | (void)path; 121 | (void)flags; 122 | /* Pretend like we always fail */ 123 | return -1; 124 | } 125 | 126 | int _wait(int *status) 127 | { 128 | (void)status; 129 | errno = ECHILD; 130 | return -1; 131 | } 132 | 133 | int _unlink(char *name) 134 | { 135 | (void)name; 136 | errno = ENOENT; 137 | return -1; 138 | } 139 | 140 | int _times(struct tms *buf) 141 | { 142 | (void)buf; 143 | return -1; 144 | } 145 | 146 | int _stat(char *file, struct stat *st) 147 | { 148 | (void)file; 149 | st->st_mode = S_IFCHR; 150 | return 0; 151 | } 152 | 153 | int _link(char *old, char *new) 154 | { 155 | (void)old; 156 | (void)new; 157 | errno = EMLINK; 158 | return -1; 159 | } 160 | 161 | int _fork(void) 162 | { 163 | errno = EAGAIN; 164 | return -1; 165 | } 166 | 167 | int _execve(char *name, char **argv, char **env) 168 | { 169 | (void)name; 170 | (void)argv; 171 | (void)env; 172 | errno = ENOMEM; 173 | return -1; 174 | } 175 | -------------------------------------------------------------------------------- /02_drop_in_compiler/Core/Src/sysmem.c: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file sysmem.c 4 | * @author Generated by STM32CubeMX 5 | * @brief System Memory calls file 6 | * 7 | * For more information about which C functions 8 | * need which of these lowlevel functions 9 | * please consult the newlib libc manual 10 | ****************************************************************************** 11 | * @attention 12 | * 13 | * Copyright (c) 2024 STMicroelectronics. 14 | * All rights reserved. 15 | * 16 | * This software is licensed under terms that can be found in the LICENSE file 17 | * in the root directory of this software component. 18 | * If no LICENSE file comes with this software, it is provided AS-IS. 19 | * 20 | ****************************************************************************** 21 | */ 22 | 23 | /* Includes */ 24 | #include 25 | #include 26 | 27 | /** 28 | * Pointer to the current high watermark of the heap usage 29 | */ 30 | static uint8_t *__sbrk_heap_end = NULL; 31 | 32 | /** 33 | * @brief _sbrk() allocates memory to the newlib heap and is used by malloc 34 | * and others from the C library 35 | * 36 | * @verbatim 37 | * ############################################################################ 38 | * # .data # .bss # newlib heap # MSP stack # 39 | * # # # # Reserved by _Min_Stack_Size # 40 | * ############################################################################ 41 | * ^-- RAM start ^-- _end _estack, RAM end --^ 42 | * @endverbatim 43 | * 44 | * This implementation starts allocating at the '_end' linker symbol 45 | * The '_Min_Stack_Size' linker symbol reserves a memory for the MSP stack 46 | * The implementation considers '_estack' linker symbol to be RAM end 47 | * NOTE: If the MSP stack, at any point during execution, grows larger than the 48 | * reserved size, please increase the '_Min_Stack_Size'. 49 | * 50 | * @param incr Memory size 51 | * @return Pointer to allocated memory 52 | */ 53 | void *_sbrk(ptrdiff_t incr) 54 | { 55 | extern uint8_t _end; /* Symbol defined in the linker script */ 56 | extern uint8_t _estack; /* Symbol defined in the linker script */ 57 | extern uint32_t _Min_Stack_Size; /* Symbol defined in the linker script */ 58 | const uint32_t stack_limit = (uint32_t)&_estack - (uint32_t)&_Min_Stack_Size; 59 | const uint8_t *max_heap = (uint8_t *)stack_limit; 60 | uint8_t *prev_heap_end; 61 | 62 | /* Initialize heap end at first call */ 63 | if (NULL == __sbrk_heap_end) 64 | { 65 | __sbrk_heap_end = &_end; 66 | } 67 | 68 | /* Protect heap from growing into the reserved MSP stack */ 69 | if (__sbrk_heap_end + incr > max_heap) 70 | { 71 | errno = ENOMEM; 72 | return (void *)-1; 73 | } 74 | 75 | prev_heap_end = __sbrk_heap_end; 76 | __sbrk_heap_end += incr; 77 | 78 | return (void *)prev_heap_end; 79 | } 80 | -------------------------------------------------------------------------------- /02_drop_in_compiler/Drivers/CMSIS/Device/ST/STM32F7xx/Include/system_stm32f7xx.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file system_stm32f7xx.h 4 | * @author MCD Application Team 5 | * @brief CMSIS Cortex-M7 Device System Source File for STM32F7xx devices. 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | * Copyright (c) 2016 STMicroelectronics. 10 | * All rights reserved. 11 | * 12 | * This software is licensed under terms that can be found in the LICENSE file 13 | * in the root directory of this software component. 14 | * If no LICENSE file comes with this software, it is provided AS-IS. 15 | * 16 | ****************************************************************************** 17 | */ 18 | 19 | /** @addtogroup CMSIS 20 | * @{ 21 | */ 22 | 23 | /** @addtogroup stm32f7xx_system 24 | * @{ 25 | */ 26 | 27 | /** 28 | * @brief Define to prevent recursive inclusion 29 | */ 30 | #ifndef __SYSTEM_STM32F7XX_H 31 | #define __SYSTEM_STM32F7XX_H 32 | 33 | #ifdef __cplusplus 34 | extern "C" { 35 | #endif 36 | 37 | /** @addtogroup STM32F7xx_System_Includes 38 | * @{ 39 | */ 40 | 41 | /** 42 | * @} 43 | */ 44 | 45 | 46 | /** @addtogroup STM32F7xx_System_Exported_Variables 47 | * @{ 48 | */ 49 | /* The SystemCoreClock variable is updated in three ways: 50 | 1) by calling CMSIS function SystemCoreClockUpdate() 51 | 2) by calling HAL API function HAL_RCC_GetSysClockFreq() 52 | 3) each time HAL_RCC_ClockConfig() is called to configure the system clock frequency 53 | Note: If you use this function to configure the system clock; then there 54 | is no need to call the 2 first functions listed above, since SystemCoreClock 55 | variable is updated automatically. 56 | */ 57 | extern uint32_t SystemCoreClock; /*!< System Clock Frequency (Core Clock) */ 58 | 59 | extern const uint8_t AHBPrescTable[16]; /*!< AHB prescalers table values */ 60 | extern const uint8_t APBPrescTable[8]; /*!< APB prescalers table values */ 61 | 62 | 63 | /** 64 | * @} 65 | */ 66 | 67 | /** @addtogroup STM32F7xx_System_Exported_Constants 68 | * @{ 69 | */ 70 | 71 | /** 72 | * @} 73 | */ 74 | 75 | /** @addtogroup STM32F7xx_System_Exported_Macros 76 | * @{ 77 | */ 78 | 79 | /** 80 | * @} 81 | */ 82 | 83 | /** @addtogroup STM32F7xx_System_Exported_Functions 84 | * @{ 85 | */ 86 | 87 | extern void SystemInit(void); 88 | extern void SystemCoreClockUpdate(void); 89 | /** 90 | * @} 91 | */ 92 | 93 | #ifdef __cplusplus 94 | } 95 | #endif 96 | 97 | #endif /*__SYSTEM_STM32F7XX_H */ 98 | 99 | /** 100 | * @} 101 | */ 102 | 103 | /** 104 | * @} 105 | */ 106 | -------------------------------------------------------------------------------- /02_drop_in_compiler/Drivers/CMSIS/Device/ST/STM32F7xx/LICENSE.txt: -------------------------------------------------------------------------------- 1 | This software component is provided to you as part of a software package and 2 | applicable license terms are in the Package_license file. If you received this 3 | software component outside of a package or without applicable license terms, 4 | the terms of the Apache-2.0 license shall apply. 5 | You may obtain a copy of the Apache-2.0 at: 6 | https://opensource.org/licenses/Apache-2.0 7 | -------------------------------------------------------------------------------- /02_drop_in_compiler/Drivers/CMSIS/Include/cmsis_version.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************//** 2 | * @file cmsis_version.h 3 | * @brief CMSIS Core(M) Version definitions 4 | * @version V5.0.2 5 | * @date 19. April 2017 6 | ******************************************************************************/ 7 | /* 8 | * Copyright (c) 2009-2017 ARM Limited. All rights reserved. 9 | * 10 | * SPDX-License-Identifier: Apache-2.0 11 | * 12 | * Licensed under the Apache License, Version 2.0 (the License); you may 13 | * not use this file except in compliance with the License. 14 | * You may obtain a copy of the License at 15 | * 16 | * www.apache.org/licenses/LICENSE-2.0 17 | * 18 | * Unless required by applicable law or agreed to in writing, software 19 | * distributed under the License is distributed on an AS IS BASIS, WITHOUT 20 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 21 | * See the License for the specific language governing permissions and 22 | * limitations under the License. 23 | */ 24 | 25 | #if defined ( __ICCARM__ ) 26 | #pragma system_include /* treat file as system include file for MISRA check */ 27 | #elif defined (__clang__) 28 | #pragma clang system_header /* treat file as system include file */ 29 | #endif 30 | 31 | #ifndef __CMSIS_VERSION_H 32 | #define __CMSIS_VERSION_H 33 | 34 | /* CMSIS Version definitions */ 35 | #define __CM_CMSIS_VERSION_MAIN ( 5U) /*!< [31:16] CMSIS Core(M) main version */ 36 | #define __CM_CMSIS_VERSION_SUB ( 1U) /*!< [15:0] CMSIS Core(M) sub version */ 37 | #define __CM_CMSIS_VERSION ((__CM_CMSIS_VERSION_MAIN << 16U) | \ 38 | __CM_CMSIS_VERSION_SUB ) /*!< CMSIS Core(M) version number */ 39 | #endif 40 | -------------------------------------------------------------------------------- /02_drop_in_compiler/Drivers/CMSIS/Include/tz_context.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * @file tz_context.h 3 | * @brief Context Management for Armv8-M TrustZone 4 | * @version V1.0.1 5 | * @date 10. January 2018 6 | ******************************************************************************/ 7 | /* 8 | * Copyright (c) 2017-2018 Arm Limited. All rights reserved. 9 | * 10 | * SPDX-License-Identifier: Apache-2.0 11 | * 12 | * Licensed under the Apache License, Version 2.0 (the License); you may 13 | * not use this file except in compliance with the License. 14 | * You may obtain a copy of the License at 15 | * 16 | * www.apache.org/licenses/LICENSE-2.0 17 | * 18 | * Unless required by applicable law or agreed to in writing, software 19 | * distributed under the License is distributed on an AS IS BASIS, WITHOUT 20 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 21 | * See the License for the specific language governing permissions and 22 | * limitations under the License. 23 | */ 24 | 25 | #if defined ( __ICCARM__ ) 26 | #pragma system_include /* treat file as system include file for MISRA check */ 27 | #elif defined (__clang__) 28 | #pragma clang system_header /* treat file as system include file */ 29 | #endif 30 | 31 | #ifndef TZ_CONTEXT_H 32 | #define TZ_CONTEXT_H 33 | 34 | #include 35 | 36 | #ifndef TZ_MODULEID_T 37 | #define TZ_MODULEID_T 38 | /// \details Data type that identifies secure software modules called by a process. 39 | typedef uint32_t TZ_ModuleId_t; 40 | #endif 41 | 42 | /// \details TZ Memory ID identifies an allocated memory slot. 43 | typedef uint32_t TZ_MemoryId_t; 44 | 45 | /// Initialize secure context memory system 46 | /// \return execution status (1: success, 0: error) 47 | uint32_t TZ_InitContextSystem_S (void); 48 | 49 | /// Allocate context memory for calling secure software modules in TrustZone 50 | /// \param[in] module identifies software modules called from non-secure mode 51 | /// \return value != 0 id TrustZone memory slot identifier 52 | /// \return value 0 no memory available or internal error 53 | TZ_MemoryId_t TZ_AllocModuleContext_S (TZ_ModuleId_t module); 54 | 55 | /// Free context memory that was previously allocated with \ref TZ_AllocModuleContext_S 56 | /// \param[in] id TrustZone memory slot identifier 57 | /// \return execution status (1: success, 0: error) 58 | uint32_t TZ_FreeModuleContext_S (TZ_MemoryId_t id); 59 | 60 | /// Load secure context (called on RTOS thread context switch) 61 | /// \param[in] id TrustZone memory slot identifier 62 | /// \return execution status (1: success, 0: error) 63 | uint32_t TZ_LoadContext_S (TZ_MemoryId_t id); 64 | 65 | /// Store secure context (called on RTOS thread context switch) 66 | /// \param[in] id TrustZone memory slot identifier 67 | /// \return execution status (1: success, 0: error) 68 | uint32_t TZ_StoreContext_S (TZ_MemoryId_t id); 69 | 70 | #endif // TZ_CONTEXT_H 71 | -------------------------------------------------------------------------------- /02_drop_in_compiler/Drivers/STM32F7xx_HAL_Driver/Inc/stm32f7xx_hal_dma_ex.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f7xx_hal_dma_ex.h 4 | * @author MCD Application Team 5 | * @brief Header file of DMA HAL extension module. 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | * Copyright (c) 2017 STMicroelectronics. 10 | * All rights reserved. 11 | * 12 | * This software is licensed under terms that can be found in the LICENSE file in 13 | * the root directory of this software component. 14 | * If no LICENSE file comes with this software, it is provided AS-IS. 15 | * 16 | ****************************************************************************** 17 | */ 18 | 19 | /* Define to prevent recursive inclusion -------------------------------------*/ 20 | #ifndef __STM32F7xx_HAL_DMA_EX_H 21 | #define __STM32F7xx_HAL_DMA_EX_H 22 | 23 | #ifdef __cplusplus 24 | extern "C" { 25 | #endif 26 | 27 | /* Includes ------------------------------------------------------------------*/ 28 | #include "stm32f7xx_hal_def.h" 29 | 30 | /** @addtogroup STM32F7xx_HAL_Driver 31 | * @{ 32 | */ 33 | 34 | /** @addtogroup DMAEx 35 | * @{ 36 | */ 37 | 38 | /* Exported types ------------------------------------------------------------*/ 39 | /** @defgroup DMAEx_Exported_Types DMAEx Exported Types 40 | * @brief DMAEx Exported types 41 | * @{ 42 | */ 43 | 44 | /** 45 | * @brief HAL DMA Memory definition 46 | */ 47 | typedef enum 48 | { 49 | MEMORY0 = 0x00U, /*!< Memory 0 */ 50 | MEMORY1 = 0x01U, /*!< Memory 1 */ 51 | 52 | }HAL_DMA_MemoryTypeDef; 53 | 54 | /** 55 | * @} 56 | */ 57 | 58 | /* Exported constants --------------------------------------------------------*/ 59 | 60 | /** @defgroup DMA_Exported_Constants DMA Exported Constants 61 | * @brief DMA Exported constants 62 | * @{ 63 | */ 64 | 65 | /** @defgroup DMAEx_Channel_selection DMA Channel selection 66 | * @brief DMAEx channel selection 67 | * @{ 68 | */ 69 | #define DMA_CHANNEL_0 0x00000000U /*!< DMA Channel 0 */ 70 | #define DMA_CHANNEL_1 0x02000000U /*!< DMA Channel 1 */ 71 | #define DMA_CHANNEL_2 0x04000000U /*!< DMA Channel 2 */ 72 | #define DMA_CHANNEL_3 0x06000000U /*!< DMA Channel 3 */ 73 | #define DMA_CHANNEL_4 0x08000000U /*!< DMA Channel 4 */ 74 | #define DMA_CHANNEL_5 0x0A000000U /*!< DMA Channel 5 */ 75 | #define DMA_CHANNEL_6 0x0C000000U /*!< DMA Channel 6 */ 76 | #define DMA_CHANNEL_7 0x0E000000U /*!< DMA Channel 7 */ 77 | #if defined (STM32F722xx) || defined (STM32F723xx) || defined (STM32F732xx) || defined (STM32F733xx) ||\ 78 | defined (STM32F765xx) || defined (STM32F767xx) || defined (STM32F769xx) || defined (STM32F777xx) ||\ 79 | defined (STM32F779xx) || defined (STM32F730xx) 80 | #define DMA_CHANNEL_8 0x10000000U /*!< DMA Channel 8 */ 81 | #define DMA_CHANNEL_9 0x12000000U /*!< DMA Channel 9 */ 82 | #define DMA_CHANNEL_10 0x14000000U /*!< DMA Channel 10*/ 83 | #define DMA_CHANNEL_11 0x16000000U /*!< DMA Channel 11*/ 84 | #define DMA_CHANNEL_12 0x18000000U /*!< DMA Channel 12*/ 85 | #define DMA_CHANNEL_13 0x1A000000U /*!< DMA Channel 13*/ 86 | #define DMA_CHANNEL_14 0x1C000000U /*!< DMA Channel 14*/ 87 | #define DMA_CHANNEL_15 0x1E000000U /*!< DMA Channel 15*/ 88 | #endif /* STM32F722xx || STM32F723xx || STM32F732xx || STM32F733xx || STM32F765xx || STM32F767xx || 89 | STM32F769xx || STM32F777xx || STM32F779xx || STM32F730xx */ 90 | 91 | /** 92 | * @} 93 | */ 94 | 95 | /** 96 | * @} 97 | */ 98 | 99 | /* Exported functions --------------------------------------------------------*/ 100 | /** @defgroup DMAEx_Exported_Functions DMAEx Exported Functions 101 | * @brief DMAEx Exported functions 102 | * @{ 103 | */ 104 | 105 | /** @defgroup DMAEx_Exported_Functions_Group1 Extended features functions 106 | * @brief Extended features functions 107 | * @{ 108 | */ 109 | 110 | /* IO operation functions *******************************************************/ 111 | HAL_StatusTypeDef HAL_DMAEx_MultiBufferStart(DMA_HandleTypeDef *hdma, uint32_t SrcAddress, uint32_t DstAddress, uint32_t SecondMemAddress, uint32_t DataLength); 112 | HAL_StatusTypeDef HAL_DMAEx_MultiBufferStart_IT(DMA_HandleTypeDef *hdma, uint32_t SrcAddress, uint32_t DstAddress, uint32_t SecondMemAddress, uint32_t DataLength); 113 | HAL_StatusTypeDef HAL_DMAEx_ChangeMemory(DMA_HandleTypeDef *hdma, uint32_t Address, HAL_DMA_MemoryTypeDef memory); 114 | 115 | /** 116 | * @} 117 | */ 118 | /** 119 | * @} 120 | */ 121 | 122 | /* Private macros ------------------------------------------------------------*/ 123 | /** @defgroup DMAEx_Private_Macros DMA Private Macros 124 | * @brief DMAEx private macros 125 | * @{ 126 | */ 127 | #if defined (STM32F722xx) || defined (STM32F723xx) || defined (STM32F732xx) || defined (STM32F733xx) ||\ 128 | defined (STM32F765xx) || defined (STM32F767xx) || defined (STM32F769xx) || defined (STM32F777xx) ||\ 129 | defined (STM32F779xx) || defined (STM32F730xx) 130 | #define IS_DMA_CHANNEL(CHANNEL) (((CHANNEL) == DMA_CHANNEL_0) || \ 131 | ((CHANNEL) == DMA_CHANNEL_1) || \ 132 | ((CHANNEL) == DMA_CHANNEL_2) || \ 133 | ((CHANNEL) == DMA_CHANNEL_3) || \ 134 | ((CHANNEL) == DMA_CHANNEL_4) || \ 135 | ((CHANNEL) == DMA_CHANNEL_5) || \ 136 | ((CHANNEL) == DMA_CHANNEL_6) || \ 137 | ((CHANNEL) == DMA_CHANNEL_7) || \ 138 | ((CHANNEL) == DMA_CHANNEL_8) || \ 139 | ((CHANNEL) == DMA_CHANNEL_9) || \ 140 | ((CHANNEL) == DMA_CHANNEL_10) || \ 141 | ((CHANNEL) == DMA_CHANNEL_11) || \ 142 | ((CHANNEL) == DMA_CHANNEL_12) || \ 143 | ((CHANNEL) == DMA_CHANNEL_13) || \ 144 | ((CHANNEL) == DMA_CHANNEL_14) || \ 145 | ((CHANNEL) == DMA_CHANNEL_15)) 146 | #else 147 | #define IS_DMA_CHANNEL(CHANNEL) (((CHANNEL) == DMA_CHANNEL_0) || \ 148 | ((CHANNEL) == DMA_CHANNEL_1) || \ 149 | ((CHANNEL) == DMA_CHANNEL_2) || \ 150 | ((CHANNEL) == DMA_CHANNEL_3) || \ 151 | ((CHANNEL) == DMA_CHANNEL_4) || \ 152 | ((CHANNEL) == DMA_CHANNEL_5) || \ 153 | ((CHANNEL) == DMA_CHANNEL_6) || \ 154 | ((CHANNEL) == DMA_CHANNEL_7)) 155 | #endif /* STM32F722xx || STM32F723xx || STM32F732xx || STM32F733xx || STM32F765xx || STM32F767xx || 156 | STM32F769xx || STM32F777xx || STM32F779xx || STM32F730xx*/ 157 | /** 158 | * @} 159 | */ 160 | 161 | /* Private functions ---------------------------------------------------------*/ 162 | /** @defgroup DMAEx_Private_Functions DMAEx Private Functions 163 | * @brief DMAEx Private functions 164 | * @{ 165 | */ 166 | /** 167 | * @} 168 | */ 169 | 170 | /** 171 | * @} 172 | */ 173 | 174 | /** 175 | * @} 176 | */ 177 | 178 | #ifdef __cplusplus 179 | } 180 | #endif 181 | 182 | #endif /* __STM32F7xx_HAL_DMA_H */ 183 | 184 | -------------------------------------------------------------------------------- /02_drop_in_compiler/Drivers/STM32F7xx_HAL_Driver/LICENSE.txt: -------------------------------------------------------------------------------- 1 | This software component is provided to you as part of a software package and 2 | applicable license terms are in the Package_license file. If you received this 3 | software component outside of a package or without applicable license terms, 4 | the terms of the BSD-3-Clause license shall apply. 5 | You may obtain a copy of the BSD-3-Clause at: 6 | https://opensource.org/licenses/BSD-3-Clause 7 | -------------------------------------------------------------------------------- /02_drop_in_compiler/STM32F750N8Hx_FLASH.ld: -------------------------------------------------------------------------------- 1 | /* 2 | ****************************************************************************** 3 | ** 4 | 5 | ** File : LinkerScript.ld 6 | ** 7 | ** Author : STM32CubeMX 8 | ** 9 | ** Abstract : Linker script for STM32F750N8Hx series 10 | ** 64Kbytes FLASH and 320Kbytes RAM 11 | ** 12 | ** Set heap size, stack size and stack location according 13 | ** to application requirements. 14 | ** 15 | ** Set memory bank area and size if external memory is used. 16 | ** 17 | ** Target : STMicroelectronics STM32 18 | ** 19 | ** Distribution: The file is distributed “as is,” without any warranty 20 | ** of any kind. 21 | ** 22 | ***************************************************************************** 23 | ** @attention 24 | ** 25 | **

© COPYRIGHT(c) 2019 STMicroelectronics

26 | ** 27 | ** Redistribution and use in source and binary forms, with or without modification, 28 | ** are permitted provided that the following conditions are met: 29 | ** 1. Redistributions of source code must retain the above copyright notice, 30 | ** this list of conditions and the following disclaimer. 31 | ** 2. Redistributions in binary form must reproduce the above copyright notice, 32 | ** this list of conditions and the following disclaimer in the documentation 33 | ** and/or other materials provided with the distribution. 34 | ** 3. Neither the name of STMicroelectronics nor the names of its contributors 35 | ** may be used to endorse or promote products derived from this software 36 | ** without specific prior written permission. 37 | ** 38 | ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 39 | ** AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 40 | ** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 41 | ** DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 42 | ** FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 43 | ** DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 44 | ** SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 45 | ** CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 46 | ** OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 47 | ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 48 | ** 49 | ***************************************************************************** 50 | */ 51 | 52 | /* Entry Point */ 53 | ENTRY(Reset_Handler) 54 | 55 | /* Specify the memory areas */ 56 | MEMORY 57 | { 58 | RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 320K 59 | FLASH (rx) : ORIGIN = 0x8000000, LENGTH = 64K 60 | } 61 | 62 | /* Highest address of the user mode stack */ 63 | _estack = ORIGIN(RAM) + LENGTH(RAM); /* end of RAM */ 64 | /* Generate a link error if heap and stack don't fit into RAM */ 65 | _Min_Heap_Size = 0x200; /* required amount of heap */ 66 | _Min_Stack_Size = 0x400; /* required amount of stack */ 67 | 68 | /* Define output sections */ 69 | SECTIONS 70 | { 71 | /* The startup code goes first into FLASH */ 72 | .isr_vector : 73 | { 74 | . = ALIGN(4); 75 | KEEP(*(.isr_vector)) /* Startup code */ 76 | . = ALIGN(4); 77 | } >FLASH 78 | 79 | /* The program code and other data goes into FLASH */ 80 | .text : 81 | { 82 | . = ALIGN(4); 83 | *(.text) /* .text sections (code) */ 84 | *(.text*) /* .text* sections (code) */ 85 | *(.glue_7) /* glue arm to thumb code */ 86 | *(.glue_7t) /* glue thumb to arm code */ 87 | *(.eh_frame) 88 | 89 | KEEP (*(.init)) 90 | KEEP (*(.fini)) 91 | 92 | . = ALIGN(4); 93 | _etext = .; /* define a global symbols at end of code */ 94 | } >FLASH 95 | 96 | /* Constant data goes into FLASH */ 97 | .rodata : 98 | { 99 | . = ALIGN(4); 100 | *(.rodata) /* .rodata sections (constants, strings, etc.) */ 101 | *(.rodata*) /* .rodata* sections (constants, strings, etc.) */ 102 | . = ALIGN(4); 103 | } >FLASH 104 | 105 | .ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) } >FLASH 106 | .ARM : { 107 | __exidx_start = .; 108 | *(.ARM.exidx*) 109 | __exidx_end = .; 110 | } >FLASH 111 | 112 | .preinit_array : 113 | { 114 | PROVIDE_HIDDEN (__preinit_array_start = .); 115 | KEEP (*(.preinit_array*)) 116 | PROVIDE_HIDDEN (__preinit_array_end = .); 117 | } >FLASH 118 | .init_array : 119 | { 120 | PROVIDE_HIDDEN (__init_array_start = .); 121 | KEEP (*(SORT(.init_array.*))) 122 | KEEP (*(.init_array*)) 123 | PROVIDE_HIDDEN (__init_array_end = .); 124 | } >FLASH 125 | .fini_array : 126 | { 127 | PROVIDE_HIDDEN (__fini_array_start = .); 128 | KEEP (*(SORT(.fini_array.*))) 129 | KEEP (*(.fini_array*)) 130 | PROVIDE_HIDDEN (__fini_array_end = .); 131 | } >FLASH 132 | 133 | /* used by the startup to initialize data */ 134 | _sidata = LOADADDR(.data); 135 | 136 | /* Initialized data sections goes into RAM, load LMA copy after code */ 137 | .data : 138 | { 139 | . = ALIGN(4); 140 | _sdata = .; /* create a global symbol at data start */ 141 | *(.data) /* .data sections */ 142 | *(.data*) /* .data* sections */ 143 | 144 | . = ALIGN(4); 145 | _edata = .; /* define a global symbol at data end */ 146 | } >RAM AT> FLASH 147 | 148 | 149 | /* Uninitialized data section */ 150 | . = ALIGN(4); 151 | .bss : 152 | { 153 | /* This is used by the startup in order to initialize the .bss secion */ 154 | _sbss = .; /* define a global symbol at bss start */ 155 | __bss_start__ = _sbss; 156 | *(.bss) 157 | *(.bss*) 158 | *(COMMON) 159 | 160 | . = ALIGN(4); 161 | _ebss = .; /* define a global symbol at bss end */ 162 | __bss_end__ = _ebss; 163 | } >RAM 164 | 165 | /* User_heap_stack section, used to check that there is enough RAM left */ 166 | ._user_heap_stack (NOLOAD) : 167 | { 168 | . = ALIGN(8); 169 | PROVIDE ( end = . ); 170 | PROVIDE ( _end = . ); 171 | . = . + _Min_Heap_Size; 172 | . = . + _Min_Stack_Size; 173 | . = ALIGN(8); 174 | } >RAM 175 | 176 | 177 | 178 | /* Remove information from the standard libraries */ 179 | /DISCARD/ : 180 | { 181 | libc.a ( * ) 182 | libm.a ( * ) 183 | libgcc.a ( * ) 184 | } 185 | 186 | .ARM.attributes 0 : { *(.ARM.attributes) } 187 | } 188 | 189 | 190 | -------------------------------------------------------------------------------- /03_with_zig_build/Core/Inc/gpio.h: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file gpio.h 5 | * @brief This file contains all the function prototypes for 6 | * the gpio.c file 7 | ****************************************************************************** 8 | * @attention 9 | * 10 | * Copyright (c) 2024 STMicroelectronics. 11 | * All rights reserved. 12 | * 13 | * This software is licensed under terms that can be found in the LICENSE file 14 | * in the root directory of this software component. 15 | * If no LICENSE file comes with this software, it is provided AS-IS. 16 | * 17 | ****************************************************************************** 18 | */ 19 | /* USER CODE END Header */ 20 | /* Define to prevent recursive inclusion -------------------------------------*/ 21 | #ifndef __GPIO_H__ 22 | #define __GPIO_H__ 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | /* Includes ------------------------------------------------------------------*/ 29 | #include "main.h" 30 | 31 | /* USER CODE BEGIN Includes */ 32 | 33 | /* USER CODE END Includes */ 34 | 35 | /* USER CODE BEGIN Private defines */ 36 | 37 | /* USER CODE END Private defines */ 38 | 39 | void MX_GPIO_Init(void); 40 | 41 | /* USER CODE BEGIN Prototypes */ 42 | 43 | /* USER CODE END Prototypes */ 44 | 45 | #ifdef __cplusplus 46 | } 47 | #endif 48 | #endif /*__ GPIO_H__ */ 49 | 50 | -------------------------------------------------------------------------------- /03_with_zig_build/Core/Inc/main.h: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file : main.h 5 | * @brief : Header for main.c file. 6 | * This file contains the common defines of the application. 7 | ****************************************************************************** 8 | * @attention 9 | * 10 | * Copyright (c) 2024 STMicroelectronics. 11 | * All rights reserved. 12 | * 13 | * This software is licensed under terms that can be found in the LICENSE file 14 | * in the root directory of this software component. 15 | * If no LICENSE file comes with this software, it is provided AS-IS. 16 | * 17 | ****************************************************************************** 18 | */ 19 | /* USER CODE END Header */ 20 | 21 | /* Define to prevent recursive inclusion -------------------------------------*/ 22 | #ifndef __MAIN_H 23 | #define __MAIN_H 24 | 25 | #ifdef __cplusplus 26 | extern "C" { 27 | #endif 28 | 29 | /* Includes ------------------------------------------------------------------*/ 30 | #include "stm32f7xx_hal.h" 31 | 32 | /* Private includes ----------------------------------------------------------*/ 33 | /* USER CODE BEGIN Includes */ 34 | 35 | /* USER CODE END Includes */ 36 | 37 | /* Exported types ------------------------------------------------------------*/ 38 | /* USER CODE BEGIN ET */ 39 | 40 | /* USER CODE END ET */ 41 | 42 | /* Exported constants --------------------------------------------------------*/ 43 | /* USER CODE BEGIN EC */ 44 | 45 | /* USER CODE END EC */ 46 | 47 | /* Exported macro ------------------------------------------------------------*/ 48 | /* USER CODE BEGIN EM */ 49 | 50 | /* USER CODE END EM */ 51 | 52 | /* Exported functions prototypes ---------------------------------------------*/ 53 | void Error_Handler(void); 54 | 55 | /* USER CODE BEGIN EFP */ 56 | void hal_initialization_code(void); 57 | 58 | /* USER CODE END EFP */ 59 | 60 | /* Private defines -----------------------------------------------------------*/ 61 | #define LED_BLINK_Pin GPIO_PIN_15 62 | #define LED_BLINK_GPIO_Port GPIOA 63 | 64 | /* USER CODE BEGIN Private defines */ 65 | 66 | /* USER CODE END Private defines */ 67 | 68 | #ifdef __cplusplus 69 | } 70 | #endif 71 | 72 | #endif /* __MAIN_H */ 73 | -------------------------------------------------------------------------------- /03_with_zig_build/Core/Inc/stm32f7xx_it.h: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file stm32f7xx_it.h 5 | * @brief This file contains the headers of the interrupt handlers. 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | * Copyright (c) 2024 STMicroelectronics. 10 | * All rights reserved. 11 | * 12 | * This software is licensed under terms that can be found in the LICENSE file 13 | * in the root directory of this software component. 14 | * If no LICENSE file comes with this software, it is provided AS-IS. 15 | * 16 | ****************************************************************************** 17 | */ 18 | /* USER CODE END Header */ 19 | 20 | /* Define to prevent recursive inclusion -------------------------------------*/ 21 | #ifndef __STM32F7xx_IT_H 22 | #define __STM32F7xx_IT_H 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | /* Private includes ----------------------------------------------------------*/ 29 | /* USER CODE BEGIN Includes */ 30 | 31 | /* USER CODE END Includes */ 32 | 33 | /* Exported types ------------------------------------------------------------*/ 34 | /* USER CODE BEGIN ET */ 35 | 36 | /* USER CODE END ET */ 37 | 38 | /* Exported constants --------------------------------------------------------*/ 39 | /* USER CODE BEGIN EC */ 40 | 41 | /* USER CODE END EC */ 42 | 43 | /* Exported macro ------------------------------------------------------------*/ 44 | /* USER CODE BEGIN EM */ 45 | 46 | /* USER CODE END EM */ 47 | 48 | /* Exported functions prototypes ---------------------------------------------*/ 49 | void SysTick_Handler(void); 50 | /* USER CODE BEGIN EFP */ 51 | 52 | /* USER CODE END EFP */ 53 | 54 | #ifdef __cplusplus 55 | } 56 | #endif 57 | 58 | #endif /* __STM32F7xx_IT_H */ 59 | -------------------------------------------------------------------------------- /03_with_zig_build/Core/Src/gpio.c: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file gpio.c 5 | * @brief This file provides code for the configuration 6 | * of all used GPIO pins. 7 | ****************************************************************************** 8 | * @attention 9 | * 10 | * Copyright (c) 2024 STMicroelectronics. 11 | * All rights reserved. 12 | * 13 | * This software is licensed under terms that can be found in the LICENSE file 14 | * in the root directory of this software component. 15 | * If no LICENSE file comes with this software, it is provided AS-IS. 16 | * 17 | ****************************************************************************** 18 | */ 19 | /* USER CODE END Header */ 20 | 21 | /* Includes ------------------------------------------------------------------*/ 22 | #include "gpio.h" 23 | 24 | /* USER CODE BEGIN 0 */ 25 | 26 | /* USER CODE END 0 */ 27 | 28 | /*----------------------------------------------------------------------------*/ 29 | /* Configure GPIO */ 30 | /*----------------------------------------------------------------------------*/ 31 | /* USER CODE BEGIN 1 */ 32 | 33 | /* USER CODE END 1 */ 34 | 35 | /** Configure pins 36 | PE2 ------> QUADSPI_BK1_IO2 37 | PB6 ------> QUADSPI_BK1_NCS 38 | PB2 ------> QUADSPI_CLK 39 | PD12 ------> QUADSPI_BK1_IO1 40 | PD13 ------> QUADSPI_BK1_IO3 41 | PD11 ------> QUADSPI_BK1_IO0 42 | */ 43 | void MX_GPIO_Init(void) 44 | { 45 | 46 | GPIO_InitTypeDef GPIO_InitStruct = {0}; 47 | 48 | /* GPIO Ports Clock Enable */ 49 | __HAL_RCC_GPIOE_CLK_ENABLE(); 50 | __HAL_RCC_GPIOA_CLK_ENABLE(); 51 | __HAL_RCC_GPIOB_CLK_ENABLE(); 52 | __HAL_RCC_GPIOH_CLK_ENABLE(); 53 | __HAL_RCC_GPIOD_CLK_ENABLE(); 54 | 55 | /*Configure GPIO pin Output Level */ 56 | HAL_GPIO_WritePin(LED_BLINK_GPIO_Port, LED_BLINK_Pin, GPIO_PIN_RESET); 57 | 58 | /*Configure GPIO pin : PE2 */ 59 | GPIO_InitStruct.Pin = GPIO_PIN_2; 60 | GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; 61 | GPIO_InitStruct.Pull = GPIO_NOPULL; 62 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; 63 | GPIO_InitStruct.Alternate = GPIO_AF9_QUADSPI; 64 | HAL_GPIO_Init(GPIOE, &GPIO_InitStruct); 65 | 66 | /*Configure GPIO pin : PtPin */ 67 | GPIO_InitStruct.Pin = LED_BLINK_Pin; 68 | GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; 69 | GPIO_InitStruct.Pull = GPIO_NOPULL; 70 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; 71 | HAL_GPIO_Init(LED_BLINK_GPIO_Port, &GPIO_InitStruct); 72 | 73 | /*Configure GPIO pin : PB6 */ 74 | GPIO_InitStruct.Pin = GPIO_PIN_6; 75 | GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; 76 | GPIO_InitStruct.Pull = GPIO_NOPULL; 77 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; 78 | GPIO_InitStruct.Alternate = GPIO_AF10_QUADSPI; 79 | HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); 80 | 81 | /*Configure GPIO pin : PB2 */ 82 | GPIO_InitStruct.Pin = GPIO_PIN_2; 83 | GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; 84 | GPIO_InitStruct.Pull = GPIO_NOPULL; 85 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; 86 | GPIO_InitStruct.Alternate = GPIO_AF9_QUADSPI; 87 | HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); 88 | 89 | /*Configure GPIO pins : PD12 PD13 PD11 */ 90 | GPIO_InitStruct.Pin = GPIO_PIN_12|GPIO_PIN_13|GPIO_PIN_11; 91 | GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; 92 | GPIO_InitStruct.Pull = GPIO_NOPULL; 93 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; 94 | GPIO_InitStruct.Alternate = GPIO_AF9_QUADSPI; 95 | HAL_GPIO_Init(GPIOD, &GPIO_InitStruct); 96 | 97 | } 98 | 99 | /* USER CODE BEGIN 2 */ 100 | 101 | /* USER CODE END 2 */ 102 | -------------------------------------------------------------------------------- /03_with_zig_build/Core/Src/stm32f7xx_hal_msp.c: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file stm32f7xx_hal_msp.c 5 | * @brief This file provides code for the MSP Initialization 6 | * and de-Initialization codes. 7 | ****************************************************************************** 8 | * @attention 9 | * 10 | * Copyright (c) 2024 STMicroelectronics. 11 | * All rights reserved. 12 | * 13 | * This software is licensed under terms that can be found in the LICENSE file 14 | * in the root directory of this software component. 15 | * If no LICENSE file comes with this software, it is provided AS-IS. 16 | * 17 | ****************************************************************************** 18 | */ 19 | /* USER CODE END Header */ 20 | 21 | /* Includes ------------------------------------------------------------------*/ 22 | #include "main.h" 23 | /* USER CODE BEGIN Includes */ 24 | 25 | /* USER CODE END Includes */ 26 | 27 | /* Private typedef -----------------------------------------------------------*/ 28 | /* USER CODE BEGIN TD */ 29 | 30 | /* USER CODE END TD */ 31 | 32 | /* Private define ------------------------------------------------------------*/ 33 | /* USER CODE BEGIN Define */ 34 | 35 | /* USER CODE END Define */ 36 | 37 | /* Private macro -------------------------------------------------------------*/ 38 | /* USER CODE BEGIN Macro */ 39 | 40 | /* USER CODE END Macro */ 41 | 42 | /* Private variables ---------------------------------------------------------*/ 43 | /* USER CODE BEGIN PV */ 44 | 45 | /* USER CODE END PV */ 46 | 47 | /* Private function prototypes -----------------------------------------------*/ 48 | /* USER CODE BEGIN PFP */ 49 | 50 | /* USER CODE END PFP */ 51 | 52 | /* External functions --------------------------------------------------------*/ 53 | /* USER CODE BEGIN ExternalFunctions */ 54 | 55 | /* USER CODE END ExternalFunctions */ 56 | 57 | /* USER CODE BEGIN 0 */ 58 | 59 | /* USER CODE END 0 */ 60 | /** 61 | * Initializes the Global MSP. 62 | */ 63 | void HAL_MspInit(void) 64 | { 65 | 66 | /* USER CODE BEGIN MspInit 0 */ 67 | 68 | /* USER CODE END MspInit 0 */ 69 | 70 | __HAL_RCC_PWR_CLK_ENABLE(); 71 | __HAL_RCC_SYSCFG_CLK_ENABLE(); 72 | 73 | /* System interrupt init*/ 74 | 75 | /* USER CODE BEGIN MspInit 1 */ 76 | 77 | /* USER CODE END MspInit 1 */ 78 | } 79 | 80 | /* USER CODE BEGIN 1 */ 81 | 82 | /* USER CODE END 1 */ 83 | -------------------------------------------------------------------------------- /03_with_zig_build/Core/Src/stm32f7xx_it.c: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file stm32f7xx_it.c 5 | * @brief Interrupt Service Routines. 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | * Copyright (c) 2024 STMicroelectronics. 10 | * All rights reserved. 11 | * 12 | * This software is licensed under terms that can be found in the LICENSE file 13 | * in the root directory of this software component. 14 | * If no LICENSE file comes with this software, it is provided AS-IS. 15 | * 16 | ****************************************************************************** 17 | */ 18 | /* USER CODE END Header */ 19 | 20 | /* Includes ------------------------------------------------------------------*/ 21 | #include "main.h" 22 | #include "stm32f7xx_it.h" 23 | /* Private includes ----------------------------------------------------------*/ 24 | /* USER CODE BEGIN Includes */ 25 | /* USER CODE END Includes */ 26 | 27 | /* Private typedef -----------------------------------------------------------*/ 28 | /* USER CODE BEGIN TD */ 29 | 30 | /* USER CODE END TD */ 31 | 32 | /* Private define ------------------------------------------------------------*/ 33 | /* USER CODE BEGIN PD */ 34 | 35 | /* USER CODE END PD */ 36 | 37 | /* Private macro -------------------------------------------------------------*/ 38 | /* USER CODE BEGIN PM */ 39 | 40 | /* USER CODE END PM */ 41 | 42 | /* Private variables ---------------------------------------------------------*/ 43 | /* USER CODE BEGIN PV */ 44 | 45 | /* USER CODE END PV */ 46 | 47 | /* Private function prototypes -----------------------------------------------*/ 48 | /* USER CODE BEGIN PFP */ 49 | 50 | /* USER CODE END PFP */ 51 | 52 | /* Private user code ---------------------------------------------------------*/ 53 | /* USER CODE BEGIN 0 */ 54 | 55 | /* USER CODE END 0 */ 56 | 57 | /* External variables --------------------------------------------------------*/ 58 | 59 | /* USER CODE BEGIN EV */ 60 | 61 | /* USER CODE END EV */ 62 | 63 | /******************************************************************************/ 64 | /* Cortex-M7 Processor Interruption and Exception Handlers */ 65 | /******************************************************************************/ 66 | /** 67 | * @brief This function handles System tick timer. 68 | */ 69 | void SysTick_Handler(void) 70 | { 71 | /* USER CODE BEGIN SysTick_IRQn 0 */ 72 | 73 | /* USER CODE END SysTick_IRQn 0 */ 74 | HAL_IncTick(); 75 | /* USER CODE BEGIN SysTick_IRQn 1 */ 76 | 77 | /* USER CODE END SysTick_IRQn 1 */ 78 | } 79 | 80 | /******************************************************************************/ 81 | /* STM32F7xx Peripheral Interrupt Handlers */ 82 | /* Add here the Interrupt Handlers for the used peripherals. */ 83 | /* For the available peripheral interrupt handler names, */ 84 | /* please refer to the startup file (startup_stm32f7xx.s). */ 85 | /******************************************************************************/ 86 | 87 | /* USER CODE BEGIN 1 */ 88 | 89 | /* USER CODE END 1 */ 90 | -------------------------------------------------------------------------------- /03_with_zig_build/Core/Src/syscalls.c: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file syscalls.c 4 | * @author Auto-generated by STM32CubeMX 5 | * @brief Minimal System calls file 6 | * 7 | * For more information about which c-functions 8 | * need which of these lowlevel functions 9 | * please consult the Newlib libc-manual 10 | ****************************************************************************** 11 | * @attention 12 | * 13 | * Copyright (c) 2020-2024 STMicroelectronics. 14 | * All rights reserved. 15 | * 16 | * This software is licensed under terms that can be found in the LICENSE file 17 | * in the root directory of this software component. 18 | * If no LICENSE file comes with this software, it is provided AS-IS. 19 | * 20 | ****************************************************************************** 21 | */ 22 | 23 | /* Includes */ 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | 33 | /* Variables */ 34 | extern int __io_putchar(int ch) __attribute__((weak)); 35 | extern int __io_getchar(void) __attribute__((weak)); 36 | 37 | char *__env[1] = {0}; 38 | char **environ = __env; 39 | 40 | /* Functions */ 41 | void initialise_monitor_handles() 42 | { 43 | } 44 | 45 | int _getpid(void) 46 | { 47 | return 1; 48 | } 49 | 50 | int _kill(int pid, int sig) 51 | { 52 | (void)pid; 53 | (void)sig; 54 | errno = EINVAL; 55 | return -1; 56 | } 57 | 58 | void _exit(int status) 59 | { 60 | _kill(status, -1); 61 | while (1) 62 | { 63 | } /* Make sure we hang here */ 64 | } 65 | 66 | __attribute__((weak)) int _read(int file, char *ptr, int len) 67 | { 68 | (void)file; 69 | int DataIdx; 70 | 71 | for (DataIdx = 0; DataIdx < len; DataIdx++) 72 | { 73 | *ptr++ = __io_getchar(); 74 | } 75 | 76 | return len; 77 | } 78 | 79 | __attribute__((weak)) int _write(int file, char *ptr, int len) 80 | { 81 | (void)file; 82 | int DataIdx; 83 | 84 | for (DataIdx = 0; DataIdx < len; DataIdx++) 85 | { 86 | __io_putchar(*ptr++); 87 | } 88 | return len; 89 | } 90 | 91 | int _close(int file) 92 | { 93 | (void)file; 94 | return -1; 95 | } 96 | 97 | int _fstat(int file, struct stat *st) 98 | { 99 | (void)file; 100 | st->st_mode = S_IFCHR; 101 | return 0; 102 | } 103 | 104 | int _isatty(int file) 105 | { 106 | (void)file; 107 | return 1; 108 | } 109 | 110 | int _lseek(int file, int ptr, int dir) 111 | { 112 | (void)file; 113 | (void)ptr; 114 | (void)dir; 115 | return 0; 116 | } 117 | 118 | int _open(char *path, int flags, ...) 119 | { 120 | (void)path; 121 | (void)flags; 122 | /* Pretend like we always fail */ 123 | return -1; 124 | } 125 | 126 | int _wait(int *status) 127 | { 128 | (void)status; 129 | errno = ECHILD; 130 | return -1; 131 | } 132 | 133 | int _unlink(char *name) 134 | { 135 | (void)name; 136 | errno = ENOENT; 137 | return -1; 138 | } 139 | 140 | int _times(struct tms *buf) 141 | { 142 | (void)buf; 143 | return -1; 144 | } 145 | 146 | int _stat(char *file, struct stat *st) 147 | { 148 | (void)file; 149 | st->st_mode = S_IFCHR; 150 | return 0; 151 | } 152 | 153 | int _link(char *old, char *new) 154 | { 155 | (void)old; 156 | (void)new; 157 | errno = EMLINK; 158 | return -1; 159 | } 160 | 161 | int _fork(void) 162 | { 163 | errno = EAGAIN; 164 | return -1; 165 | } 166 | 167 | int _execve(char *name, char **argv, char **env) 168 | { 169 | (void)name; 170 | (void)argv; 171 | (void)env; 172 | errno = ENOMEM; 173 | return -1; 174 | } 175 | -------------------------------------------------------------------------------- /03_with_zig_build/Core/Src/sysmem.c: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file sysmem.c 4 | * @author Generated by STM32CubeMX 5 | * @brief System Memory calls file 6 | * 7 | * For more information about which C functions 8 | * need which of these lowlevel functions 9 | * please consult the newlib libc manual 10 | ****************************************************************************** 11 | * @attention 12 | * 13 | * Copyright (c) 2024 STMicroelectronics. 14 | * All rights reserved. 15 | * 16 | * This software is licensed under terms that can be found in the LICENSE file 17 | * in the root directory of this software component. 18 | * If no LICENSE file comes with this software, it is provided AS-IS. 19 | * 20 | ****************************************************************************** 21 | */ 22 | 23 | /* Includes */ 24 | #include 25 | #include 26 | 27 | /** 28 | * Pointer to the current high watermark of the heap usage 29 | */ 30 | static uint8_t *__sbrk_heap_end = NULL; 31 | 32 | /** 33 | * @brief _sbrk() allocates memory to the newlib heap and is used by malloc 34 | * and others from the C library 35 | * 36 | * @verbatim 37 | * ############################################################################ 38 | * # .data # .bss # newlib heap # MSP stack # 39 | * # # # # Reserved by _Min_Stack_Size # 40 | * ############################################################################ 41 | * ^-- RAM start ^-- _end _estack, RAM end --^ 42 | * @endverbatim 43 | * 44 | * This implementation starts allocating at the '_end' linker symbol 45 | * The '_Min_Stack_Size' linker symbol reserves a memory for the MSP stack 46 | * The implementation considers '_estack' linker symbol to be RAM end 47 | * NOTE: If the MSP stack, at any point during execution, grows larger than the 48 | * reserved size, please increase the '_Min_Stack_Size'. 49 | * 50 | * @param incr Memory size 51 | * @return Pointer to allocated memory 52 | */ 53 | void *_sbrk(ptrdiff_t incr) 54 | { 55 | extern uint8_t _end; /* Symbol defined in the linker script */ 56 | extern uint8_t _estack; /* Symbol defined in the linker script */ 57 | extern uint32_t _Min_Stack_Size; /* Symbol defined in the linker script */ 58 | const uint32_t stack_limit = (uint32_t)&_estack - (uint32_t)&_Min_Stack_Size; 59 | const uint8_t *max_heap = (uint8_t *)stack_limit; 60 | uint8_t *prev_heap_end; 61 | 62 | /* Initialize heap end at first call */ 63 | if (NULL == __sbrk_heap_end) 64 | { 65 | __sbrk_heap_end = &_end; 66 | } 67 | 68 | /* Protect heap from growing into the reserved MSP stack */ 69 | if (__sbrk_heap_end + incr > max_heap) 70 | { 71 | errno = ENOMEM; 72 | return (void *)-1; 73 | } 74 | 75 | prev_heap_end = __sbrk_heap_end; 76 | __sbrk_heap_end += incr; 77 | 78 | return (void *)prev_heap_end; 79 | } 80 | -------------------------------------------------------------------------------- /03_with_zig_build/Drivers/CMSIS/Device/ST/STM32F7xx/Include/system_stm32f7xx.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file system_stm32f7xx.h 4 | * @author MCD Application Team 5 | * @brief CMSIS Cortex-M7 Device System Source File for STM32F7xx devices. 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | * Copyright (c) 2016 STMicroelectronics. 10 | * All rights reserved. 11 | * 12 | * This software is licensed under terms that can be found in the LICENSE file 13 | * in the root directory of this software component. 14 | * If no LICENSE file comes with this software, it is provided AS-IS. 15 | * 16 | ****************************************************************************** 17 | */ 18 | 19 | /** @addtogroup CMSIS 20 | * @{ 21 | */ 22 | 23 | /** @addtogroup stm32f7xx_system 24 | * @{ 25 | */ 26 | 27 | /** 28 | * @brief Define to prevent recursive inclusion 29 | */ 30 | #ifndef __SYSTEM_STM32F7XX_H 31 | #define __SYSTEM_STM32F7XX_H 32 | 33 | #ifdef __cplusplus 34 | extern "C" { 35 | #endif 36 | 37 | /** @addtogroup STM32F7xx_System_Includes 38 | * @{ 39 | */ 40 | 41 | /** 42 | * @} 43 | */ 44 | 45 | 46 | /** @addtogroup STM32F7xx_System_Exported_Variables 47 | * @{ 48 | */ 49 | /* The SystemCoreClock variable is updated in three ways: 50 | 1) by calling CMSIS function SystemCoreClockUpdate() 51 | 2) by calling HAL API function HAL_RCC_GetSysClockFreq() 52 | 3) each time HAL_RCC_ClockConfig() is called to configure the system clock frequency 53 | Note: If you use this function to configure the system clock; then there 54 | is no need to call the 2 first functions listed above, since SystemCoreClock 55 | variable is updated automatically. 56 | */ 57 | extern uint32_t SystemCoreClock; /*!< System Clock Frequency (Core Clock) */ 58 | 59 | extern const uint8_t AHBPrescTable[16]; /*!< AHB prescalers table values */ 60 | extern const uint8_t APBPrescTable[8]; /*!< APB prescalers table values */ 61 | 62 | 63 | /** 64 | * @} 65 | */ 66 | 67 | /** @addtogroup STM32F7xx_System_Exported_Constants 68 | * @{ 69 | */ 70 | 71 | /** 72 | * @} 73 | */ 74 | 75 | /** @addtogroup STM32F7xx_System_Exported_Macros 76 | * @{ 77 | */ 78 | 79 | /** 80 | * @} 81 | */ 82 | 83 | /** @addtogroup STM32F7xx_System_Exported_Functions 84 | * @{ 85 | */ 86 | 87 | extern void SystemInit(void); 88 | extern void SystemCoreClockUpdate(void); 89 | /** 90 | * @} 91 | */ 92 | 93 | #ifdef __cplusplus 94 | } 95 | #endif 96 | 97 | #endif /*__SYSTEM_STM32F7XX_H */ 98 | 99 | /** 100 | * @} 101 | */ 102 | 103 | /** 104 | * @} 105 | */ 106 | -------------------------------------------------------------------------------- /03_with_zig_build/Drivers/CMSIS/Device/ST/STM32F7xx/LICENSE.txt: -------------------------------------------------------------------------------- 1 | This software component is provided to you as part of a software package and 2 | applicable license terms are in the Package_license file. If you received this 3 | software component outside of a package or without applicable license terms, 4 | the terms of the Apache-2.0 license shall apply. 5 | You may obtain a copy of the Apache-2.0 at: 6 | https://opensource.org/licenses/Apache-2.0 7 | -------------------------------------------------------------------------------- /03_with_zig_build/Drivers/CMSIS/Include/cmsis_version.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************//** 2 | * @file cmsis_version.h 3 | * @brief CMSIS Core(M) Version definitions 4 | * @version V5.0.2 5 | * @date 19. April 2017 6 | ******************************************************************************/ 7 | /* 8 | * Copyright (c) 2009-2017 ARM Limited. All rights reserved. 9 | * 10 | * SPDX-License-Identifier: Apache-2.0 11 | * 12 | * Licensed under the Apache License, Version 2.0 (the License); you may 13 | * not use this file except in compliance with the License. 14 | * You may obtain a copy of the License at 15 | * 16 | * www.apache.org/licenses/LICENSE-2.0 17 | * 18 | * Unless required by applicable law or agreed to in writing, software 19 | * distributed under the License is distributed on an AS IS BASIS, WITHOUT 20 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 21 | * See the License for the specific language governing permissions and 22 | * limitations under the License. 23 | */ 24 | 25 | #if defined ( __ICCARM__ ) 26 | #pragma system_include /* treat file as system include file for MISRA check */ 27 | #elif defined (__clang__) 28 | #pragma clang system_header /* treat file as system include file */ 29 | #endif 30 | 31 | #ifndef __CMSIS_VERSION_H 32 | #define __CMSIS_VERSION_H 33 | 34 | /* CMSIS Version definitions */ 35 | #define __CM_CMSIS_VERSION_MAIN ( 5U) /*!< [31:16] CMSIS Core(M) main version */ 36 | #define __CM_CMSIS_VERSION_SUB ( 1U) /*!< [15:0] CMSIS Core(M) sub version */ 37 | #define __CM_CMSIS_VERSION ((__CM_CMSIS_VERSION_MAIN << 16U) | \ 38 | __CM_CMSIS_VERSION_SUB ) /*!< CMSIS Core(M) version number */ 39 | #endif 40 | -------------------------------------------------------------------------------- /03_with_zig_build/Drivers/CMSIS/Include/tz_context.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * @file tz_context.h 3 | * @brief Context Management for Armv8-M TrustZone 4 | * @version V1.0.1 5 | * @date 10. January 2018 6 | ******************************************************************************/ 7 | /* 8 | * Copyright (c) 2017-2018 Arm Limited. All rights reserved. 9 | * 10 | * SPDX-License-Identifier: Apache-2.0 11 | * 12 | * Licensed under the Apache License, Version 2.0 (the License); you may 13 | * not use this file except in compliance with the License. 14 | * You may obtain a copy of the License at 15 | * 16 | * www.apache.org/licenses/LICENSE-2.0 17 | * 18 | * Unless required by applicable law or agreed to in writing, software 19 | * distributed under the License is distributed on an AS IS BASIS, WITHOUT 20 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 21 | * See the License for the specific language governing permissions and 22 | * limitations under the License. 23 | */ 24 | 25 | #if defined ( __ICCARM__ ) 26 | #pragma system_include /* treat file as system include file for MISRA check */ 27 | #elif defined (__clang__) 28 | #pragma clang system_header /* treat file as system include file */ 29 | #endif 30 | 31 | #ifndef TZ_CONTEXT_H 32 | #define TZ_CONTEXT_H 33 | 34 | #include 35 | 36 | #ifndef TZ_MODULEID_T 37 | #define TZ_MODULEID_T 38 | /// \details Data type that identifies secure software modules called by a process. 39 | typedef uint32_t TZ_ModuleId_t; 40 | #endif 41 | 42 | /// \details TZ Memory ID identifies an allocated memory slot. 43 | typedef uint32_t TZ_MemoryId_t; 44 | 45 | /// Initialize secure context memory system 46 | /// \return execution status (1: success, 0: error) 47 | uint32_t TZ_InitContextSystem_S (void); 48 | 49 | /// Allocate context memory for calling secure software modules in TrustZone 50 | /// \param[in] module identifies software modules called from non-secure mode 51 | /// \return value != 0 id TrustZone memory slot identifier 52 | /// \return value 0 no memory available or internal error 53 | TZ_MemoryId_t TZ_AllocModuleContext_S (TZ_ModuleId_t module); 54 | 55 | /// Free context memory that was previously allocated with \ref TZ_AllocModuleContext_S 56 | /// \param[in] id TrustZone memory slot identifier 57 | /// \return execution status (1: success, 0: error) 58 | uint32_t TZ_FreeModuleContext_S (TZ_MemoryId_t id); 59 | 60 | /// Load secure context (called on RTOS thread context switch) 61 | /// \param[in] id TrustZone memory slot identifier 62 | /// \return execution status (1: success, 0: error) 63 | uint32_t TZ_LoadContext_S (TZ_MemoryId_t id); 64 | 65 | /// Store secure context (called on RTOS thread context switch) 66 | /// \param[in] id TrustZone memory slot identifier 67 | /// \return execution status (1: success, 0: error) 68 | uint32_t TZ_StoreContext_S (TZ_MemoryId_t id); 69 | 70 | #endif // TZ_CONTEXT_H 71 | -------------------------------------------------------------------------------- /03_with_zig_build/Drivers/STM32F7xx_HAL_Driver/Inc/stm32f7xx_hal_dma_ex.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f7xx_hal_dma_ex.h 4 | * @author MCD Application Team 5 | * @brief Header file of DMA HAL extension module. 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | * Copyright (c) 2017 STMicroelectronics. 10 | * All rights reserved. 11 | * 12 | * This software is licensed under terms that can be found in the LICENSE file in 13 | * the root directory of this software component. 14 | * If no LICENSE file comes with this software, it is provided AS-IS. 15 | * 16 | ****************************************************************************** 17 | */ 18 | 19 | /* Define to prevent recursive inclusion -------------------------------------*/ 20 | #ifndef __STM32F7xx_HAL_DMA_EX_H 21 | #define __STM32F7xx_HAL_DMA_EX_H 22 | 23 | #ifdef __cplusplus 24 | extern "C" { 25 | #endif 26 | 27 | /* Includes ------------------------------------------------------------------*/ 28 | #include "stm32f7xx_hal_def.h" 29 | 30 | /** @addtogroup STM32F7xx_HAL_Driver 31 | * @{ 32 | */ 33 | 34 | /** @addtogroup DMAEx 35 | * @{ 36 | */ 37 | 38 | /* Exported types ------------------------------------------------------------*/ 39 | /** @defgroup DMAEx_Exported_Types DMAEx Exported Types 40 | * @brief DMAEx Exported types 41 | * @{ 42 | */ 43 | 44 | /** 45 | * @brief HAL DMA Memory definition 46 | */ 47 | typedef enum 48 | { 49 | MEMORY0 = 0x00U, /*!< Memory 0 */ 50 | MEMORY1 = 0x01U, /*!< Memory 1 */ 51 | 52 | }HAL_DMA_MemoryTypeDef; 53 | 54 | /** 55 | * @} 56 | */ 57 | 58 | /* Exported constants --------------------------------------------------------*/ 59 | 60 | /** @defgroup DMA_Exported_Constants DMA Exported Constants 61 | * @brief DMA Exported constants 62 | * @{ 63 | */ 64 | 65 | /** @defgroup DMAEx_Channel_selection DMA Channel selection 66 | * @brief DMAEx channel selection 67 | * @{ 68 | */ 69 | #define DMA_CHANNEL_0 0x00000000U /*!< DMA Channel 0 */ 70 | #define DMA_CHANNEL_1 0x02000000U /*!< DMA Channel 1 */ 71 | #define DMA_CHANNEL_2 0x04000000U /*!< DMA Channel 2 */ 72 | #define DMA_CHANNEL_3 0x06000000U /*!< DMA Channel 3 */ 73 | #define DMA_CHANNEL_4 0x08000000U /*!< DMA Channel 4 */ 74 | #define DMA_CHANNEL_5 0x0A000000U /*!< DMA Channel 5 */ 75 | #define DMA_CHANNEL_6 0x0C000000U /*!< DMA Channel 6 */ 76 | #define DMA_CHANNEL_7 0x0E000000U /*!< DMA Channel 7 */ 77 | #if defined (STM32F722xx) || defined (STM32F723xx) || defined (STM32F732xx) || defined (STM32F733xx) ||\ 78 | defined (STM32F765xx) || defined (STM32F767xx) || defined (STM32F769xx) || defined (STM32F777xx) ||\ 79 | defined (STM32F779xx) || defined (STM32F730xx) 80 | #define DMA_CHANNEL_8 0x10000000U /*!< DMA Channel 8 */ 81 | #define DMA_CHANNEL_9 0x12000000U /*!< DMA Channel 9 */ 82 | #define DMA_CHANNEL_10 0x14000000U /*!< DMA Channel 10*/ 83 | #define DMA_CHANNEL_11 0x16000000U /*!< DMA Channel 11*/ 84 | #define DMA_CHANNEL_12 0x18000000U /*!< DMA Channel 12*/ 85 | #define DMA_CHANNEL_13 0x1A000000U /*!< DMA Channel 13*/ 86 | #define DMA_CHANNEL_14 0x1C000000U /*!< DMA Channel 14*/ 87 | #define DMA_CHANNEL_15 0x1E000000U /*!< DMA Channel 15*/ 88 | #endif /* STM32F722xx || STM32F723xx || STM32F732xx || STM32F733xx || STM32F765xx || STM32F767xx || 89 | STM32F769xx || STM32F777xx || STM32F779xx || STM32F730xx */ 90 | 91 | /** 92 | * @} 93 | */ 94 | 95 | /** 96 | * @} 97 | */ 98 | 99 | /* Exported functions --------------------------------------------------------*/ 100 | /** @defgroup DMAEx_Exported_Functions DMAEx Exported Functions 101 | * @brief DMAEx Exported functions 102 | * @{ 103 | */ 104 | 105 | /** @defgroup DMAEx_Exported_Functions_Group1 Extended features functions 106 | * @brief Extended features functions 107 | * @{ 108 | */ 109 | 110 | /* IO operation functions *******************************************************/ 111 | HAL_StatusTypeDef HAL_DMAEx_MultiBufferStart(DMA_HandleTypeDef *hdma, uint32_t SrcAddress, uint32_t DstAddress, uint32_t SecondMemAddress, uint32_t DataLength); 112 | HAL_StatusTypeDef HAL_DMAEx_MultiBufferStart_IT(DMA_HandleTypeDef *hdma, uint32_t SrcAddress, uint32_t DstAddress, uint32_t SecondMemAddress, uint32_t DataLength); 113 | HAL_StatusTypeDef HAL_DMAEx_ChangeMemory(DMA_HandleTypeDef *hdma, uint32_t Address, HAL_DMA_MemoryTypeDef memory); 114 | 115 | /** 116 | * @} 117 | */ 118 | /** 119 | * @} 120 | */ 121 | 122 | /* Private macros ------------------------------------------------------------*/ 123 | /** @defgroup DMAEx_Private_Macros DMA Private Macros 124 | * @brief DMAEx private macros 125 | * @{ 126 | */ 127 | #if defined (STM32F722xx) || defined (STM32F723xx) || defined (STM32F732xx) || defined (STM32F733xx) ||\ 128 | defined (STM32F765xx) || defined (STM32F767xx) || defined (STM32F769xx) || defined (STM32F777xx) ||\ 129 | defined (STM32F779xx) || defined (STM32F730xx) 130 | #define IS_DMA_CHANNEL(CHANNEL) (((CHANNEL) == DMA_CHANNEL_0) || \ 131 | ((CHANNEL) == DMA_CHANNEL_1) || \ 132 | ((CHANNEL) == DMA_CHANNEL_2) || \ 133 | ((CHANNEL) == DMA_CHANNEL_3) || \ 134 | ((CHANNEL) == DMA_CHANNEL_4) || \ 135 | ((CHANNEL) == DMA_CHANNEL_5) || \ 136 | ((CHANNEL) == DMA_CHANNEL_6) || \ 137 | ((CHANNEL) == DMA_CHANNEL_7) || \ 138 | ((CHANNEL) == DMA_CHANNEL_8) || \ 139 | ((CHANNEL) == DMA_CHANNEL_9) || \ 140 | ((CHANNEL) == DMA_CHANNEL_10) || \ 141 | ((CHANNEL) == DMA_CHANNEL_11) || \ 142 | ((CHANNEL) == DMA_CHANNEL_12) || \ 143 | ((CHANNEL) == DMA_CHANNEL_13) || \ 144 | ((CHANNEL) == DMA_CHANNEL_14) || \ 145 | ((CHANNEL) == DMA_CHANNEL_15)) 146 | #else 147 | #define IS_DMA_CHANNEL(CHANNEL) (((CHANNEL) == DMA_CHANNEL_0) || \ 148 | ((CHANNEL) == DMA_CHANNEL_1) || \ 149 | ((CHANNEL) == DMA_CHANNEL_2) || \ 150 | ((CHANNEL) == DMA_CHANNEL_3) || \ 151 | ((CHANNEL) == DMA_CHANNEL_4) || \ 152 | ((CHANNEL) == DMA_CHANNEL_5) || \ 153 | ((CHANNEL) == DMA_CHANNEL_6) || \ 154 | ((CHANNEL) == DMA_CHANNEL_7)) 155 | #endif /* STM32F722xx || STM32F723xx || STM32F732xx || STM32F733xx || STM32F765xx || STM32F767xx || 156 | STM32F769xx || STM32F777xx || STM32F779xx || STM32F730xx*/ 157 | /** 158 | * @} 159 | */ 160 | 161 | /* Private functions ---------------------------------------------------------*/ 162 | /** @defgroup DMAEx_Private_Functions DMAEx Private Functions 163 | * @brief DMAEx Private functions 164 | * @{ 165 | */ 166 | /** 167 | * @} 168 | */ 169 | 170 | /** 171 | * @} 172 | */ 173 | 174 | /** 175 | * @} 176 | */ 177 | 178 | #ifdef __cplusplus 179 | } 180 | #endif 181 | 182 | #endif /* __STM32F7xx_HAL_DMA_H */ 183 | 184 | -------------------------------------------------------------------------------- /03_with_zig_build/Drivers/STM32F7xx_HAL_Driver/LICENSE.txt: -------------------------------------------------------------------------------- 1 | This software component is provided to you as part of a software package and 2 | applicable license terms are in the Package_license file. If you received this 3 | software component outside of a package or without applicable license terms, 4 | the terms of the BSD-3-Clause license shall apply. 5 | You may obtain a copy of the BSD-3-Clause at: 6 | https://opensource.org/licenses/BSD-3-Clause 7 | -------------------------------------------------------------------------------- /03_with_zig_build/README.md: -------------------------------------------------------------------------------- 1 | # Writing a `build.zig` for Zig's Build System 2 | 3 | Surely we can do better than a Makefile though, right? This is [insert year it is currently]! 4 | 5 | ## Migrating To Zig's Build System 6 | 7 | Zig also includes its own build-system. Documentation is on the... light... side for now, but there are enough examples out there (like this one!) to get something working. I won't go into the nitty gritty of how precisely Zig's build system works, but will provide some guidance on how our Makefile from [02_drop_in_compiler](../02_drop_in_compiler) translates to [build.zig](./build.zig). 8 | 9 | Some specific callouts: 10 | 11 | ``` zig 12 | const target = b.resolveTargetQuery(.{ 13 | .cpu_arch = .thumb, 14 | .os_tag = .freestanding, 15 | .abi = .eabihf, 16 | .cpu_model = std.zig.CrossTarget.CpuModel{ .explicit = &std.Target.arm.cpu.cortex_m7 }, 17 | .cpu_features_add = std.Target.arm.featureSet(&[_]std.Target.arm.Feature{std.Target.arm.Feature.fp_armv8d16sp}), 18 | }); 19 | ``` 20 | 21 | This does the equivalent of our `-mcpu`, `-mfpu`, `-mfloat-abi` and `-mthumb` flags from earlier. This describes our target, which is an arm processor using the thumb instruction set, it has no OS, it uses the "embedded application binary interface" with an "hf" at the end to signify hardware floating point, it is a Cortex M7 processor, and finally we manually add the feature that actually enables the hardware floating point instructions. That last one was the only one that was difficult to figure out, as while there are "features" named `vfp4d16sp`, and `vfp3d16sp`, there is NOT one named `vfp5d16sp`. The equivalent feature in this case is `fp_armv8d16sp`, because this is the same instruction set, and so LLVM only contains this feature (see [here](https://github.com/llvm/llvm-project/issues/95053) for more info). An important note is *you must correctly setup your floating point configuration in this section* rather than using the `-mfpu` and `-mfloat-abi` flags from earlier. See my post on ziggit [here](https://ziggit.dev/t/clang-default-cpu-features-overriding-gcc-style-compile-flags/4683) for a full explanation why. For anyone who's ever written a toolchain file in CMake, this declarative way of defining a target architecture (complete with code-completion!) is pretty refreshing. 22 | 23 | ``` zig 24 | blinky_exe.link_gc_sections = true; 25 | blinky_exe.link_data_sections = true; 26 | blinky_exe.link_function_sections = true; 27 | ``` 28 | 29 | This allows us to remove manually specified `-ffunction-sections` and `-fdata-sections` compile flags as well as `Wl,--gc-sections` linker flag. Zig does this for us now that we've asked it to. 30 | 31 | Finally, I use Zig to try to find `arm-none-eabi-gcc` either via a user supplied path (supply with `-Darmgcc=...`) or in the system's `PATH` variable: 32 | ``` Zig 33 | // Try to find arm-none-eabi-gcc program at a user specified path, or PATH variable if none provided 34 | const arm_gcc_pgm = if (b.option([]const u8, "armgcc", "Path to arm-none-eabi-gcc compiler")) |arm_gcc_path| 35 | b.findProgram(&.{"arm-none-eabi-gcc"}, &.{arm_gcc_path}) catch { 36 | std.log.err("Couldn't find arm-none-eabi-gcc at provided path: {s}\n", .{arm_gcc_path}); 37 | unreachable; 38 | } 39 | else 40 | b.findProgram(&.{"arm-none-eabi-gcc"}, &.{}) catch { 41 | std.log.err("Couldn't find arm-none-eabi-gcc in PATH, try manually providing the path to this executable with -Darmgcc=[path]\n", .{}); 42 | unreachable; 43 | }; 44 | ``` 45 | 46 | I use the same tricks from [02_drop_in_compiler](../02_drop_in_compiler) to find and populate the pre-compiled Newlib libc that comes bundled with `arm-none-eabi-gcc`. You should now be able to build blink by calling `zig build`! -------------------------------------------------------------------------------- /03_with_zig_build/STM32F750N8Hx_FLASH.ld: -------------------------------------------------------------------------------- 1 | /* 2 | ****************************************************************************** 3 | ** 4 | 5 | ** File : LinkerScript.ld 6 | ** 7 | ** Author : STM32CubeMX 8 | ** 9 | ** Abstract : Linker script for STM32F750N8Hx series 10 | ** 64Kbytes FLASH and 320Kbytes RAM 11 | ** 12 | ** Set heap size, stack size and stack location according 13 | ** to application requirements. 14 | ** 15 | ** Set memory bank area and size if external memory is used. 16 | ** 17 | ** Target : STMicroelectronics STM32 18 | ** 19 | ** Distribution: The file is distributed “as is,” without any warranty 20 | ** of any kind. 21 | ** 22 | ***************************************************************************** 23 | ** @attention 24 | ** 25 | **

© COPYRIGHT(c) 2019 STMicroelectronics

26 | ** 27 | ** Redistribution and use in source and binary forms, with or without modification, 28 | ** are permitted provided that the following conditions are met: 29 | ** 1. Redistributions of source code must retain the above copyright notice, 30 | ** this list of conditions and the following disclaimer. 31 | ** 2. Redistributions in binary form must reproduce the above copyright notice, 32 | ** this list of conditions and the following disclaimer in the documentation 33 | ** and/or other materials provided with the distribution. 34 | ** 3. Neither the name of STMicroelectronics nor the names of its contributors 35 | ** may be used to endorse or promote products derived from this software 36 | ** without specific prior written permission. 37 | ** 38 | ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 39 | ** AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 40 | ** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 41 | ** DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 42 | ** FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 43 | ** DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 44 | ** SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 45 | ** CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 46 | ** OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 47 | ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 48 | ** 49 | ***************************************************************************** 50 | */ 51 | 52 | /* Entry Point */ 53 | ENTRY(Reset_Handler) 54 | 55 | /* Specify the memory areas */ 56 | MEMORY 57 | { 58 | RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 320K 59 | FLASH (rx) : ORIGIN = 0x8000000, LENGTH = 64K 60 | } 61 | 62 | /* Highest address of the user mode stack */ 63 | _estack = ORIGIN(RAM) + LENGTH(RAM); /* end of RAM */ 64 | /* Generate a link error if heap and stack don't fit into RAM */ 65 | _Min_Heap_Size = 0x200; /* required amount of heap */ 66 | _Min_Stack_Size = 0x400; /* required amount of stack */ 67 | 68 | /* Define output sections */ 69 | SECTIONS 70 | { 71 | /* The startup code goes first into FLASH */ 72 | .isr_vector : 73 | { 74 | . = ALIGN(4); 75 | KEEP(*(.isr_vector)) /* Startup code */ 76 | . = ALIGN(4); 77 | } >FLASH 78 | 79 | /* The program code and other data goes into FLASH */ 80 | .text : 81 | { 82 | . = ALIGN(4); 83 | *(.text) /* .text sections (code) */ 84 | *(.text*) /* .text* sections (code) */ 85 | *(.glue_7) /* glue arm to thumb code */ 86 | *(.glue_7t) /* glue thumb to arm code */ 87 | *(.eh_frame) 88 | 89 | KEEP (*(.init)) 90 | KEEP (*(.fini)) 91 | 92 | . = ALIGN(4); 93 | _etext = .; /* define a global symbols at end of code */ 94 | } >FLASH 95 | 96 | /* Constant data goes into FLASH */ 97 | .rodata : 98 | { 99 | . = ALIGN(4); 100 | *(.rodata) /* .rodata sections (constants, strings, etc.) */ 101 | *(.rodata*) /* .rodata* sections (constants, strings, etc.) */ 102 | . = ALIGN(4); 103 | } >FLASH 104 | 105 | .ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) } >FLASH 106 | .ARM : { 107 | __exidx_start = .; 108 | *(.ARM.exidx*) 109 | __exidx_end = .; 110 | } >FLASH 111 | 112 | .preinit_array : 113 | { 114 | PROVIDE_HIDDEN (__preinit_array_start = .); 115 | KEEP (*(.preinit_array*)) 116 | PROVIDE_HIDDEN (__preinit_array_end = .); 117 | } >FLASH 118 | .init_array : 119 | { 120 | PROVIDE_HIDDEN (__init_array_start = .); 121 | KEEP (*(SORT(.init_array.*))) 122 | KEEP (*(.init_array*)) 123 | PROVIDE_HIDDEN (__init_array_end = .); 124 | } >FLASH 125 | .fini_array : 126 | { 127 | PROVIDE_HIDDEN (__fini_array_start = .); 128 | KEEP (*(SORT(.fini_array.*))) 129 | KEEP (*(.fini_array*)) 130 | PROVIDE_HIDDEN (__fini_array_end = .); 131 | } >FLASH 132 | 133 | /* used by the startup to initialize data */ 134 | _sidata = LOADADDR(.data); 135 | 136 | /* Initialized data sections goes into RAM, load LMA copy after code */ 137 | .data : 138 | { 139 | . = ALIGN(4); 140 | _sdata = .; /* create a global symbol at data start */ 141 | *(.data) /* .data sections */ 142 | *(.data*) /* .data* sections */ 143 | 144 | . = ALIGN(4); 145 | _edata = .; /* define a global symbol at data end */ 146 | } >RAM AT> FLASH 147 | 148 | 149 | /* Uninitialized data section */ 150 | . = ALIGN(4); 151 | .bss : 152 | { 153 | /* This is used by the startup in order to initialize the .bss secion */ 154 | _sbss = .; /* define a global symbol at bss start */ 155 | __bss_start__ = _sbss; 156 | *(.bss) 157 | *(.bss*) 158 | *(COMMON) 159 | 160 | . = ALIGN(4); 161 | _ebss = .; /* define a global symbol at bss end */ 162 | __bss_end__ = _ebss; 163 | } >RAM 164 | 165 | /* User_heap_stack section, used to check that there is enough RAM left */ 166 | ._user_heap_stack (NOLOAD) : 167 | { 168 | . = ALIGN(8); 169 | PROVIDE ( end = . ); 170 | PROVIDE ( _end = . ); 171 | . = . + _Min_Heap_Size; 172 | . = . + _Min_Stack_Size; 173 | . = ALIGN(8); 174 | } >RAM 175 | 176 | 177 | 178 | /* Remove information from the standard libraries */ 179 | /DISCARD/ : 180 | { 181 | libc.a ( * ) 182 | libm.a ( * ) 183 | libgcc.a ( * ) 184 | } 185 | 186 | .ARM.attributes 0 : { *(.ARM.attributes) } 187 | } 188 | 189 | 190 | -------------------------------------------------------------------------------- /03_with_zig_build/build.zig: -------------------------------------------------------------------------------- 1 | const std = @import("std"); 2 | 3 | pub fn build(b: *std.Build) void { 4 | const target = b.resolveTargetQuery(.{ 5 | .cpu_arch = .thumb, 6 | .os_tag = .freestanding, 7 | .abi = .eabihf, 8 | .cpu_model = std.zig.CrossTarget.CpuModel{ .explicit = &std.Target.arm.cpu.cortex_m7 }, 9 | // Note that "fp_armv8d16sp" is the same instruction set as "fpv5-sp-d16", so LLVM only has the former 10 | // https://github.com/llvm/llvm-project/issues/95053 11 | .cpu_features_add = std.Target.arm.featureSet(&[_]std.Target.arm.Feature{std.Target.arm.Feature.fp_armv8d16sp}), 12 | }); 13 | const executable_name = "blinky"; 14 | 15 | const optimize = b.standardOptimizeOption(.{}); 16 | const blinky_exe = b.addExecutable(.{ 17 | .name = executable_name ++ ".elf", 18 | .target = target, 19 | .optimize = optimize, 20 | .link_libc = false, 21 | .linkage = .static, 22 | .single_threaded = true, 23 | }); 24 | 25 | // User Options 26 | 27 | // Try to find arm-none-eabi-gcc program at a user specified path, or PATH variable if none provided 28 | const arm_gcc_pgm = if (b.option([]const u8, "armgcc", "Path to arm-none-eabi-gcc compiler")) |arm_gcc_path| 29 | b.findProgram(&.{"arm-none-eabi-gcc"}, &.{arm_gcc_path}) catch { 30 | std.log.err("Couldn't find arm-none-eabi-gcc at provided path: {s}\n", .{arm_gcc_path}); 31 | unreachable; 32 | } 33 | else 34 | b.findProgram(&.{"arm-none-eabi-gcc"}, &.{}) catch { 35 | std.log.err("Couldn't find arm-none-eabi-gcc in PATH, try manually providing the path to this executable with -Darmgcc=[path]\n", .{}); 36 | unreachable; 37 | }; 38 | 39 | // Allow user to enable float formatting in newlib (printf, sprintf, ...) 40 | if (b.option(bool, "NEWLIB_PRINTF_FLOAT", "Force newlib to include float support for printf()")) |_| { 41 | blinky_exe.forceUndefinedSymbol("_printf_float"); // GCC equivalent : "-u _printf_float" 42 | } 43 | 44 | // Use gcc-arm-none-eabi to figure out where library paths are 45 | const gcc_arm_sysroot_path = std.mem.trim(u8, b.run(&.{ arm_gcc_pgm, "-print-sysroot" }), "\r\n"); 46 | const gcc_arm_multidir_relative_path = std.mem.trim(u8, b.run(&.{ arm_gcc_pgm, "-mcpu=cortex-m7", "-mfpu=fpv5-sp-d16", "-mfloat-abi=hard", "-print-multi-directory" }), "\r\n"); 47 | const gcc_arm_version = std.mem.trim(u8, b.run(&.{ arm_gcc_pgm, "-dumpversion" }), "\r\n"); 48 | const gcc_arm_lib_path1 = b.fmt("{s}/../lib/gcc/arm-none-eabi/{s}/{s}", .{ gcc_arm_sysroot_path, gcc_arm_version, gcc_arm_multidir_relative_path }); 49 | const gcc_arm_lib_path2 = b.fmt("{s}/lib/{s}", .{ gcc_arm_sysroot_path, gcc_arm_multidir_relative_path }); 50 | 51 | // Manually add "nano" variant newlib C standard lib from arm-none-eabi-gcc library folders 52 | blinky_exe.addLibraryPath(.{ .cwd_relative = gcc_arm_lib_path1 }); 53 | blinky_exe.addLibraryPath(.{ .cwd_relative = gcc_arm_lib_path2 }); 54 | blinky_exe.addSystemIncludePath(.{ .cwd_relative = b.fmt("{s}/include", .{gcc_arm_sysroot_path}) }); 55 | blinky_exe.linkSystemLibrary("c_nano"); 56 | blinky_exe.linkSystemLibrary("m"); 57 | 58 | // Manually include C runtime objects bundled with arm-none-eabi-gcc 59 | blinky_exe.addObjectFile(.{ .cwd_relative = b.fmt("{s}/crt0.o", .{gcc_arm_lib_path2}) }); 60 | blinky_exe.addObjectFile(.{ .cwd_relative = b.fmt("{s}/crti.o", .{gcc_arm_lib_path1}) }); 61 | blinky_exe.addObjectFile(.{ .cwd_relative = b.fmt("{s}/crtbegin.o", .{gcc_arm_lib_path1}) }); 62 | blinky_exe.addObjectFile(.{ .cwd_relative = b.fmt("{s}/crtend.o", .{gcc_arm_lib_path1}) }); 63 | blinky_exe.addObjectFile(.{ .cwd_relative = b.fmt("{s}/crtn.o", .{gcc_arm_lib_path1}) }); 64 | 65 | // Normal Include Paths 66 | blinky_exe.addIncludePath(b.path("Core/Inc")); 67 | blinky_exe.addIncludePath(b.path("Drivers/STM32F7xx_HAL_Driver/Inc")); 68 | blinky_exe.addIncludePath(b.path("Drivers/STM32F7xx_HAL_Driver/Inc/Legacy")); 69 | blinky_exe.addIncludePath(b.path("Drivers/CMSIS/Device/ST/STM32F7xx/Include")); 70 | blinky_exe.addIncludePath(b.path("Drivers/CMSIS/Include")); 71 | 72 | // Startup file 73 | blinky_exe.addAssemblyFile(b.path("startup_stm32f750xx.s")); 74 | 75 | // Source files 76 | blinky_exe.addCSourceFiles(.{ 77 | .files = &.{ 78 | "Core/Src/main.c", 79 | "Core/Src/gpio.c", 80 | "Core/Src/stm32f7xx_it.c", 81 | "Core/Src/stm32f7xx_hal_msp.c", 82 | "Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_cortex.c", 83 | "Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_rcc.c", 84 | "Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_rcc_ex.c", 85 | "Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_flash.c", 86 | "Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_flash_ex.c", 87 | "Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_gpio.c", 88 | "Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_dma.c", 89 | "Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_dma_ex.c", 90 | "Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_pwr.c", 91 | "Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_pwr_ex.c", 92 | "Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal.c", 93 | "Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_i2c.c", 94 | "Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_i2c_ex.c", 95 | "Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_tim.c", 96 | "Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_tim_ex.c", 97 | "Core/Src/system_stm32f7xx.c", 98 | "Core/Src/sysmem.c", 99 | "Core/Src/syscalls.c", 100 | }, 101 | .flags = &.{ "-Og", "-std=c11", "-DUSE_HAL_DRIVER", "-DSTM32F750xx" }, 102 | }); 103 | 104 | blinky_exe.link_gc_sections = true; 105 | blinky_exe.link_data_sections = true; 106 | blinky_exe.link_function_sections = true; 107 | blinky_exe.setLinkerScriptPath(b.path("./STM32F750N8Hx_FLASH.ld")); 108 | 109 | // Produce .bin file from .elf 110 | const bin = b.addObjCopy(blinky_exe.getEmittedBin(), .{ 111 | .format = .bin, 112 | }); 113 | bin.step.dependOn(&blinky_exe.step); 114 | const copy_bin = b.addInstallBinFile(bin.getOutput(), executable_name ++ ".bin"); 115 | b.default_step.dependOn(©_bin.step); 116 | 117 | // Produce .hex file from .elf 118 | const hex = b.addObjCopy(blinky_exe.getEmittedBin(), .{ 119 | .format = .hex, 120 | }); 121 | hex.step.dependOn(&blinky_exe.step); 122 | const copy_hex = b.addInstallBinFile(hex.getOutput(), executable_name ++ ".hex"); 123 | b.default_step.dependOn(©_hex.step); 124 | 125 | b.installArtifact(blinky_exe); 126 | } 127 | -------------------------------------------------------------------------------- /04_advanced_zig_project/build.zig: -------------------------------------------------------------------------------- 1 | const std = @import("std"); 2 | const stm32_hal = @import("stm32_hal"); 3 | 4 | pub fn build(b: *std.Build) void { 5 | const target = b.resolveTargetQuery(.{ 6 | .cpu_arch = .thumb, 7 | .os_tag = .freestanding, 8 | .abi = .eabihf, 9 | .cpu_model = std.zig.CrossTarget.CpuModel{ .explicit = &std.Target.arm.cpu.cortex_m7 }, 10 | // Note that "fp_armv8d16sp" is the same instruction set as "fpv5-sp-d16", so LLVM only has the former 11 | // https://github.com/llvm/llvm-project/issues/95053 12 | .cpu_features_add = std.Target.arm.featureSet(&[_]std.Target.arm.Feature{std.Target.arm.Feature.fp_armv8d16sp}), 13 | }); 14 | const executable_name = "blinky"; 15 | 16 | const optimize = b.standardOptimizeOption(.{}); 17 | const blinky_exe = b.addExecutable(.{ 18 | .name = executable_name ++ ".elf", 19 | .target = target, 20 | .optimize = optimize, 21 | .link_libc = false, 22 | .linkage = .static, 23 | .single_threaded = true, 24 | .root_source_file = b.path("src/main.zig"), 25 | }); 26 | 27 | // Add STM32 Hal 28 | stm32_hal.addTo(b, blinky_exe); 29 | 30 | blinky_exe.link_gc_sections = true; 31 | blinky_exe.link_data_sections = true; 32 | blinky_exe.link_function_sections = true; 33 | 34 | // Produce .bin file from .elf 35 | const bin = b.addObjCopy(blinky_exe.getEmittedBin(), .{ 36 | .format = .bin, 37 | }); 38 | bin.step.dependOn(&blinky_exe.step); 39 | const copy_bin = b.addInstallBinFile(bin.getOutput(), executable_name ++ ".bin"); 40 | b.default_step.dependOn(©_bin.step); 41 | 42 | // Produce .hex file from .elf 43 | const hex = b.addObjCopy(blinky_exe.getEmittedBin(), .{ 44 | .format = .hex, 45 | }); 46 | hex.step.dependOn(&blinky_exe.step); 47 | const copy_hex = b.addInstallBinFile(hex.getOutput(), executable_name ++ ".hex"); 48 | b.default_step.dependOn(©_hex.step); 49 | 50 | b.installArtifact(blinky_exe); 51 | } 52 | -------------------------------------------------------------------------------- /04_advanced_zig_project/build.zig.zon: -------------------------------------------------------------------------------- 1 | .{ 2 | .name = "stm32_zig_porting", 3 | .version = "0.0.0", 4 | .dependencies = .{ 5 | .stm32_hal = .{ 6 | .path = "stm32_hal", 7 | }, 8 | }, 9 | .paths = .{ 10 | "build.zig", 11 | "build.zig.zon", 12 | "src", 13 | "README.md", 14 | }, 15 | } 16 | -------------------------------------------------------------------------------- /04_advanced_zig_project/src/main.zig: -------------------------------------------------------------------------------- 1 | const stm32_hal = @cImport({ 2 | @cDefine("STM32F750xx", {}); 3 | @cDefine("USE_HAL_DRIVER", {}); 4 | @cInclude("main.h"); 5 | }); 6 | 7 | // This also does the exact same thing, and is ~25 lines instead of the ~26000 generated from the above @cImport! 8 | // const stm32_hal = struct { 9 | // pub const GPIO_TypeDef = extern struct { 10 | // MODER: u32 = @import("std").mem.zeroes(u32), 11 | // OTYPER: u32 = @import("std").mem.zeroes(u32), 12 | // OSPEEDR: u32 = @import("std").mem.zeroes(u32), 13 | // PUPDR: u32 = @import("std").mem.zeroes(u32), 14 | // IDR: u32 = @import("std").mem.zeroes(u32), 15 | // ODR: u32 = @import("std").mem.zeroes(u32), 16 | // BSRR: u32 = @import("std").mem.zeroes(u32), 17 | // LCKR: u32 = @import("std").mem.zeroes(u32), 18 | // AFR: [2]u32 = @import("std").mem.zeroes([2]u32), 19 | // }; 20 | // pub const PERIPH_BASE = @as(c_ulong, 0x40000000); 21 | // pub const AHB1PERIPH_BASE = PERIPH_BASE + @as(c_ulong, 0x00020000); 22 | // pub const GPIOA_BASE = AHB1PERIPH_BASE + @as(c_ulong, 0x0000); 23 | // pub const GPIOA = @import("std").zig.c_translation.cast([*c]GPIO_TypeDef, GPIOA_BASE); 24 | // pub const GPIO_PIN_15 = @import("std").zig.c_translation.cast(u16, @as(c_uint, 0x8000)); 25 | // pub const LED_BLINK_Pin = GPIO_PIN_15; 26 | // pub const LED_BLINK_GPIO_Port = GPIOA; 27 | // pub const GPIO_PinState = c_uint; 28 | // pub const GPIO_PIN_RESET: c_int = 0; 29 | // pub const GPIO_PIN_SET: c_int = 1; 30 | // pub extern fn HAL_GPIO_WritePin(GPIOx: [*c]GPIO_TypeDef, GPIO_Pin: u16, PinState: GPIO_PinState) void; 31 | // pub extern fn HAL_Delay(Delay: u32) void; 32 | // }; 33 | 34 | export fn zigMain() void { 35 | while (true) { 36 | stm32_hal.HAL_GPIO_WritePin(stm32_hal.LED_BLINK_GPIO_Port, stm32_hal.LED_BLINK_Pin, stm32_hal.GPIO_PIN_RESET); 37 | stm32_hal.HAL_Delay(1000); 38 | stm32_hal.HAL_GPIO_WritePin(stm32_hal.LED_BLINK_GPIO_Port, stm32_hal.LED_BLINK_Pin, stm32_hal.GPIO_PIN_SET); 39 | stm32_hal.HAL_Delay(1000); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /04_advanced_zig_project/stm32_hal/Core/Inc/gpio.h: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file gpio.h 5 | * @brief This file contains all the function prototypes for 6 | * the gpio.c file 7 | ****************************************************************************** 8 | * @attention 9 | * 10 | * Copyright (c) 2024 STMicroelectronics. 11 | * All rights reserved. 12 | * 13 | * This software is licensed under terms that can be found in the LICENSE file 14 | * in the root directory of this software component. 15 | * If no LICENSE file comes with this software, it is provided AS-IS. 16 | * 17 | ****************************************************************************** 18 | */ 19 | /* USER CODE END Header */ 20 | /* Define to prevent recursive inclusion -------------------------------------*/ 21 | #ifndef __GPIO_H__ 22 | #define __GPIO_H__ 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | /* Includes ------------------------------------------------------------------*/ 29 | #include "main.h" 30 | 31 | /* USER CODE BEGIN Includes */ 32 | 33 | /* USER CODE END Includes */ 34 | 35 | /* USER CODE BEGIN Private defines */ 36 | 37 | /* USER CODE END Private defines */ 38 | 39 | void MX_GPIO_Init(void); 40 | 41 | /* USER CODE BEGIN Prototypes */ 42 | 43 | /* USER CODE END Prototypes */ 44 | 45 | #ifdef __cplusplus 46 | } 47 | #endif 48 | #endif /*__ GPIO_H__ */ 49 | 50 | -------------------------------------------------------------------------------- /04_advanced_zig_project/stm32_hal/Core/Inc/main.h: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file : main.h 5 | * @brief : Header for main.c file. 6 | * This file contains the common defines of the application. 7 | ****************************************************************************** 8 | * @attention 9 | * 10 | * Copyright (c) 2024 STMicroelectronics. 11 | * All rights reserved. 12 | * 13 | * This software is licensed under terms that can be found in the LICENSE file 14 | * in the root directory of this software component. 15 | * If no LICENSE file comes with this software, it is provided AS-IS. 16 | * 17 | ****************************************************************************** 18 | */ 19 | /* USER CODE END Header */ 20 | 21 | /* Define to prevent recursive inclusion -------------------------------------*/ 22 | #ifndef __MAIN_H 23 | #define __MAIN_H 24 | 25 | #ifdef __cplusplus 26 | extern "C" { 27 | #endif 28 | 29 | /* Includes ------------------------------------------------------------------*/ 30 | #include "stm32f7xx_hal.h" 31 | 32 | /* Private includes ----------------------------------------------------------*/ 33 | /* USER CODE BEGIN Includes */ 34 | 35 | /* USER CODE END Includes */ 36 | 37 | /* Exported types ------------------------------------------------------------*/ 38 | /* USER CODE BEGIN ET */ 39 | 40 | /* USER CODE END ET */ 41 | 42 | /* Exported constants --------------------------------------------------------*/ 43 | /* USER CODE BEGIN EC */ 44 | 45 | /* USER CODE END EC */ 46 | 47 | /* Exported macro ------------------------------------------------------------*/ 48 | /* USER CODE BEGIN EM */ 49 | 50 | /* USER CODE END EM */ 51 | 52 | /* Exported functions prototypes ---------------------------------------------*/ 53 | void Error_Handler(void); 54 | 55 | /* USER CODE BEGIN EFP */ 56 | void hal_initialization_code(void); 57 | 58 | /* USER CODE END EFP */ 59 | 60 | /* Private defines -----------------------------------------------------------*/ 61 | #define LED_BLINK_Pin GPIO_PIN_15 62 | #define LED_BLINK_GPIO_Port GPIOA 63 | 64 | /* USER CODE BEGIN Private defines */ 65 | 66 | /* USER CODE END Private defines */ 67 | 68 | #ifdef __cplusplus 69 | } 70 | #endif 71 | 72 | #endif /* __MAIN_H */ 73 | -------------------------------------------------------------------------------- /04_advanced_zig_project/stm32_hal/Core/Inc/stm32f7xx_it.h: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file stm32f7xx_it.h 5 | * @brief This file contains the headers of the interrupt handlers. 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | * Copyright (c) 2024 STMicroelectronics. 10 | * All rights reserved. 11 | * 12 | * This software is licensed under terms that can be found in the LICENSE file 13 | * in the root directory of this software component. 14 | * If no LICENSE file comes with this software, it is provided AS-IS. 15 | * 16 | ****************************************************************************** 17 | */ 18 | /* USER CODE END Header */ 19 | 20 | /* Define to prevent recursive inclusion -------------------------------------*/ 21 | #ifndef __STM32F7xx_IT_H 22 | #define __STM32F7xx_IT_H 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | /* Private includes ----------------------------------------------------------*/ 29 | /* USER CODE BEGIN Includes */ 30 | 31 | /* USER CODE END Includes */ 32 | 33 | /* Exported types ------------------------------------------------------------*/ 34 | /* USER CODE BEGIN ET */ 35 | 36 | /* USER CODE END ET */ 37 | 38 | /* Exported constants --------------------------------------------------------*/ 39 | /* USER CODE BEGIN EC */ 40 | 41 | /* USER CODE END EC */ 42 | 43 | /* Exported macro ------------------------------------------------------------*/ 44 | /* USER CODE BEGIN EM */ 45 | 46 | /* USER CODE END EM */ 47 | 48 | /* Exported functions prototypes ---------------------------------------------*/ 49 | void SysTick_Handler(void); 50 | /* USER CODE BEGIN EFP */ 51 | 52 | /* USER CODE END EFP */ 53 | 54 | #ifdef __cplusplus 55 | } 56 | #endif 57 | 58 | #endif /* __STM32F7xx_IT_H */ 59 | -------------------------------------------------------------------------------- /04_advanced_zig_project/stm32_hal/Core/Src/gpio.c: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file gpio.c 5 | * @brief This file provides code for the configuration 6 | * of all used GPIO pins. 7 | ****************************************************************************** 8 | * @attention 9 | * 10 | * Copyright (c) 2024 STMicroelectronics. 11 | * All rights reserved. 12 | * 13 | * This software is licensed under terms that can be found in the LICENSE file 14 | * in the root directory of this software component. 15 | * If no LICENSE file comes with this software, it is provided AS-IS. 16 | * 17 | ****************************************************************************** 18 | */ 19 | /* USER CODE END Header */ 20 | 21 | /* Includes ------------------------------------------------------------------*/ 22 | #include "gpio.h" 23 | 24 | /* USER CODE BEGIN 0 */ 25 | 26 | /* USER CODE END 0 */ 27 | 28 | /*----------------------------------------------------------------------------*/ 29 | /* Configure GPIO */ 30 | /*----------------------------------------------------------------------------*/ 31 | /* USER CODE BEGIN 1 */ 32 | 33 | /* USER CODE END 1 */ 34 | 35 | /** Configure pins 36 | PE2 ------> QUADSPI_BK1_IO2 37 | PB6 ------> QUADSPI_BK1_NCS 38 | PB2 ------> QUADSPI_CLK 39 | PD12 ------> QUADSPI_BK1_IO1 40 | PD13 ------> QUADSPI_BK1_IO3 41 | PD11 ------> QUADSPI_BK1_IO0 42 | */ 43 | void MX_GPIO_Init(void) 44 | { 45 | 46 | GPIO_InitTypeDef GPIO_InitStruct = {0}; 47 | 48 | /* GPIO Ports Clock Enable */ 49 | __HAL_RCC_GPIOE_CLK_ENABLE(); 50 | __HAL_RCC_GPIOA_CLK_ENABLE(); 51 | __HAL_RCC_GPIOB_CLK_ENABLE(); 52 | __HAL_RCC_GPIOH_CLK_ENABLE(); 53 | __HAL_RCC_GPIOD_CLK_ENABLE(); 54 | 55 | /*Configure GPIO pin Output Level */ 56 | HAL_GPIO_WritePin(LED_BLINK_GPIO_Port, LED_BLINK_Pin, GPIO_PIN_RESET); 57 | 58 | /*Configure GPIO pin : PE2 */ 59 | GPIO_InitStruct.Pin = GPIO_PIN_2; 60 | GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; 61 | GPIO_InitStruct.Pull = GPIO_NOPULL; 62 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; 63 | GPIO_InitStruct.Alternate = GPIO_AF9_QUADSPI; 64 | HAL_GPIO_Init(GPIOE, &GPIO_InitStruct); 65 | 66 | /*Configure GPIO pin : PtPin */ 67 | GPIO_InitStruct.Pin = LED_BLINK_Pin; 68 | GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; 69 | GPIO_InitStruct.Pull = GPIO_NOPULL; 70 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; 71 | HAL_GPIO_Init(LED_BLINK_GPIO_Port, &GPIO_InitStruct); 72 | 73 | /*Configure GPIO pin : PB6 */ 74 | GPIO_InitStruct.Pin = GPIO_PIN_6; 75 | GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; 76 | GPIO_InitStruct.Pull = GPIO_NOPULL; 77 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; 78 | GPIO_InitStruct.Alternate = GPIO_AF10_QUADSPI; 79 | HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); 80 | 81 | /*Configure GPIO pin : PB2 */ 82 | GPIO_InitStruct.Pin = GPIO_PIN_2; 83 | GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; 84 | GPIO_InitStruct.Pull = GPIO_NOPULL; 85 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; 86 | GPIO_InitStruct.Alternate = GPIO_AF9_QUADSPI; 87 | HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); 88 | 89 | /*Configure GPIO pins : PD12 PD13 PD11 */ 90 | GPIO_InitStruct.Pin = GPIO_PIN_12|GPIO_PIN_13|GPIO_PIN_11; 91 | GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; 92 | GPIO_InitStruct.Pull = GPIO_NOPULL; 93 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; 94 | GPIO_InitStruct.Alternate = GPIO_AF9_QUADSPI; 95 | HAL_GPIO_Init(GPIOD, &GPIO_InitStruct); 96 | 97 | } 98 | 99 | /* USER CODE BEGIN 2 */ 100 | 101 | /* USER CODE END 2 */ 102 | -------------------------------------------------------------------------------- /04_advanced_zig_project/stm32_hal/Core/Src/main.c: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file : main.c 5 | * @brief : Main program body 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | * Copyright (c) 2024 STMicroelectronics. 10 | * All rights reserved. 11 | * 12 | * This software is licensed under terms that can be found in the LICENSE file 13 | * in the root directory of this software component. 14 | * If no LICENSE file comes with this software, it is provided AS-IS. 15 | * 16 | ****************************************************************************** 17 | */ 18 | /* USER CODE END Header */ 19 | /* Includes ------------------------------------------------------------------*/ 20 | #include "main.h" 21 | #include "gpio.h" 22 | 23 | /* Private includes ----------------------------------------------------------*/ 24 | /* USER CODE BEGIN Includes */ 25 | 26 | /* USER CODE END Includes */ 27 | 28 | /* Private typedef -----------------------------------------------------------*/ 29 | /* USER CODE BEGIN PTD */ 30 | 31 | /* USER CODE END PTD */ 32 | 33 | /* Private define ------------------------------------------------------------*/ 34 | /* USER CODE BEGIN PD */ 35 | 36 | /* USER CODE END PD */ 37 | 38 | /* Private macro -------------------------------------------------------------*/ 39 | /* USER CODE BEGIN PM */ 40 | 41 | /* USER CODE END PM */ 42 | 43 | /* Private variables ---------------------------------------------------------*/ 44 | 45 | /* USER CODE BEGIN PV */ 46 | 47 | /* USER CODE END PV */ 48 | 49 | /* Private function prototypes -----------------------------------------------*/ 50 | void SystemClock_Config(void); 51 | static void MPU_Config(void); 52 | /* USER CODE BEGIN PFP */ 53 | 54 | /* USER CODE END PFP */ 55 | 56 | /* Private user code ---------------------------------------------------------*/ 57 | /* USER CODE BEGIN 0 */ 58 | extern void zigMain(void); 59 | /* USER CODE END 0 */ 60 | 61 | /** 62 | * @brief The application entry point. 63 | * @retval int 64 | */ 65 | int main(void) 66 | { 67 | 68 | /* USER CODE BEGIN 1 */ 69 | 70 | /* USER CODE END 1 */ 71 | 72 | /* MPU Configuration--------------------------------------------------------*/ 73 | MPU_Config(); 74 | 75 | /* MCU Configuration--------------------------------------------------------*/ 76 | 77 | /* Reset of all peripherals, Initializes the Flash interface and the Systick. */ 78 | HAL_Init(); 79 | 80 | /* USER CODE BEGIN Init */ 81 | 82 | /* USER CODE END Init */ 83 | 84 | /* Configure the system clock */ 85 | SystemClock_Config(); 86 | 87 | /* USER CODE BEGIN SysInit */ 88 | 89 | /* USER CODE END SysInit */ 90 | 91 | /* Initialize all configured peripherals */ 92 | MX_GPIO_Init(); 93 | /* USER CODE BEGIN 2 */ 94 | zigMain(); // Never returns! 95 | /* USER CODE END 2 */ 96 | 97 | /* Infinite loop */ 98 | /* USER CODE BEGIN WHILE */ 99 | while (1) 100 | { 101 | /* USER CODE END WHILE */ 102 | 103 | /* USER CODE BEGIN 3 */ 104 | } 105 | /* USER CODE END 3 */ 106 | } 107 | 108 | /** 109 | * @brief System Clock Configuration 110 | * @retval None 111 | */ 112 | void SystemClock_Config(void) 113 | { 114 | RCC_OscInitTypeDef RCC_OscInitStruct = {0}; 115 | RCC_ClkInitTypeDef RCC_ClkInitStruct = {0}; 116 | 117 | /** Configure the main internal regulator output voltage 118 | */ 119 | __HAL_RCC_PWR_CLK_ENABLE(); 120 | __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1); 121 | 122 | /** Initializes the RCC Oscillators according to the specified parameters 123 | * in the RCC_OscInitTypeDef structure. 124 | */ 125 | RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE; 126 | RCC_OscInitStruct.HSEState = RCC_HSE_ON; 127 | RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; 128 | RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE; 129 | RCC_OscInitStruct.PLL.PLLM = 25; 130 | RCC_OscInitStruct.PLL.PLLN = 432; 131 | RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2; 132 | RCC_OscInitStruct.PLL.PLLQ = 2; 133 | if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) 134 | { 135 | Error_Handler(); 136 | } 137 | 138 | /** Activate the Over-Drive mode 139 | */ 140 | if (HAL_PWREx_EnableOverDrive() != HAL_OK) 141 | { 142 | Error_Handler(); 143 | } 144 | 145 | /** Initializes the CPU, AHB and APB buses clocks 146 | */ 147 | RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2; 148 | RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; 149 | RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; 150 | RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV4; 151 | RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV2; 152 | 153 | if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_7) != HAL_OK) 154 | { 155 | Error_Handler(); 156 | } 157 | } 158 | 159 | /* USER CODE BEGIN 4 */ 160 | 161 | /* USER CODE END 4 */ 162 | 163 | /* MPU Configuration */ 164 | 165 | void MPU_Config(void) 166 | { 167 | MPU_Region_InitTypeDef MPU_InitStruct = {0}; 168 | 169 | /* Disables the MPU */ 170 | HAL_MPU_Disable(); 171 | 172 | /** Initializes and configures the Region and the memory to be protected 173 | */ 174 | MPU_InitStruct.Enable = MPU_REGION_ENABLE; 175 | MPU_InitStruct.Number = MPU_REGION_NUMBER0; 176 | MPU_InitStruct.BaseAddress = 0x0; 177 | MPU_InitStruct.Size = MPU_REGION_SIZE_4GB; 178 | MPU_InitStruct.SubRegionDisable = 0x87; 179 | MPU_InitStruct.TypeExtField = MPU_TEX_LEVEL0; 180 | MPU_InitStruct.AccessPermission = MPU_REGION_NO_ACCESS; 181 | MPU_InitStruct.DisableExec = MPU_INSTRUCTION_ACCESS_DISABLE; 182 | MPU_InitStruct.IsShareable = MPU_ACCESS_SHAREABLE; 183 | MPU_InitStruct.IsCacheable = MPU_ACCESS_NOT_CACHEABLE; 184 | MPU_InitStruct.IsBufferable = MPU_ACCESS_NOT_BUFFERABLE; 185 | 186 | HAL_MPU_ConfigRegion(&MPU_InitStruct); 187 | 188 | /** Initializes and configures the Region and the memory to be protected 189 | */ 190 | MPU_InitStruct.Number = MPU_REGION_NUMBER1; 191 | MPU_InitStruct.BaseAddress = 0xA0000000; 192 | MPU_InitStruct.Size = MPU_REGION_SIZE_8KB; 193 | MPU_InitStruct.SubRegionDisable = 0x0; 194 | MPU_InitStruct.AccessPermission = MPU_REGION_FULL_ACCESS; 195 | MPU_InitStruct.IsBufferable = MPU_ACCESS_BUFFERABLE; 196 | 197 | HAL_MPU_ConfigRegion(&MPU_InitStruct); 198 | /* Enables the MPU */ 199 | HAL_MPU_Enable(MPU_PRIVILEGED_DEFAULT); 200 | } 201 | 202 | /** 203 | * @brief This function is executed in case of error occurrence. 204 | * @retval None 205 | */ 206 | void Error_Handler(void) 207 | { 208 | /* USER CODE BEGIN Error_Handler_Debug */ 209 | /* User can add his own implementation to report the HAL error return state */ 210 | __disable_irq(); 211 | while (1) 212 | { 213 | } 214 | /* USER CODE END Error_Handler_Debug */ 215 | } 216 | 217 | #ifdef USE_FULL_ASSERT 218 | /** 219 | * @brief Reports the name of the source file and the source line number 220 | * where the assert_param error has occurred. 221 | * @param file: pointer to the source file name 222 | * @param line: assert_param error line source number 223 | * @retval None 224 | */ 225 | void assert_failed(uint8_t *file, uint32_t line) 226 | { 227 | /* USER CODE BEGIN 6 */ 228 | /* User can add his own implementation to report the file name and line number, 229 | ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */ 230 | /* USER CODE END 6 */ 231 | } 232 | #endif /* USE_FULL_ASSERT */ 233 | -------------------------------------------------------------------------------- /04_advanced_zig_project/stm32_hal/Core/Src/stm32f7xx_hal_msp.c: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file stm32f7xx_hal_msp.c 5 | * @brief This file provides code for the MSP Initialization 6 | * and de-Initialization codes. 7 | ****************************************************************************** 8 | * @attention 9 | * 10 | * Copyright (c) 2024 STMicroelectronics. 11 | * All rights reserved. 12 | * 13 | * This software is licensed under terms that can be found in the LICENSE file 14 | * in the root directory of this software component. 15 | * If no LICENSE file comes with this software, it is provided AS-IS. 16 | * 17 | ****************************************************************************** 18 | */ 19 | /* USER CODE END Header */ 20 | 21 | /* Includes ------------------------------------------------------------------*/ 22 | #include "main.h" 23 | /* USER CODE BEGIN Includes */ 24 | 25 | /* USER CODE END Includes */ 26 | 27 | /* Private typedef -----------------------------------------------------------*/ 28 | /* USER CODE BEGIN TD */ 29 | 30 | /* USER CODE END TD */ 31 | 32 | /* Private define ------------------------------------------------------------*/ 33 | /* USER CODE BEGIN Define */ 34 | 35 | /* USER CODE END Define */ 36 | 37 | /* Private macro -------------------------------------------------------------*/ 38 | /* USER CODE BEGIN Macro */ 39 | 40 | /* USER CODE END Macro */ 41 | 42 | /* Private variables ---------------------------------------------------------*/ 43 | /* USER CODE BEGIN PV */ 44 | 45 | /* USER CODE END PV */ 46 | 47 | /* Private function prototypes -----------------------------------------------*/ 48 | /* USER CODE BEGIN PFP */ 49 | 50 | /* USER CODE END PFP */ 51 | 52 | /* External functions --------------------------------------------------------*/ 53 | /* USER CODE BEGIN ExternalFunctions */ 54 | 55 | /* USER CODE END ExternalFunctions */ 56 | 57 | /* USER CODE BEGIN 0 */ 58 | 59 | /* USER CODE END 0 */ 60 | /** 61 | * Initializes the Global MSP. 62 | */ 63 | void HAL_MspInit(void) 64 | { 65 | 66 | /* USER CODE BEGIN MspInit 0 */ 67 | 68 | /* USER CODE END MspInit 0 */ 69 | 70 | __HAL_RCC_PWR_CLK_ENABLE(); 71 | __HAL_RCC_SYSCFG_CLK_ENABLE(); 72 | 73 | /* System interrupt init*/ 74 | 75 | /* USER CODE BEGIN MspInit 1 */ 76 | 77 | /* USER CODE END MspInit 1 */ 78 | } 79 | 80 | /* USER CODE BEGIN 1 */ 81 | 82 | /* USER CODE END 1 */ 83 | -------------------------------------------------------------------------------- /04_advanced_zig_project/stm32_hal/Core/Src/stm32f7xx_it.c: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file stm32f7xx_it.c 5 | * @brief Interrupt Service Routines. 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | * Copyright (c) 2024 STMicroelectronics. 10 | * All rights reserved. 11 | * 12 | * This software is licensed under terms that can be found in the LICENSE file 13 | * in the root directory of this software component. 14 | * If no LICENSE file comes with this software, it is provided AS-IS. 15 | * 16 | ****************************************************************************** 17 | */ 18 | /* USER CODE END Header */ 19 | 20 | /* Includes ------------------------------------------------------------------*/ 21 | #include "main.h" 22 | #include "stm32f7xx_it.h" 23 | /* Private includes ----------------------------------------------------------*/ 24 | /* USER CODE BEGIN Includes */ 25 | /* USER CODE END Includes */ 26 | 27 | /* Private typedef -----------------------------------------------------------*/ 28 | /* USER CODE BEGIN TD */ 29 | 30 | /* USER CODE END TD */ 31 | 32 | /* Private define ------------------------------------------------------------*/ 33 | /* USER CODE BEGIN PD */ 34 | 35 | /* USER CODE END PD */ 36 | 37 | /* Private macro -------------------------------------------------------------*/ 38 | /* USER CODE BEGIN PM */ 39 | 40 | /* USER CODE END PM */ 41 | 42 | /* Private variables ---------------------------------------------------------*/ 43 | /* USER CODE BEGIN PV */ 44 | 45 | /* USER CODE END PV */ 46 | 47 | /* Private function prototypes -----------------------------------------------*/ 48 | /* USER CODE BEGIN PFP */ 49 | 50 | /* USER CODE END PFP */ 51 | 52 | /* Private user code ---------------------------------------------------------*/ 53 | /* USER CODE BEGIN 0 */ 54 | 55 | /* USER CODE END 0 */ 56 | 57 | /* External variables --------------------------------------------------------*/ 58 | 59 | /* USER CODE BEGIN EV */ 60 | 61 | /* USER CODE END EV */ 62 | 63 | /******************************************************************************/ 64 | /* Cortex-M7 Processor Interruption and Exception Handlers */ 65 | /******************************************************************************/ 66 | /** 67 | * @brief This function handles System tick timer. 68 | */ 69 | void SysTick_Handler(void) 70 | { 71 | /* USER CODE BEGIN SysTick_IRQn 0 */ 72 | 73 | /* USER CODE END SysTick_IRQn 0 */ 74 | HAL_IncTick(); 75 | /* USER CODE BEGIN SysTick_IRQn 1 */ 76 | 77 | /* USER CODE END SysTick_IRQn 1 */ 78 | } 79 | 80 | /******************************************************************************/ 81 | /* STM32F7xx Peripheral Interrupt Handlers */ 82 | /* Add here the Interrupt Handlers for the used peripherals. */ 83 | /* For the available peripheral interrupt handler names, */ 84 | /* please refer to the startup file (startup_stm32f7xx.s). */ 85 | /******************************************************************************/ 86 | 87 | /* USER CODE BEGIN 1 */ 88 | 89 | /* USER CODE END 1 */ 90 | -------------------------------------------------------------------------------- /04_advanced_zig_project/stm32_hal/Core/Src/syscalls.c: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file syscalls.c 4 | * @author Auto-generated by STM32CubeMX 5 | * @brief Minimal System calls file 6 | * 7 | * For more information about which c-functions 8 | * need which of these lowlevel functions 9 | * please consult the Newlib libc-manual 10 | ****************************************************************************** 11 | * @attention 12 | * 13 | * Copyright (c) 2020-2024 STMicroelectronics. 14 | * All rights reserved. 15 | * 16 | * This software is licensed under terms that can be found in the LICENSE file 17 | * in the root directory of this software component. 18 | * If no LICENSE file comes with this software, it is provided AS-IS. 19 | * 20 | ****************************************************************************** 21 | */ 22 | 23 | /* Includes */ 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | 33 | /* Variables */ 34 | extern int __io_putchar(int ch) __attribute__((weak)); 35 | extern int __io_getchar(void) __attribute__((weak)); 36 | 37 | char *__env[1] = {0}; 38 | char **environ = __env; 39 | 40 | /* Functions */ 41 | void initialise_monitor_handles() 42 | { 43 | } 44 | 45 | int _getpid(void) 46 | { 47 | return 1; 48 | } 49 | 50 | int _kill(int pid, int sig) 51 | { 52 | (void)pid; 53 | (void)sig; 54 | errno = EINVAL; 55 | return -1; 56 | } 57 | 58 | void _exit(int status) 59 | { 60 | _kill(status, -1); 61 | while (1) 62 | { 63 | } /* Make sure we hang here */ 64 | } 65 | 66 | __attribute__((weak)) int _read(int file, char *ptr, int len) 67 | { 68 | (void)file; 69 | int DataIdx; 70 | 71 | for (DataIdx = 0; DataIdx < len; DataIdx++) 72 | { 73 | *ptr++ = __io_getchar(); 74 | } 75 | 76 | return len; 77 | } 78 | 79 | __attribute__((weak)) int _write(int file, char *ptr, int len) 80 | { 81 | (void)file; 82 | int DataIdx; 83 | 84 | for (DataIdx = 0; DataIdx < len; DataIdx++) 85 | { 86 | __io_putchar(*ptr++); 87 | } 88 | return len; 89 | } 90 | 91 | int _close(int file) 92 | { 93 | (void)file; 94 | return -1; 95 | } 96 | 97 | int _fstat(int file, struct stat *st) 98 | { 99 | (void)file; 100 | st->st_mode = S_IFCHR; 101 | return 0; 102 | } 103 | 104 | int _isatty(int file) 105 | { 106 | (void)file; 107 | return 1; 108 | } 109 | 110 | int _lseek(int file, int ptr, int dir) 111 | { 112 | (void)file; 113 | (void)ptr; 114 | (void)dir; 115 | return 0; 116 | } 117 | 118 | int _open(char *path, int flags, ...) 119 | { 120 | (void)path; 121 | (void)flags; 122 | /* Pretend like we always fail */ 123 | return -1; 124 | } 125 | 126 | int _wait(int *status) 127 | { 128 | (void)status; 129 | errno = ECHILD; 130 | return -1; 131 | } 132 | 133 | int _unlink(char *name) 134 | { 135 | (void)name; 136 | errno = ENOENT; 137 | return -1; 138 | } 139 | 140 | int _times(struct tms *buf) 141 | { 142 | (void)buf; 143 | return -1; 144 | } 145 | 146 | int _stat(char *file, struct stat *st) 147 | { 148 | (void)file; 149 | st->st_mode = S_IFCHR; 150 | return 0; 151 | } 152 | 153 | int _link(char *old, char *new) 154 | { 155 | (void)old; 156 | (void)new; 157 | errno = EMLINK; 158 | return -1; 159 | } 160 | 161 | int _fork(void) 162 | { 163 | errno = EAGAIN; 164 | return -1; 165 | } 166 | 167 | int _execve(char *name, char **argv, char **env) 168 | { 169 | (void)name; 170 | (void)argv; 171 | (void)env; 172 | errno = ENOMEM; 173 | return -1; 174 | } 175 | -------------------------------------------------------------------------------- /04_advanced_zig_project/stm32_hal/Core/Src/sysmem.c: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file sysmem.c 4 | * @author Generated by STM32CubeMX 5 | * @brief System Memory calls file 6 | * 7 | * For more information about which C functions 8 | * need which of these lowlevel functions 9 | * please consult the newlib libc manual 10 | ****************************************************************************** 11 | * @attention 12 | * 13 | * Copyright (c) 2024 STMicroelectronics. 14 | * All rights reserved. 15 | * 16 | * This software is licensed under terms that can be found in the LICENSE file 17 | * in the root directory of this software component. 18 | * If no LICENSE file comes with this software, it is provided AS-IS. 19 | * 20 | ****************************************************************************** 21 | */ 22 | 23 | /* Includes */ 24 | #include 25 | #include 26 | 27 | /** 28 | * Pointer to the current high watermark of the heap usage 29 | */ 30 | static uint8_t *__sbrk_heap_end = NULL; 31 | 32 | /** 33 | * @brief _sbrk() allocates memory to the newlib heap and is used by malloc 34 | * and others from the C library 35 | * 36 | * @verbatim 37 | * ############################################################################ 38 | * # .data # .bss # newlib heap # MSP stack # 39 | * # # # # Reserved by _Min_Stack_Size # 40 | * ############################################################################ 41 | * ^-- RAM start ^-- _end _estack, RAM end --^ 42 | * @endverbatim 43 | * 44 | * This implementation starts allocating at the '_end' linker symbol 45 | * The '_Min_Stack_Size' linker symbol reserves a memory for the MSP stack 46 | * The implementation considers '_estack' linker symbol to be RAM end 47 | * NOTE: If the MSP stack, at any point during execution, grows larger than the 48 | * reserved size, please increase the '_Min_Stack_Size'. 49 | * 50 | * @param incr Memory size 51 | * @return Pointer to allocated memory 52 | */ 53 | void *_sbrk(ptrdiff_t incr) 54 | { 55 | extern uint8_t _end; /* Symbol defined in the linker script */ 56 | extern uint8_t _estack; /* Symbol defined in the linker script */ 57 | extern uint32_t _Min_Stack_Size; /* Symbol defined in the linker script */ 58 | const uint32_t stack_limit = (uint32_t)&_estack - (uint32_t)&_Min_Stack_Size; 59 | const uint8_t *max_heap = (uint8_t *)stack_limit; 60 | uint8_t *prev_heap_end; 61 | 62 | /* Initialize heap end at first call */ 63 | if (NULL == __sbrk_heap_end) 64 | { 65 | __sbrk_heap_end = &_end; 66 | } 67 | 68 | /* Protect heap from growing into the reserved MSP stack */ 69 | if (__sbrk_heap_end + incr > max_heap) 70 | { 71 | errno = ENOMEM; 72 | return (void *)-1; 73 | } 74 | 75 | prev_heap_end = __sbrk_heap_end; 76 | __sbrk_heap_end += incr; 77 | 78 | return (void *)prev_heap_end; 79 | } 80 | -------------------------------------------------------------------------------- /04_advanced_zig_project/stm32_hal/Drivers/CMSIS/Device/ST/STM32F7xx/Include/system_stm32f7xx.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file system_stm32f7xx.h 4 | * @author MCD Application Team 5 | * @brief CMSIS Cortex-M7 Device System Source File for STM32F7xx devices. 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | * Copyright (c) 2016 STMicroelectronics. 10 | * All rights reserved. 11 | * 12 | * This software is licensed under terms that can be found in the LICENSE file 13 | * in the root directory of this software component. 14 | * If no LICENSE file comes with this software, it is provided AS-IS. 15 | * 16 | ****************************************************************************** 17 | */ 18 | 19 | /** @addtogroup CMSIS 20 | * @{ 21 | */ 22 | 23 | /** @addtogroup stm32f7xx_system 24 | * @{ 25 | */ 26 | 27 | /** 28 | * @brief Define to prevent recursive inclusion 29 | */ 30 | #ifndef __SYSTEM_STM32F7XX_H 31 | #define __SYSTEM_STM32F7XX_H 32 | 33 | #ifdef __cplusplus 34 | extern "C" { 35 | #endif 36 | 37 | /** @addtogroup STM32F7xx_System_Includes 38 | * @{ 39 | */ 40 | 41 | /** 42 | * @} 43 | */ 44 | 45 | 46 | /** @addtogroup STM32F7xx_System_Exported_Variables 47 | * @{ 48 | */ 49 | /* The SystemCoreClock variable is updated in three ways: 50 | 1) by calling CMSIS function SystemCoreClockUpdate() 51 | 2) by calling HAL API function HAL_RCC_GetSysClockFreq() 52 | 3) each time HAL_RCC_ClockConfig() is called to configure the system clock frequency 53 | Note: If you use this function to configure the system clock; then there 54 | is no need to call the 2 first functions listed above, since SystemCoreClock 55 | variable is updated automatically. 56 | */ 57 | extern uint32_t SystemCoreClock; /*!< System Clock Frequency (Core Clock) */ 58 | 59 | extern const uint8_t AHBPrescTable[16]; /*!< AHB prescalers table values */ 60 | extern const uint8_t APBPrescTable[8]; /*!< APB prescalers table values */ 61 | 62 | 63 | /** 64 | * @} 65 | */ 66 | 67 | /** @addtogroup STM32F7xx_System_Exported_Constants 68 | * @{ 69 | */ 70 | 71 | /** 72 | * @} 73 | */ 74 | 75 | /** @addtogroup STM32F7xx_System_Exported_Macros 76 | * @{ 77 | */ 78 | 79 | /** 80 | * @} 81 | */ 82 | 83 | /** @addtogroup STM32F7xx_System_Exported_Functions 84 | * @{ 85 | */ 86 | 87 | extern void SystemInit(void); 88 | extern void SystemCoreClockUpdate(void); 89 | /** 90 | * @} 91 | */ 92 | 93 | #ifdef __cplusplus 94 | } 95 | #endif 96 | 97 | #endif /*__SYSTEM_STM32F7XX_H */ 98 | 99 | /** 100 | * @} 101 | */ 102 | 103 | /** 104 | * @} 105 | */ 106 | -------------------------------------------------------------------------------- /04_advanced_zig_project/stm32_hal/Drivers/CMSIS/Device/ST/STM32F7xx/LICENSE.txt: -------------------------------------------------------------------------------- 1 | This software component is provided to you as part of a software package and 2 | applicable license terms are in the Package_license file. If you received this 3 | software component outside of a package or without applicable license terms, 4 | the terms of the Apache-2.0 license shall apply. 5 | You may obtain a copy of the Apache-2.0 at: 6 | https://opensource.org/licenses/Apache-2.0 7 | -------------------------------------------------------------------------------- /04_advanced_zig_project/stm32_hal/Drivers/CMSIS/Include/cmsis_version.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************//** 2 | * @file cmsis_version.h 3 | * @brief CMSIS Core(M) Version definitions 4 | * @version V5.0.2 5 | * @date 19. April 2017 6 | ******************************************************************************/ 7 | /* 8 | * Copyright (c) 2009-2017 ARM Limited. All rights reserved. 9 | * 10 | * SPDX-License-Identifier: Apache-2.0 11 | * 12 | * Licensed under the Apache License, Version 2.0 (the License); you may 13 | * not use this file except in compliance with the License. 14 | * You may obtain a copy of the License at 15 | * 16 | * www.apache.org/licenses/LICENSE-2.0 17 | * 18 | * Unless required by applicable law or agreed to in writing, software 19 | * distributed under the License is distributed on an AS IS BASIS, WITHOUT 20 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 21 | * See the License for the specific language governing permissions and 22 | * limitations under the License. 23 | */ 24 | 25 | #if defined ( __ICCARM__ ) 26 | #pragma system_include /* treat file as system include file for MISRA check */ 27 | #elif defined (__clang__) 28 | #pragma clang system_header /* treat file as system include file */ 29 | #endif 30 | 31 | #ifndef __CMSIS_VERSION_H 32 | #define __CMSIS_VERSION_H 33 | 34 | /* CMSIS Version definitions */ 35 | #define __CM_CMSIS_VERSION_MAIN ( 5U) /*!< [31:16] CMSIS Core(M) main version */ 36 | #define __CM_CMSIS_VERSION_SUB ( 1U) /*!< [15:0] CMSIS Core(M) sub version */ 37 | #define __CM_CMSIS_VERSION ((__CM_CMSIS_VERSION_MAIN << 16U) | \ 38 | __CM_CMSIS_VERSION_SUB ) /*!< CMSIS Core(M) version number */ 39 | #endif 40 | -------------------------------------------------------------------------------- /04_advanced_zig_project/stm32_hal/Drivers/CMSIS/Include/tz_context.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * @file tz_context.h 3 | * @brief Context Management for Armv8-M TrustZone 4 | * @version V1.0.1 5 | * @date 10. January 2018 6 | ******************************************************************************/ 7 | /* 8 | * Copyright (c) 2017-2018 Arm Limited. All rights reserved. 9 | * 10 | * SPDX-License-Identifier: Apache-2.0 11 | * 12 | * Licensed under the Apache License, Version 2.0 (the License); you may 13 | * not use this file except in compliance with the License. 14 | * You may obtain a copy of the License at 15 | * 16 | * www.apache.org/licenses/LICENSE-2.0 17 | * 18 | * Unless required by applicable law or agreed to in writing, software 19 | * distributed under the License is distributed on an AS IS BASIS, WITHOUT 20 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 21 | * See the License for the specific language governing permissions and 22 | * limitations under the License. 23 | */ 24 | 25 | #if defined ( __ICCARM__ ) 26 | #pragma system_include /* treat file as system include file for MISRA check */ 27 | #elif defined (__clang__) 28 | #pragma clang system_header /* treat file as system include file */ 29 | #endif 30 | 31 | #ifndef TZ_CONTEXT_H 32 | #define TZ_CONTEXT_H 33 | 34 | #include 35 | 36 | #ifndef TZ_MODULEID_T 37 | #define TZ_MODULEID_T 38 | /// \details Data type that identifies secure software modules called by a process. 39 | typedef uint32_t TZ_ModuleId_t; 40 | #endif 41 | 42 | /// \details TZ Memory ID identifies an allocated memory slot. 43 | typedef uint32_t TZ_MemoryId_t; 44 | 45 | /// Initialize secure context memory system 46 | /// \return execution status (1: success, 0: error) 47 | uint32_t TZ_InitContextSystem_S (void); 48 | 49 | /// Allocate context memory for calling secure software modules in TrustZone 50 | /// \param[in] module identifies software modules called from non-secure mode 51 | /// \return value != 0 id TrustZone memory slot identifier 52 | /// \return value 0 no memory available or internal error 53 | TZ_MemoryId_t TZ_AllocModuleContext_S (TZ_ModuleId_t module); 54 | 55 | /// Free context memory that was previously allocated with \ref TZ_AllocModuleContext_S 56 | /// \param[in] id TrustZone memory slot identifier 57 | /// \return execution status (1: success, 0: error) 58 | uint32_t TZ_FreeModuleContext_S (TZ_MemoryId_t id); 59 | 60 | /// Load secure context (called on RTOS thread context switch) 61 | /// \param[in] id TrustZone memory slot identifier 62 | /// \return execution status (1: success, 0: error) 63 | uint32_t TZ_LoadContext_S (TZ_MemoryId_t id); 64 | 65 | /// Store secure context (called on RTOS thread context switch) 66 | /// \param[in] id TrustZone memory slot identifier 67 | /// \return execution status (1: success, 0: error) 68 | uint32_t TZ_StoreContext_S (TZ_MemoryId_t id); 69 | 70 | #endif // TZ_CONTEXT_H 71 | -------------------------------------------------------------------------------- /04_advanced_zig_project/stm32_hal/Drivers/STM32F7xx_HAL_Driver/Inc/stm32f7xx_hal_dma_ex.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f7xx_hal_dma_ex.h 4 | * @author MCD Application Team 5 | * @brief Header file of DMA HAL extension module. 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | * Copyright (c) 2017 STMicroelectronics. 10 | * All rights reserved. 11 | * 12 | * This software is licensed under terms that can be found in the LICENSE file in 13 | * the root directory of this software component. 14 | * If no LICENSE file comes with this software, it is provided AS-IS. 15 | * 16 | ****************************************************************************** 17 | */ 18 | 19 | /* Define to prevent recursive inclusion -------------------------------------*/ 20 | #ifndef __STM32F7xx_HAL_DMA_EX_H 21 | #define __STM32F7xx_HAL_DMA_EX_H 22 | 23 | #ifdef __cplusplus 24 | extern "C" { 25 | #endif 26 | 27 | /* Includes ------------------------------------------------------------------*/ 28 | #include "stm32f7xx_hal_def.h" 29 | 30 | /** @addtogroup STM32F7xx_HAL_Driver 31 | * @{ 32 | */ 33 | 34 | /** @addtogroup DMAEx 35 | * @{ 36 | */ 37 | 38 | /* Exported types ------------------------------------------------------------*/ 39 | /** @defgroup DMAEx_Exported_Types DMAEx Exported Types 40 | * @brief DMAEx Exported types 41 | * @{ 42 | */ 43 | 44 | /** 45 | * @brief HAL DMA Memory definition 46 | */ 47 | typedef enum 48 | { 49 | MEMORY0 = 0x00U, /*!< Memory 0 */ 50 | MEMORY1 = 0x01U, /*!< Memory 1 */ 51 | 52 | }HAL_DMA_MemoryTypeDef; 53 | 54 | /** 55 | * @} 56 | */ 57 | 58 | /* Exported constants --------------------------------------------------------*/ 59 | 60 | /** @defgroup DMA_Exported_Constants DMA Exported Constants 61 | * @brief DMA Exported constants 62 | * @{ 63 | */ 64 | 65 | /** @defgroup DMAEx_Channel_selection DMA Channel selection 66 | * @brief DMAEx channel selection 67 | * @{ 68 | */ 69 | #define DMA_CHANNEL_0 0x00000000U /*!< DMA Channel 0 */ 70 | #define DMA_CHANNEL_1 0x02000000U /*!< DMA Channel 1 */ 71 | #define DMA_CHANNEL_2 0x04000000U /*!< DMA Channel 2 */ 72 | #define DMA_CHANNEL_3 0x06000000U /*!< DMA Channel 3 */ 73 | #define DMA_CHANNEL_4 0x08000000U /*!< DMA Channel 4 */ 74 | #define DMA_CHANNEL_5 0x0A000000U /*!< DMA Channel 5 */ 75 | #define DMA_CHANNEL_6 0x0C000000U /*!< DMA Channel 6 */ 76 | #define DMA_CHANNEL_7 0x0E000000U /*!< DMA Channel 7 */ 77 | #if defined (STM32F722xx) || defined (STM32F723xx) || defined (STM32F732xx) || defined (STM32F733xx) ||\ 78 | defined (STM32F765xx) || defined (STM32F767xx) || defined (STM32F769xx) || defined (STM32F777xx) ||\ 79 | defined (STM32F779xx) || defined (STM32F730xx) 80 | #define DMA_CHANNEL_8 0x10000000U /*!< DMA Channel 8 */ 81 | #define DMA_CHANNEL_9 0x12000000U /*!< DMA Channel 9 */ 82 | #define DMA_CHANNEL_10 0x14000000U /*!< DMA Channel 10*/ 83 | #define DMA_CHANNEL_11 0x16000000U /*!< DMA Channel 11*/ 84 | #define DMA_CHANNEL_12 0x18000000U /*!< DMA Channel 12*/ 85 | #define DMA_CHANNEL_13 0x1A000000U /*!< DMA Channel 13*/ 86 | #define DMA_CHANNEL_14 0x1C000000U /*!< DMA Channel 14*/ 87 | #define DMA_CHANNEL_15 0x1E000000U /*!< DMA Channel 15*/ 88 | #endif /* STM32F722xx || STM32F723xx || STM32F732xx || STM32F733xx || STM32F765xx || STM32F767xx || 89 | STM32F769xx || STM32F777xx || STM32F779xx || STM32F730xx */ 90 | 91 | /** 92 | * @} 93 | */ 94 | 95 | /** 96 | * @} 97 | */ 98 | 99 | /* Exported functions --------------------------------------------------------*/ 100 | /** @defgroup DMAEx_Exported_Functions DMAEx Exported Functions 101 | * @brief DMAEx Exported functions 102 | * @{ 103 | */ 104 | 105 | /** @defgroup DMAEx_Exported_Functions_Group1 Extended features functions 106 | * @brief Extended features functions 107 | * @{ 108 | */ 109 | 110 | /* IO operation functions *******************************************************/ 111 | HAL_StatusTypeDef HAL_DMAEx_MultiBufferStart(DMA_HandleTypeDef *hdma, uint32_t SrcAddress, uint32_t DstAddress, uint32_t SecondMemAddress, uint32_t DataLength); 112 | HAL_StatusTypeDef HAL_DMAEx_MultiBufferStart_IT(DMA_HandleTypeDef *hdma, uint32_t SrcAddress, uint32_t DstAddress, uint32_t SecondMemAddress, uint32_t DataLength); 113 | HAL_StatusTypeDef HAL_DMAEx_ChangeMemory(DMA_HandleTypeDef *hdma, uint32_t Address, HAL_DMA_MemoryTypeDef memory); 114 | 115 | /** 116 | * @} 117 | */ 118 | /** 119 | * @} 120 | */ 121 | 122 | /* Private macros ------------------------------------------------------------*/ 123 | /** @defgroup DMAEx_Private_Macros DMA Private Macros 124 | * @brief DMAEx private macros 125 | * @{ 126 | */ 127 | #if defined (STM32F722xx) || defined (STM32F723xx) || defined (STM32F732xx) || defined (STM32F733xx) ||\ 128 | defined (STM32F765xx) || defined (STM32F767xx) || defined (STM32F769xx) || defined (STM32F777xx) ||\ 129 | defined (STM32F779xx) || defined (STM32F730xx) 130 | #define IS_DMA_CHANNEL(CHANNEL) (((CHANNEL) == DMA_CHANNEL_0) || \ 131 | ((CHANNEL) == DMA_CHANNEL_1) || \ 132 | ((CHANNEL) == DMA_CHANNEL_2) || \ 133 | ((CHANNEL) == DMA_CHANNEL_3) || \ 134 | ((CHANNEL) == DMA_CHANNEL_4) || \ 135 | ((CHANNEL) == DMA_CHANNEL_5) || \ 136 | ((CHANNEL) == DMA_CHANNEL_6) || \ 137 | ((CHANNEL) == DMA_CHANNEL_7) || \ 138 | ((CHANNEL) == DMA_CHANNEL_8) || \ 139 | ((CHANNEL) == DMA_CHANNEL_9) || \ 140 | ((CHANNEL) == DMA_CHANNEL_10) || \ 141 | ((CHANNEL) == DMA_CHANNEL_11) || \ 142 | ((CHANNEL) == DMA_CHANNEL_12) || \ 143 | ((CHANNEL) == DMA_CHANNEL_13) || \ 144 | ((CHANNEL) == DMA_CHANNEL_14) || \ 145 | ((CHANNEL) == DMA_CHANNEL_15)) 146 | #else 147 | #define IS_DMA_CHANNEL(CHANNEL) (((CHANNEL) == DMA_CHANNEL_0) || \ 148 | ((CHANNEL) == DMA_CHANNEL_1) || \ 149 | ((CHANNEL) == DMA_CHANNEL_2) || \ 150 | ((CHANNEL) == DMA_CHANNEL_3) || \ 151 | ((CHANNEL) == DMA_CHANNEL_4) || \ 152 | ((CHANNEL) == DMA_CHANNEL_5) || \ 153 | ((CHANNEL) == DMA_CHANNEL_6) || \ 154 | ((CHANNEL) == DMA_CHANNEL_7)) 155 | #endif /* STM32F722xx || STM32F723xx || STM32F732xx || STM32F733xx || STM32F765xx || STM32F767xx || 156 | STM32F769xx || STM32F777xx || STM32F779xx || STM32F730xx*/ 157 | /** 158 | * @} 159 | */ 160 | 161 | /* Private functions ---------------------------------------------------------*/ 162 | /** @defgroup DMAEx_Private_Functions DMAEx Private Functions 163 | * @brief DMAEx Private functions 164 | * @{ 165 | */ 166 | /** 167 | * @} 168 | */ 169 | 170 | /** 171 | * @} 172 | */ 173 | 174 | /** 175 | * @} 176 | */ 177 | 178 | #ifdef __cplusplus 179 | } 180 | #endif 181 | 182 | #endif /* __STM32F7xx_HAL_DMA_H */ 183 | 184 | -------------------------------------------------------------------------------- /04_advanced_zig_project/stm32_hal/Drivers/STM32F7xx_HAL_Driver/LICENSE.txt: -------------------------------------------------------------------------------- 1 | This software component is provided to you as part of a software package and 2 | applicable license terms are in the Package_license file. If you received this 3 | software component outside of a package or without applicable license terms, 4 | the terms of the BSD-3-Clause license shall apply. 5 | You may obtain a copy of the BSD-3-Clause at: 6 | https://opensource.org/licenses/BSD-3-Clause 7 | -------------------------------------------------------------------------------- /04_advanced_zig_project/stm32_hal/STM32F750N8Hx_FLASH.ld: -------------------------------------------------------------------------------- 1 | /* 2 | ****************************************************************************** 3 | ** 4 | 5 | ** File : LinkerScript.ld 6 | ** 7 | ** Author : STM32CubeMX 8 | ** 9 | ** Abstract : Linker script for STM32F750N8Hx series 10 | ** 64Kbytes FLASH and 320Kbytes RAM 11 | ** 12 | ** Set heap size, stack size and stack location according 13 | ** to application requirements. 14 | ** 15 | ** Set memory bank area and size if external memory is used. 16 | ** 17 | ** Target : STMicroelectronics STM32 18 | ** 19 | ** Distribution: The file is distributed “as is,” without any warranty 20 | ** of any kind. 21 | ** 22 | ***************************************************************************** 23 | ** @attention 24 | ** 25 | **

© COPYRIGHT(c) 2019 STMicroelectronics

26 | ** 27 | ** Redistribution and use in source and binary forms, with or without modification, 28 | ** are permitted provided that the following conditions are met: 29 | ** 1. Redistributions of source code must retain the above copyright notice, 30 | ** this list of conditions and the following disclaimer. 31 | ** 2. Redistributions in binary form must reproduce the above copyright notice, 32 | ** this list of conditions and the following disclaimer in the documentation 33 | ** and/or other materials provided with the distribution. 34 | ** 3. Neither the name of STMicroelectronics nor the names of its contributors 35 | ** may be used to endorse or promote products derived from this software 36 | ** without specific prior written permission. 37 | ** 38 | ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 39 | ** AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 40 | ** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 41 | ** DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 42 | ** FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 43 | ** DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 44 | ** SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 45 | ** CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 46 | ** OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 47 | ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 48 | ** 49 | ***************************************************************************** 50 | */ 51 | 52 | /* Entry Point */ 53 | ENTRY(Reset_Handler) 54 | 55 | /* Specify the memory areas */ 56 | MEMORY 57 | { 58 | RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 320K 59 | FLASH (rx) : ORIGIN = 0x8000000, LENGTH = 64K 60 | } 61 | 62 | /* Highest address of the user mode stack */ 63 | _estack = ORIGIN(RAM) + LENGTH(RAM); /* end of RAM */ 64 | /* Generate a link error if heap and stack don't fit into RAM */ 65 | _Min_Heap_Size = 0x200; /* required amount of heap */ 66 | _Min_Stack_Size = 0x400; /* required amount of stack */ 67 | 68 | /* Define output sections */ 69 | SECTIONS 70 | { 71 | /* The startup code goes first into FLASH */ 72 | .isr_vector : 73 | { 74 | . = ALIGN(4); 75 | KEEP(*(.isr_vector)) /* Startup code */ 76 | . = ALIGN(4); 77 | } >FLASH 78 | 79 | /* The program code and other data goes into FLASH */ 80 | .text : 81 | { 82 | . = ALIGN(4); 83 | *(.text) /* .text sections (code) */ 84 | *(.text*) /* .text* sections (code) */ 85 | *(.glue_7) /* glue arm to thumb code */ 86 | *(.glue_7t) /* glue thumb to arm code */ 87 | *(.eh_frame) 88 | 89 | KEEP (*(.init)) 90 | KEEP (*(.fini)) 91 | 92 | . = ALIGN(4); 93 | _etext = .; /* define a global symbols at end of code */ 94 | } >FLASH 95 | 96 | /* Constant data goes into FLASH */ 97 | .rodata : 98 | { 99 | . = ALIGN(4); 100 | *(.rodata) /* .rodata sections (constants, strings, etc.) */ 101 | *(.rodata*) /* .rodata* sections (constants, strings, etc.) */ 102 | . = ALIGN(4); 103 | } >FLASH 104 | 105 | .ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) } >FLASH 106 | .ARM : { 107 | __exidx_start = .; 108 | *(.ARM.exidx*) 109 | __exidx_end = .; 110 | } >FLASH 111 | 112 | .preinit_array : 113 | { 114 | PROVIDE_HIDDEN (__preinit_array_start = .); 115 | KEEP (*(.preinit_array*)) 116 | PROVIDE_HIDDEN (__preinit_array_end = .); 117 | } >FLASH 118 | .init_array : 119 | { 120 | PROVIDE_HIDDEN (__init_array_start = .); 121 | KEEP (*(SORT(.init_array.*))) 122 | KEEP (*(.init_array*)) 123 | PROVIDE_HIDDEN (__init_array_end = .); 124 | } >FLASH 125 | .fini_array : 126 | { 127 | PROVIDE_HIDDEN (__fini_array_start = .); 128 | KEEP (*(SORT(.fini_array.*))) 129 | KEEP (*(.fini_array*)) 130 | PROVIDE_HIDDEN (__fini_array_end = .); 131 | } >FLASH 132 | 133 | /* used by the startup to initialize data */ 134 | _sidata = LOADADDR(.data); 135 | 136 | /* Initialized data sections goes into RAM, load LMA copy after code */ 137 | .data : 138 | { 139 | . = ALIGN(4); 140 | _sdata = .; /* create a global symbol at data start */ 141 | *(.data) /* .data sections */ 142 | *(.data*) /* .data* sections */ 143 | 144 | . = ALIGN(4); 145 | _edata = .; /* define a global symbol at data end */ 146 | } >RAM AT> FLASH 147 | 148 | 149 | /* Uninitialized data section */ 150 | . = ALIGN(4); 151 | .bss : 152 | { 153 | /* This is used by the startup in order to initialize the .bss secion */ 154 | _sbss = .; /* define a global symbol at bss start */ 155 | __bss_start__ = _sbss; 156 | *(.bss) 157 | *(.bss*) 158 | *(COMMON) 159 | 160 | . = ALIGN(4); 161 | _ebss = .; /* define a global symbol at bss end */ 162 | __bss_end__ = _ebss; 163 | } >RAM 164 | 165 | /* User_heap_stack section, used to check that there is enough RAM left */ 166 | ._user_heap_stack (NOLOAD) : 167 | { 168 | . = ALIGN(8); 169 | PROVIDE ( end = . ); 170 | PROVIDE ( _end = . ); 171 | . = . + _Min_Heap_Size; 172 | . = . + _Min_Stack_Size; 173 | . = ALIGN(8); 174 | } >RAM 175 | 176 | 177 | 178 | /* Remove information from the standard libraries */ 179 | /DISCARD/ : 180 | { 181 | libc.a ( * ) 182 | libm.a ( * ) 183 | libgcc.a ( * ) 184 | } 185 | 186 | .ARM.attributes 0 : { *(.ARM.attributes) } 187 | } 188 | 189 | 190 | -------------------------------------------------------------------------------- /04_advanced_zig_project/stm32_hal/build.zig: -------------------------------------------------------------------------------- 1 | const std = @import("std"); 2 | pub const newlib = @import("gatz").newlib; 3 | 4 | /// Add STM32 HAL sources/etc. as well as link in newlib 5 | /// 6 | /// Note: Assumes the path [project root]/stm32_hal for this module! 7 | pub fn addTo(b: *std.Build, executable: *std.Build.Step.Compile) void { 8 | 9 | // Includes 10 | const headers = .{ 11 | "stm32_hal/Core/Inc", 12 | "stm32_hal/Drivers/STM32F7xx_HAL_Driver/Inc", 13 | "stm32_hal/Drivers/STM32F7xx_HAL_Driver/Inc/Legacy", 14 | "stm32_hal/Drivers/CMSIS/Device/ST/STM32F7xx/Include", 15 | "stm32_hal/Drivers/CMSIS/Include", 16 | }; 17 | inline for (headers) |header| { 18 | executable.installHeadersDirectory(b.path(header), "", .{}); 19 | executable.addIncludePath(b.path(header)); 20 | } 21 | 22 | // Source files 23 | executable.addCSourceFiles(.{ 24 | .files = &.{ 25 | "stm32_hal/Core/Src/main.c", 26 | "stm32_hal/Core/Src/gpio.c", 27 | "stm32_hal/Core/Src/stm32f7xx_it.c", 28 | "stm32_hal/Core/Src/stm32f7xx_hal_msp.c", 29 | "stm32_hal/Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_cortex.c", 30 | "stm32_hal/Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_rcc.c", 31 | "stm32_hal/Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_rcc_ex.c", 32 | "stm32_hal/Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_flash.c", 33 | "stm32_hal/Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_flash_ex.c", 34 | "stm32_hal/Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_gpio.c", 35 | "stm32_hal/Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_dma.c", 36 | "stm32_hal/Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_dma_ex.c", 37 | "stm32_hal/Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_pwr.c", 38 | "stm32_hal/Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_pwr_ex.c", 39 | "stm32_hal/Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal.c", 40 | "stm32_hal/Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_i2c.c", 41 | "stm32_hal/Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_i2c_ex.c", 42 | "stm32_hal/Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_tim.c", 43 | "stm32_hal/Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_tim_ex.c", 44 | "stm32_hal/Core/Src/system_stm32f7xx.c", 45 | "stm32_hal/Core/Src/sysmem.c", 46 | "stm32_hal/Core/Src/syscalls.c", 47 | }, 48 | .flags = &.{"-std=c11"}, 49 | }); 50 | 51 | // Neccessary for HAL 52 | executable.defineCMacro("USE_HAL_DRIVER", null); 53 | executable.defineCMacro("STM32F750xx", null); 54 | 55 | // Startup file 56 | executable.addAssemblyFile(b.path("stm32_hal/startup_stm32f750xx.s")); 57 | 58 | // Linker Script 59 | executable.setLinkerScriptPath(b.path("stm32_hal/STM32F750N8Hx_FLASH.ld")); 60 | 61 | // Pull in Newlib with a utility 62 | const resolved_target_from_exe = executable.root_module.resolved_target.?; 63 | newlib.addTo(b, resolved_target_from_exe, executable) catch |err| switch (err) { 64 | newlib.Error.CompilerNotFound => { 65 | std.log.err("Couldn't find arm-none-eabi-gcc compiler!\n", .{}); 66 | unreachable; 67 | }, 68 | newlib.Error.IncompatibleCpu => { 69 | std.log.err("Cpu: {s} isn't supported by gatz!\n", .{resolved_target_from_exe.result.cpu.model.name}); 70 | unreachable; 71 | }, 72 | }; 73 | } 74 | -------------------------------------------------------------------------------- /04_advanced_zig_project/stm32_hal/build.zig.zon: -------------------------------------------------------------------------------- 1 | .{ 2 | .name = "stm32_hal", 3 | .version = "0.0.0", 4 | .dependencies = .{ 5 | .gatz = .{ 6 | .url = "git+https://github.com/haydenridd/gcc-arm-to-zig#ff5d2dfb03149981237a16d5e93b8c39224f318a", 7 | .hash = "122079adf4c3bf1082b907ea8438096c50c193fa3224ea590dd0c7d3eff1d405c3de", 8 | }, 9 | }, 10 | .paths = .{ 11 | "build.zig", 12 | "build.zig.zon", 13 | "Core", 14 | "Drivers", 15 | "startup_stm32f750xx.s", 16 | "STM32F750N8Hx_FLASH.ld", 17 | }, 18 | } 19 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Porting STM32CubeMX Projects to Zig 2 | 3 | This repo serves as a guide for porting existing STM32CubeMX projects to the Zig C/C++ compiler, unlocking the ability to mix C/C++ and Zig code in your project. 4 | It is intended to track major release versions of Zig, as Zig is still in development and subject to change. This repo is currently tracking Zig: 5 | 6 | `0.13.0` 7 | 8 | ## Project Setup 9 | 10 | STM32CubeMX, using the "Makefile" toolchain selection, was used to generate a very simple blinky program for the STM32F750N8 MCU. 11 | This MCU uses a Cortex M7, and supports hardware floating point operations. The program itself isn't the important part of this guide, 12 | rather following along with what needs to be modified/changed to get generated STM32CubeMX code to compile with Zig's C/C++ compiler. 13 | 14 | ## How to Use This Guide 15 | 16 | This repo contains four different "project" directories: 17 | - 1: [The baseline project generated by STM32CubeMX without modification](01_base_project/README.md) 18 | - 2: [Using zig as a drop in compiler replacement in a Makefile](02_drop_in_compiler/README.md) 19 | - 3: [Replacing the Makefile with a build.zig file to make use of Zig's build system](03_with_zig_build/README.md) 20 | - 4: [Using more advanced features of Zig's build system + integrating Zig code](04_advanced_zig_project/README.md) 21 | 22 | They are meant to be read in order, as the complexity builds with each example. 23 | 24 | ## Miscellaneous Notes + Thoughts 25 | - Zig emits to stderror when `blinky_exe.setVerboseLink(true);` is used, see [here](https://github.com/ziglang/zig/issues/19410) 26 | - When `blinky_exe.setVerboseLink(true);` is used, linker command appears to use "armelf_linux_eabi" as its triple which I've confirmed is "correct" but that triple is a bit of a misnomer given we are NOT compiling/linking for a linux system 27 | 28 | --------------------------------------------------------------------------------