├── .gitignore ├── README.md ├── STM32H723ZGTX_FLASH.ld ├── include ├── FreeRTOSConfig.h ├── README ├── main.h ├── stm32h7xx_hal_conf.h └── stm32h7xx_it.h ├── lib ├── FreeRTOS │ ├── CMSIS_RTOS_V2 │ │ ├── cmsis_os.h │ │ ├── cmsis_os2.c │ │ ├── cmsis_os2.h │ │ ├── freertos_mpool.h │ │ └── freertos_os2.h │ ├── croutine.c │ ├── event_groups.c │ ├── include │ │ ├── FreeRTOS.h │ │ ├── StackMacros.h │ │ ├── atomic.h │ │ ├── croutine.h │ │ ├── deprecated_definitions.h │ │ ├── event_groups.h │ │ ├── list.h │ │ ├── message_buffer.h │ │ ├── mpu_prototypes.h │ │ ├── mpu_wrappers.h │ │ ├── portable.h │ │ ├── projdefs.h │ │ ├── queue.h │ │ ├── semphr.h │ │ ├── stack_macros.h │ │ ├── stream_buffer.h │ │ ├── task.h │ │ └── timers.h │ ├── list.c │ ├── portable │ │ ├── GCC │ │ │ └── ARM_CM4F │ │ │ │ ├── port.c │ │ │ │ └── portmacro.h │ │ └── MemMang │ │ │ └── heap_4.c │ ├── queue.c │ ├── stream_buffer.c │ ├── tasks.c │ └── timers.c └── README ├── platformio.ini ├── reference_stm32cube_project ├── .cproject ├── .mxproject ├── .project ├── Core │ ├── Inc │ │ ├── FreeRTOSConfig.h │ │ ├── main.h │ │ ├── stm32h7xx_hal_conf.h │ │ └── stm32h7xx_it.h │ ├── Src │ │ ├── freertos.c │ │ ├── main.c │ │ ├── stm32h7xx_hal_msp.c │ │ ├── stm32h7xx_hal_timebase_tim.c │ │ ├── stm32h7xx_it.c │ │ ├── syscalls.c │ │ ├── sysmem.c │ │ └── system_stm32h7xx.c │ └── Startup │ │ └── startup_stm32h723zgtx.s ├── Drivers │ ├── CMSIS │ │ ├── Device │ │ │ └── ST │ │ │ │ └── STM32H7xx │ │ │ │ └── Include │ │ │ │ ├── stm32h723xx.h │ │ │ │ ├── stm32h7xx.h │ │ │ │ └── system_stm32h7xx.h │ │ └── Include │ │ │ ├── cmsis_armcc.h │ │ │ ├── cmsis_armclang.h │ │ │ ├── cmsis_armclang_ltm.h │ │ │ ├── cmsis_compiler.h │ │ │ ├── cmsis_gcc.h │ │ │ ├── cmsis_iccarm.h │ │ │ ├── cmsis_version.h │ │ │ ├── core_armv81mml.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_cm35p.h │ │ │ ├── core_cm4.h │ │ │ ├── core_cm7.h │ │ │ ├── core_sc000.h │ │ │ ├── core_sc300.h │ │ │ ├── mpu_armv7.h │ │ │ ├── mpu_armv8.h │ │ │ └── tz_context.h │ └── STM32H7xx_HAL_Driver │ │ ├── Inc │ │ ├── Legacy │ │ │ └── stm32_hal_legacy.h │ │ ├── stm32h7xx_hal.h │ │ ├── stm32h7xx_hal_cortex.h │ │ ├── stm32h7xx_hal_def.h │ │ ├── stm32h7xx_hal_dma.h │ │ ├── stm32h7xx_hal_dma_ex.h │ │ ├── stm32h7xx_hal_eth.h │ │ ├── stm32h7xx_hal_eth_ex.h │ │ ├── stm32h7xx_hal_exti.h │ │ ├── stm32h7xx_hal_flash.h │ │ ├── stm32h7xx_hal_flash_ex.h │ │ ├── stm32h7xx_hal_gpio.h │ │ ├── stm32h7xx_hal_gpio_ex.h │ │ ├── stm32h7xx_hal_hsem.h │ │ ├── stm32h7xx_hal_i2c.h │ │ ├── stm32h7xx_hal_i2c_ex.h │ │ ├── stm32h7xx_hal_mdma.h │ │ ├── stm32h7xx_hal_pwr.h │ │ ├── stm32h7xx_hal_pwr_ex.h │ │ ├── stm32h7xx_hal_rcc.h │ │ ├── stm32h7xx_hal_rcc_ex.h │ │ ├── stm32h7xx_hal_tim.h │ │ ├── stm32h7xx_hal_tim_ex.h │ │ ├── stm32h7xx_hal_uart.h │ │ └── stm32h7xx_hal_uart_ex.h │ │ └── Src │ │ ├── stm32h7xx_hal.c │ │ ├── stm32h7xx_hal_cortex.c │ │ ├── stm32h7xx_hal_dma.c │ │ ├── stm32h7xx_hal_dma_ex.c │ │ ├── stm32h7xx_hal_eth.c │ │ ├── stm32h7xx_hal_eth_ex.c │ │ ├── stm32h7xx_hal_exti.c │ │ ├── stm32h7xx_hal_flash.c │ │ ├── stm32h7xx_hal_flash_ex.c │ │ ├── stm32h7xx_hal_gpio.c │ │ ├── stm32h7xx_hal_hsem.c │ │ ├── stm32h7xx_hal_i2c.c │ │ ├── stm32h7xx_hal_i2c_ex.c │ │ ├── stm32h7xx_hal_mdma.c │ │ ├── stm32h7xx_hal_pwr.c │ │ ├── stm32h7xx_hal_pwr_ex.c │ │ ├── stm32h7xx_hal_rcc.c │ │ ├── stm32h7xx_hal_rcc_ex.c │ │ ├── stm32h7xx_hal_tim.c │ │ ├── stm32h7xx_hal_tim_ex.c │ │ ├── stm32h7xx_hal_uart.c │ │ └── stm32h7xx_hal_uart_ex.c ├── Middlewares │ └── Third_Party │ │ └── FreeRTOS │ │ └── Source │ │ ├── CMSIS_RTOS_V2 │ │ ├── cmsis_os.h │ │ ├── cmsis_os2.c │ │ ├── cmsis_os2.h │ │ ├── freertos_mpool.h │ │ └── freertos_os2.h │ │ ├── croutine.c │ │ ├── event_groups.c │ │ ├── include │ │ ├── FreeRTOS.h │ │ ├── StackMacros.h │ │ ├── atomic.h │ │ ├── croutine.h │ │ ├── deprecated_definitions.h │ │ ├── event_groups.h │ │ ├── list.h │ │ ├── message_buffer.h │ │ ├── mpu_prototypes.h │ │ ├── mpu_wrappers.h │ │ ├── portable.h │ │ ├── projdefs.h │ │ ├── queue.h │ │ ├── semphr.h │ │ ├── stack_macros.h │ │ ├── stream_buffer.h │ │ ├── task.h │ │ └── timers.h │ │ ├── list.c │ │ ├── portable │ │ ├── GCC │ │ │ └── ARM_CM4F │ │ │ │ ├── port.c │ │ │ │ └── portmacro.h │ │ └── MemMang │ │ │ └── heap_4.c │ │ ├── queue.c │ │ ├── stream_buffer.c │ │ ├── tasks.c │ │ └── timers.c ├── STM32H723ZGTX_FLASH.ld ├── STM32H723ZGTX_RAM.ld └── h7_freertos_stm32cube.ioc ├── src ├── freertos.c ├── main.c ├── stm32h7xx_hal_msp.c ├── stm32h7xx_hal_timebase_tim.c ├── stm32h7xx_it.c ├── syscalls.c ├── sysmem.c └── system_stm32h7xx.c └── test └── README /.gitignore: -------------------------------------------------------------------------------- 1 | .pio 2 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # PIO + STM32H7 STM32Cube FreeRTOS demo 2 | 3 | ## Description 4 | 5 | Shows how a auto-generated STM32CubeMX project can be converted to be compiled with PlatformIO 6 | 7 | ## STM32CubeMX configuration 8 | 9 | 1. Selected the **board** NUCLEO-H723ZG, initialize all peripherals in default mode 10 | 2. Activate Middleware -> FreeRTOS -> CMSIS_V2 11 | 3. Change SYS -> Timebase Source to "TIM2" (recommended since FreeRTOS uses SysTick) 12 | 4. Generate code for STM32CubeIDE, folder structure "advanced" 13 | 14 | ## PlatformIO conversion 15 | 16 | 1. Create blank PlatformIO project for NUCLEO-H723ZG 17 | 2. Copy `Core\Inc\*` from STM32Cube project to `include\*` 18 | 3. Copy `Core\Src\*` from STM32Cube project to `src\*` 19 | 4. Copy `Middlewares\Third_Party\FreeRTOS` folder into `lib` 20 | 5. Copy `STM32H723ZGTX_FLASH.ld` to the root of the PIO project 21 | 6. Adapt `platformio.ini` to the following 22 | 23 | ```ini 24 | [env:nucleo_h723zg] 25 | platform = ststm32 26 | board = nucleo_h723zg 27 | framework = stm32cube 28 | ; select linker file generated by CubeMX 29 | board_build.ldscript = STM32H723ZGTX_FLASH.ld 30 | ; make build system use our HAL config file 31 | board_build.stm32cube.custom_config_header = yes 32 | ; force inclusion of lib/FreeRTOS 33 | lib_deps = FreeRTOS 34 | ; needed compiler flags to 35 | ; correctly build the port assembly files 36 | ; and add freertos subfolders to include path 37 | build_flags = 38 | -mfpu=fpv4-sp-d16 39 | -mfloat-abi=softfp 40 | -Ilib/FreeRTOS/include 41 | -Ilib/FreeRTOS/CMSIS_RTOS_V2 42 | -Ilib/FreeRTOS/portable/GCC/ARM_CM4F 43 | -Iinclude 44 | ; link FreeRTOS as objectf files, not as 45 | ; archives. otherwise weak ISR functions 46 | ; don't get linked properly! 47 | lib_archive = no 48 | ; fix for RAM size / initial SP. 49 | ; see https://community.platformio.org/t/arm-versus-thumb/23540/ 50 | ; actually **not** needed because we have selected a fixed linkerfile!! 51 | ;board_upload.maximum_ram_size = 131072 52 | ``` 53 | 54 | Note: 55 | * This conversion process and the needed build flags are nothing new 56 | * outlined in many forum threads 57 | * automatic conversions tools like https://github.com/ussserrr/stm32pio exist that do the **exact same thing** 58 | * `board_build.stm32cube.custom_config_header` is needed, the default `stm32h7xx_hal_conf.h` supplied by PlatformIO declares a 25MHz HSE input frequency when the Nucleo board has a 8MHz one. Alternatively, add `-DHSE_VALUE=8000000UL` to the `build_flags`. 59 | * No need to copy `Core\Startup`, PlatforrmIO already has the startup file and compiles it in. 60 | * same goes for `Drivers\CMSIS` and `Drivers\STM32H7xx_HAL_Driver` 61 | 62 | -------------------------------------------------------------------------------- /STM32H723ZGTX_FLASH.ld: -------------------------------------------------------------------------------- 1 | /* 2 | ****************************************************************************** 3 | ** 4 | ** File : LinkerScript.ld 5 | ** 6 | ** Author : STM32CubeIDE 7 | ** 8 | ** Abstract : Linker script for STM32H7 series 9 | ** 1024Kbytes FLASH and 192Kbytes RAM 10 | ** 11 | ** Set heap size, stack size and stack location according 12 | ** to application requirements. 13 | ** 14 | ** Set memory bank area and size if external memory is used. 15 | ** 16 | ** Target : STMicroelectronics STM32 17 | ** 18 | ** Distribution: The file is distributed as is, without any warranty 19 | ** of any kind. 20 | ** 21 | ***************************************************************************** 22 | ** @attention 23 | ** 24 | ** Copyright (c) 2020 STMicroelectronics. 25 | ** All rights reserved. 26 | ** 27 | ** This software component is licensed by ST under BSD 3-Clause license, 28 | ** the "License"; You may not use this file except in compliance with the 29 | ** License. You may obtain a copy of the License at: 30 | ** opensource.org/licenses/BSD-3-Clause 31 | ** 32 | **************************************************************************** 33 | */ 34 | 35 | /* Entry Point */ 36 | ENTRY(Reset_Handler) 37 | 38 | /* Highest address of the user mode stack */ 39 | _estack = 0x20020000; /* end of RAM */ 40 | /* Generate a link error if heap and stack don't fit into RAM */ 41 | _Min_Heap_Size = 0x200 ; /* required amount of heap */ 42 | _Min_Stack_Size = 0x400 ; /* required amount of stack */ 43 | 44 | /* Specify the memory areas */ 45 | MEMORY 46 | { 47 | ITCMRAM (xrw) : ORIGIN = 0x00000000, LENGTH = 64K 48 | RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 128K 49 | FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 1024K 50 | RAM_D1 (xrw) : ORIGIN = 0x24000000, LENGTH = 320K 51 | RAM_D2 (xrw) : ORIGIN = 0x30000000, LENGTH = 32K 52 | RAM_D3 (xrw) : ORIGIN = 0x38000000, LENGTH = 16K 53 | } 54 | 55 | /* Define output sections */ 56 | SECTIONS 57 | { 58 | /* The startup code goes first into FLASH */ 59 | .isr_vector : 60 | { 61 | . = ALIGN(4); 62 | KEEP(*(.isr_vector)) /* Startup code */ 63 | . = ALIGN(4); 64 | } >FLASH 65 | 66 | /* The program code and other data goes into FLASH */ 67 | .text : 68 | { 69 | . = ALIGN(4); 70 | *(.text) /* .text sections (code) */ 71 | *(.text*) /* .text* sections (code) */ 72 | *(.glue_7) /* glue arm to thumb code */ 73 | *(.glue_7t) /* glue thumb to arm code */ 74 | *(.eh_frame) 75 | 76 | KEEP (*(.init)) 77 | KEEP (*(.fini)) 78 | 79 | . = ALIGN(4); 80 | _etext = .; /* define a global symbols at end of code */ 81 | } >FLASH 82 | 83 | /* Constant data goes into FLASH */ 84 | .rodata : 85 | { 86 | . = ALIGN(4); 87 | *(.rodata) /* .rodata sections (constants, strings, etc.) */ 88 | *(.rodata*) /* .rodata* sections (constants, strings, etc.) */ 89 | . = ALIGN(4); 90 | } >FLASH 91 | 92 | .ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) } >FLASH 93 | .ARM : { 94 | __exidx_start = .; 95 | *(.ARM.exidx*) 96 | __exidx_end = .; 97 | } >FLASH 98 | 99 | .preinit_array : 100 | { 101 | PROVIDE_HIDDEN (__preinit_array_start = .); 102 | KEEP (*(.preinit_array*)) 103 | PROVIDE_HIDDEN (__preinit_array_end = .); 104 | } >FLASH 105 | .init_array : 106 | { 107 | PROVIDE_HIDDEN (__init_array_start = .); 108 | KEEP (*(SORT(.init_array.*))) 109 | KEEP (*(.init_array*)) 110 | PROVIDE_HIDDEN (__init_array_end = .); 111 | } >FLASH 112 | .fini_array : 113 | { 114 | PROVIDE_HIDDEN (__fini_array_start = .); 115 | KEEP (*(SORT(.fini_array.*))) 116 | KEEP (*(.fini_array*)) 117 | PROVIDE_HIDDEN (__fini_array_end = .); 118 | } >FLASH 119 | 120 | /* used by the startup to initialize data */ 121 | _sidata = LOADADDR(.data); 122 | 123 | /* Initialized data sections goes into RAM, load LMA copy after code */ 124 | .data : 125 | { 126 | . = ALIGN(4); 127 | _sdata = .; /* create a global symbol at data start */ 128 | *(.data) /* .data sections */ 129 | *(.data*) /* .data* sections */ 130 | *(.RamFunc) /* .RamFunc sections */ 131 | *(.RamFunc*) /* .RamFunc* sections */ 132 | 133 | . = ALIGN(4); 134 | _edata = .; /* define a global symbol at data end */ 135 | } >RAM AT> FLASH 136 | 137 | /* Uninitialized data section */ 138 | . = ALIGN(4); 139 | .bss : 140 | { 141 | /* This is used by the startup in order to initialize the .bss secion */ 142 | _sbss = .; /* define a global symbol at bss start */ 143 | __bss_start__ = _sbss; 144 | *(.bss) 145 | *(.bss*) 146 | *(COMMON) 147 | 148 | . = ALIGN(4); 149 | _ebss = .; /* define a global symbol at bss end */ 150 | __bss_end__ = _ebss; 151 | } >RAM 152 | 153 | /* User_heap_stack section, used to check that there is enough RAM left */ 154 | ._user_heap_stack : 155 | { 156 | . = ALIGN(8); 157 | PROVIDE ( end = . ); 158 | PROVIDE ( _end = . ); 159 | . = . + _Min_Heap_Size; 160 | . = . + _Min_Stack_Size; 161 | . = ALIGN(8); 162 | } >RAM 163 | 164 | /* Remove information from the standard libraries */ 165 | /DISCARD/ : 166 | { 167 | libc.a ( * ) 168 | libm.a ( * ) 169 | libgcc.a ( * ) 170 | } 171 | 172 | .ARM.attributes 0 : { *(.ARM.attributes) } 173 | } 174 | -------------------------------------------------------------------------------- /include/FreeRTOSConfig.h: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /* 3 | * FreeRTOS Kernel V10.3.1 4 | * Portion Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. 5 | * Portion Copyright (C) 2019 StMicroelectronics, Inc. All Rights Reserved. 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a copy of 8 | * this software and associated documentation files (the "Software"), to deal in 9 | * the Software without restriction, including without limitation the rights to 10 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 11 | * the Software, and to permit persons to whom the Software is furnished to do so, 12 | * subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in all 15 | * copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 19 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 20 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 21 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 22 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | * 24 | * http://www.FreeRTOS.org 25 | * http://aws.amazon.com/freertos 26 | * 27 | * 1 tab == 4 spaces! 28 | */ 29 | /* USER CODE END Header */ 30 | 31 | #ifndef FREERTOS_CONFIG_H 32 | #define FREERTOS_CONFIG_H 33 | 34 | /*----------------------------------------------------------- 35 | * Application specific definitions. 36 | * 37 | * These definitions should be adjusted for your particular hardware and 38 | * application requirements. 39 | * 40 | * These parameters and more are described within the 'configuration' section of the 41 | * FreeRTOS API documentation available on the FreeRTOS.org web site. 42 | * 43 | * See http://www.freertos.org/a00110.html 44 | *----------------------------------------------------------*/ 45 | 46 | /* USER CODE BEGIN Includes */ 47 | /* Section where include file can be added */ 48 | /* USER CODE END Includes */ 49 | 50 | /* Ensure definitions are only used by the compiler, and not by the assembler. */ 51 | #if defined(__ICCARM__) || defined(__CC_ARM) || defined(__GNUC__) 52 | #include 53 | extern uint32_t SystemCoreClock; 54 | #endif 55 | #ifndef CMSIS_device_header 56 | #define CMSIS_device_header "stm32h7xx.h" 57 | #endif /* CMSIS_device_header */ 58 | 59 | #define configENABLE_FPU 0 60 | #define configENABLE_MPU 0 61 | 62 | #define configUSE_PREEMPTION 1 63 | #define configSUPPORT_STATIC_ALLOCATION 1 64 | #define configSUPPORT_DYNAMIC_ALLOCATION 1 65 | #define configUSE_IDLE_HOOK 0 66 | #define configUSE_TICK_HOOK 0 67 | #define configCPU_CLOCK_HZ ( SystemCoreClock ) 68 | #define configTICK_RATE_HZ ((TickType_t)1000) 69 | #define configMAX_PRIORITIES ( 56 ) 70 | #define configMINIMAL_STACK_SIZE ((uint16_t)128) 71 | #define configTOTAL_HEAP_SIZE ((size_t)15360) 72 | #define configMAX_TASK_NAME_LEN ( 16 ) 73 | #define configUSE_TRACE_FACILITY 1 74 | #define configUSE_16_BIT_TICKS 0 75 | #define configUSE_MUTEXES 1 76 | #define configQUEUE_REGISTRY_SIZE 8 77 | #define configUSE_RECURSIVE_MUTEXES 1 78 | #define configUSE_COUNTING_SEMAPHORES 1 79 | #define configUSE_PORT_OPTIMISED_TASK_SELECTION 0 80 | /* USER CODE BEGIN MESSAGE_BUFFER_LENGTH_TYPE */ 81 | /* Defaults to size_t for backward compatibility, but can be changed 82 | if lengths will always be less than the number of bytes in a size_t. */ 83 | #define configMESSAGE_BUFFER_LENGTH_TYPE size_t 84 | /* USER CODE END MESSAGE_BUFFER_LENGTH_TYPE */ 85 | 86 | /* Co-routine definitions. */ 87 | #define configUSE_CO_ROUTINES 0 88 | #define configMAX_CO_ROUTINE_PRIORITIES ( 2 ) 89 | 90 | /* Software timer definitions. */ 91 | #define configUSE_TIMERS 1 92 | #define configTIMER_TASK_PRIORITY ( 2 ) 93 | #define configTIMER_QUEUE_LENGTH 10 94 | #define configTIMER_TASK_STACK_DEPTH 256 95 | 96 | /* CMSIS-RTOS V2 flags */ 97 | #define configUSE_OS2_THREAD_SUSPEND_RESUME 1 98 | #define configUSE_OS2_THREAD_ENUMERATE 1 99 | #define configUSE_OS2_EVENTFLAGS_FROM_ISR 1 100 | #define configUSE_OS2_THREAD_FLAGS 1 101 | #define configUSE_OS2_TIMER 1 102 | #define configUSE_OS2_MUTEX 1 103 | 104 | /* Set the following definitions to 1 to include the API function, or zero 105 | to exclude the API function. */ 106 | #define INCLUDE_vTaskPrioritySet 1 107 | #define INCLUDE_uxTaskPriorityGet 1 108 | #define INCLUDE_vTaskDelete 1 109 | #define INCLUDE_vTaskCleanUpResources 0 110 | #define INCLUDE_vTaskSuspend 1 111 | #define INCLUDE_vTaskDelayUntil 1 112 | #define INCLUDE_vTaskDelay 1 113 | #define INCLUDE_xTaskGetSchedulerState 1 114 | #define INCLUDE_xTimerPendFunctionCall 1 115 | #define INCLUDE_xQueueGetMutexHolder 1 116 | #define INCLUDE_uxTaskGetStackHighWaterMark 1 117 | #define INCLUDE_xTaskGetCurrentTaskHandle 1 118 | #define INCLUDE_eTaskGetState 1 119 | 120 | /* 121 | * The CMSIS-RTOS V2 FreeRTOS wrapper is dependent on the heap implementation used 122 | * by the application thus the correct define need to be enabled below 123 | */ 124 | #define USE_FreeRTOS_HEAP_4 125 | 126 | /* Cortex-M specific definitions. */ 127 | #ifdef __NVIC_PRIO_BITS 128 | /* __BVIC_PRIO_BITS will be specified when CMSIS is being used. */ 129 | #define configPRIO_BITS __NVIC_PRIO_BITS 130 | #else 131 | #define configPRIO_BITS 4 132 | #endif 133 | 134 | /* The lowest interrupt priority that can be used in a call to a "set priority" 135 | function. */ 136 | #define configLIBRARY_LOWEST_INTERRUPT_PRIORITY 15 137 | 138 | /* The highest interrupt priority that can be used by any interrupt service 139 | routine that makes calls to interrupt safe FreeRTOS API functions. DO NOT CALL 140 | INTERRUPT SAFE FREERTOS API FUNCTIONS FROM ANY INTERRUPT THAT HAS A HIGHER 141 | PRIORITY THAN THIS! (higher priorities are lower numeric values. */ 142 | #define configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY 5 143 | 144 | /* Interrupt priorities used by the kernel port layer itself. These are generic 145 | to all Cortex-M ports, and do not rely on any particular library functions. */ 146 | #define configKERNEL_INTERRUPT_PRIORITY ( configLIBRARY_LOWEST_INTERRUPT_PRIORITY << (8 - configPRIO_BITS) ) 147 | /* !!!! configMAX_SYSCALL_INTERRUPT_PRIORITY must not be set to zero !!!! 148 | See http://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html. */ 149 | #define configMAX_SYSCALL_INTERRUPT_PRIORITY ( configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY << (8 - configPRIO_BITS) ) 150 | 151 | /* Normal assert() semantics without relying on the provision of an assert.h 152 | header file. */ 153 | /* USER CODE BEGIN 1 */ 154 | #define configASSERT( x ) if ((x) == 0) {taskDISABLE_INTERRUPTS(); for( ;; );} 155 | /* USER CODE END 1 */ 156 | 157 | /* Definitions that map the FreeRTOS port interrupt handlers to their CMSIS 158 | standard names. */ 159 | #define vPortSVCHandler SVC_Handler 160 | #define xPortPendSVHandler PendSV_Handler 161 | 162 | /* IMPORTANT: After 10.3.1 update, Systick_Handler comes from NVIC (if SYS timebase = systick), otherwise from cmsis_os2.c */ 163 | 164 | #define USE_CUSTOM_SYSTICK_HANDLER_IMPLEMENTATION 0 165 | 166 | /* USER CODE BEGIN Defines */ 167 | /* Section where parameter definitions can be added (for instance, to override default ones in FreeRTOS.h) */ 168 | /* USER CODE END Defines */ 169 | 170 | #endif /* FREERTOS_CONFIG_H */ 171 | -------------------------------------------------------------------------------- /include/README: -------------------------------------------------------------------------------- 1 | 2 | This directory is intended for project header files. 3 | 4 | A header file is a file containing C declarations and macro definitions 5 | to be shared between several project source files. You request the use of a 6 | header file in your project source file (C, C++, etc) located in `src` folder 7 | by including it, with the C preprocessing directive `#include'. 8 | 9 | ```src/main.c 10 | 11 | #include "header.h" 12 | 13 | int main (void) 14 | { 15 | ... 16 | } 17 | ``` 18 | 19 | Including a header file produces the same results as copying the header file 20 | into each source file that needs it. Such copying would be time-consuming 21 | and error-prone. With a header file, the related declarations appear 22 | in only one place. If they need to be changed, they can be changed in one 23 | place, and programs that include the header file will automatically use the 24 | new version when next recompiled. The header file eliminates the labor of 25 | finding and changing all the copies as well as the risk that a failure to 26 | find one copy will result in inconsistencies within a program. 27 | 28 | In C, the usual convention is to give header files names that end with `.h'. 29 | It is most portable to use only letters, digits, dashes, and underscores in 30 | header file names, and at most one dot. 31 | 32 | Read more about using header files in official GCC documentation: 33 | 34 | * Include Syntax 35 | * Include Operation 36 | * Once-Only Headers 37 | * Computed Includes 38 | 39 | https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html 40 | -------------------------------------------------------------------------------- /include/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) 2021 STMicroelectronics. 11 | * All rights reserved.

12 | * 13 | * This software component is licensed by ST under Ultimate Liberty license 14 | * SLA0044, the "License"; You may not use this file except in compliance with 15 | * the License. You may obtain a copy of the License at: 16 | * www.st.com/SLA0044 17 | * 18 | ****************************************************************************** 19 | */ 20 | /* USER CODE END Header */ 21 | 22 | /* Define to prevent recursive inclusion -------------------------------------*/ 23 | #ifndef __MAIN_H 24 | #define __MAIN_H 25 | 26 | #ifdef __cplusplus 27 | extern "C" { 28 | #endif 29 | 30 | /* Includes ------------------------------------------------------------------*/ 31 | #include "stm32h7xx_hal.h" 32 | 33 | /* Private includes ----------------------------------------------------------*/ 34 | /* USER CODE BEGIN Includes */ 35 | 36 | /* USER CODE END Includes */ 37 | 38 | /* Exported types ------------------------------------------------------------*/ 39 | /* USER CODE BEGIN ET */ 40 | 41 | /* USER CODE END ET */ 42 | 43 | /* Exported constants --------------------------------------------------------*/ 44 | /* USER CODE BEGIN EC */ 45 | 46 | /* USER CODE END EC */ 47 | 48 | /* Exported macro ------------------------------------------------------------*/ 49 | /* USER CODE BEGIN EM */ 50 | 51 | /* USER CODE END EM */ 52 | 53 | /* Exported functions prototypes ---------------------------------------------*/ 54 | void Error_Handler(void); 55 | 56 | /* USER CODE BEGIN EFP */ 57 | 58 | /* USER CODE END EFP */ 59 | 60 | /* Private defines -----------------------------------------------------------*/ 61 | #define B1_Pin GPIO_PIN_13 62 | #define B1_GPIO_Port GPIOC 63 | #define MCO_Pin GPIO_PIN_0 64 | #define MCO_GPIO_Port GPIOH 65 | #define RMII_MDC_Pin GPIO_PIN_1 66 | #define RMII_MDC_GPIO_Port GPIOC 67 | #define RMII_REF_CLK_Pin GPIO_PIN_1 68 | #define RMII_REF_CLK_GPIO_Port GPIOA 69 | #define RMII_MDIO_Pin GPIO_PIN_2 70 | #define RMII_MDIO_GPIO_Port GPIOA 71 | #define RMII_CRS_DV_Pin GPIO_PIN_7 72 | #define RMII_CRS_DV_GPIO_Port GPIOA 73 | #define RMII_RXD0_Pin GPIO_PIN_4 74 | #define RMII_RXD0_GPIO_Port GPIOC 75 | #define RMII_RXD1_Pin GPIO_PIN_5 76 | #define RMII_RXD1_GPIO_Port GPIOC 77 | #define LED_GREEN_Pin GPIO_PIN_0 78 | #define LED_GREEN_GPIO_Port GPIOB 79 | #define RMII_TXD1_Pin GPIO_PIN_13 80 | #define RMII_TXD1_GPIO_Port GPIOB 81 | #define LED_RED_Pin GPIO_PIN_14 82 | #define LED_RED_GPIO_Port GPIOB 83 | #define STLK_VCP_RX_Pin GPIO_PIN_8 84 | #define STLK_VCP_RX_GPIO_Port GPIOD 85 | #define STLK_VCP_TX_Pin GPIO_PIN_9 86 | #define STLK_VCP_TX_GPIO_Port GPIOD 87 | #define USB_FS_PWR_EN_Pin GPIO_PIN_10 88 | #define USB_FS_PWR_EN_GPIO_Port GPIOD 89 | #define USB_FS_OVCR_Pin GPIO_PIN_7 90 | #define USB_FS_OVCR_GPIO_Port GPIOG 91 | #define USB_FS_VBUS_Pin GPIO_PIN_9 92 | #define USB_FS_VBUS_GPIO_Port GPIOA 93 | #define USB_FS_ID_Pin GPIO_PIN_10 94 | #define USB_FS_ID_GPIO_Port GPIOA 95 | #define USB_FS_DM_Pin GPIO_PIN_11 96 | #define USB_FS_DM_GPIO_Port GPIOA 97 | #define USB_FS_DP_Pin GPIO_PIN_12 98 | #define USB_FS_DP_GPIO_Port GPIOA 99 | #define SWDIO_Pin GPIO_PIN_13 100 | #define SWDIO_GPIO_Port GPIOA 101 | #define SWCLK_Pin GPIO_PIN_14 102 | #define SWCLK_GPIO_Port GPIOA 103 | #define RMII_TX_EN_Pin GPIO_PIN_11 104 | #define RMII_TX_EN_GPIO_Port GPIOG 105 | #define RMII_TXD0_Pin GPIO_PIN_13 106 | #define RMII_TXD0_GPIO_Port GPIOG 107 | #define SWO_Pin GPIO_PIN_3 108 | #define SWO_GPIO_Port GPIOB 109 | #define LED_YELLOW_Pin GPIO_PIN_1 110 | #define LED_YELLOW_GPIO_Port GPIOE 111 | /* USER CODE BEGIN Private defines */ 112 | 113 | /* USER CODE END Private defines */ 114 | 115 | #ifdef __cplusplus 116 | } 117 | #endif 118 | 119 | #endif /* __MAIN_H */ 120 | 121 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 122 | -------------------------------------------------------------------------------- /include/stm32h7xx_it.h: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file stm32h7xx_it.h 5 | * @brief This file contains the headers of the interrupt handlers. 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | *

© Copyright (c) 2021 STMicroelectronics. 10 | * All rights reserved.

11 | * 12 | * This software component is licensed by ST under Ultimate Liberty license 13 | * SLA0044, the "License"; You may not use this file except in compliance with 14 | * the License. You may obtain a copy of the License at: 15 | * www.st.com/SLA0044 16 | * 17 | ****************************************************************************** 18 | */ 19 | /* USER CODE END Header */ 20 | 21 | /* Define to prevent recursive inclusion -------------------------------------*/ 22 | #ifndef __STM32H7xx_IT_H 23 | #define __STM32H7xx_IT_H 24 | 25 | #ifdef __cplusplus 26 | extern "C" { 27 | #endif 28 | 29 | /* Private includes ----------------------------------------------------------*/ 30 | /* USER CODE BEGIN Includes */ 31 | 32 | /* USER CODE END Includes */ 33 | 34 | /* Exported types ------------------------------------------------------------*/ 35 | /* USER CODE BEGIN ET */ 36 | 37 | /* USER CODE END ET */ 38 | 39 | /* Exported constants --------------------------------------------------------*/ 40 | /* USER CODE BEGIN EC */ 41 | 42 | /* USER CODE END EC */ 43 | 44 | /* Exported macro ------------------------------------------------------------*/ 45 | /* USER CODE BEGIN EM */ 46 | 47 | /* USER CODE END EM */ 48 | 49 | /* Exported functions prototypes ---------------------------------------------*/ 50 | void NMI_Handler(void); 51 | void HardFault_Handler(void); 52 | void MemManage_Handler(void); 53 | void BusFault_Handler(void); 54 | void UsageFault_Handler(void); 55 | void DebugMon_Handler(void); 56 | void TIM2_IRQHandler(void); 57 | /* USER CODE BEGIN EFP */ 58 | 59 | /* USER CODE END EFP */ 60 | 61 | #ifdef __cplusplus 62 | } 63 | #endif 64 | 65 | #endif /* __STM32H7xx_IT_H */ 66 | 67 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 68 | -------------------------------------------------------------------------------- /lib/FreeRTOS/CMSIS_RTOS_V2/freertos_mpool.h: -------------------------------------------------------------------------------- 1 | /* -------------------------------------------------------------------------- 2 | * Copyright (c) 2013-2020 Arm Limited. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the License); you may 7 | * not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an AS IS BASIS, WITHOUT 14 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | * 18 | * Name: freertos_mpool.h 19 | * Purpose: CMSIS RTOS2 wrapper for FreeRTOS 20 | * 21 | *---------------------------------------------------------------------------*/ 22 | 23 | #ifndef FREERTOS_MPOOL_H_ 24 | #define FREERTOS_MPOOL_H_ 25 | 26 | #include 27 | #include "FreeRTOS.h" 28 | #include "semphr.h" 29 | 30 | /* Memory Pool implementation definitions */ 31 | #define MPOOL_STATUS 0x5EED0000U 32 | 33 | /* Memory Block header */ 34 | typedef struct { 35 | void *next; /* Pointer to next block */ 36 | } MemPoolBlock_t; 37 | 38 | /* Memory Pool control block */ 39 | typedef struct MemPoolDef_t { 40 | MemPoolBlock_t *head; /* Pointer to head block */ 41 | SemaphoreHandle_t sem; /* Pool semaphore handle */ 42 | uint8_t *mem_arr; /* Pool memory array */ 43 | uint32_t mem_sz; /* Pool memory array size */ 44 | const char *name; /* Pointer to name string */ 45 | uint32_t bl_sz; /* Size of a single block */ 46 | uint32_t bl_cnt; /* Number of blocks */ 47 | uint32_t n; /* Block allocation index */ 48 | volatile uint32_t status; /* Object status flags */ 49 | #if (configSUPPORT_STATIC_ALLOCATION == 1) 50 | StaticSemaphore_t mem_sem; /* Semaphore object memory */ 51 | #endif 52 | } MemPool_t; 53 | 54 | /* No need to hide static object type, just align to coding style */ 55 | #define StaticMemPool_t MemPool_t 56 | 57 | /* Define memory pool control block size */ 58 | #define MEMPOOL_CB_SIZE (sizeof(StaticMemPool_t)) 59 | 60 | /* Define size of the byte array required to create count of blocks of given size */ 61 | #define MEMPOOL_ARR_SIZE(bl_count, bl_size) (((((bl_size) + (4 - 1)) / 4) * 4)*(bl_count)) 62 | 63 | #endif /* FREERTOS_MPOOL_H_ */ 64 | -------------------------------------------------------------------------------- /lib/FreeRTOS/include/StackMacros.h: -------------------------------------------------------------------------------- 1 | /* 2 | * FreeRTOS Kernel V10.3.1 3 | * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | * this software and associated documentation files (the "Software"), to deal in 7 | * the Software without restriction, including without limitation the rights to 8 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | * the Software, and to permit persons to whom the Software is furnished to do so, 10 | * subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | * 22 | * http://www.FreeRTOS.org 23 | * http://aws.amazon.com/freertos 24 | * 25 | * 1 tab == 4 spaces! 26 | */ 27 | 28 | #ifndef STACK_MACROS_H 29 | #define STACK_MACROS_H 30 | 31 | #ifndef _MSC_VER /* Visual Studio doesn't support #warning. */ 32 | #warning The name of this file has changed to stack_macros.h. Please update your code accordingly. This source file (which has the original name) will be removed in future released. 33 | #endif 34 | 35 | /* 36 | * Call the stack overflow hook function if the stack of the task being swapped 37 | * out is currently overflowed, or looks like it might have overflowed in the 38 | * past. 39 | * 40 | * Setting configCHECK_FOR_STACK_OVERFLOW to 1 will cause the macro to check 41 | * the current stack state only - comparing the current top of stack value to 42 | * the stack limit. Setting configCHECK_FOR_STACK_OVERFLOW to greater than 1 43 | * will also cause the last few stack bytes to be checked to ensure the value 44 | * to which the bytes were set when the task was created have not been 45 | * overwritten. Note this second test does not guarantee that an overflowed 46 | * stack will always be recognised. 47 | */ 48 | 49 | /*-----------------------------------------------------------*/ 50 | 51 | #if( ( configCHECK_FOR_STACK_OVERFLOW == 1 ) && ( portSTACK_GROWTH < 0 ) ) 52 | 53 | /* Only the current stack state is to be checked. */ 54 | #define taskCHECK_FOR_STACK_OVERFLOW() \ 55 | { \ 56 | /* Is the currently saved stack pointer within the stack limit? */ \ 57 | if( pxCurrentTCB->pxTopOfStack <= pxCurrentTCB->pxStack ) \ 58 | { \ 59 | vApplicationStackOverflowHook( ( TaskHandle_t ) pxCurrentTCB, pxCurrentTCB->pcTaskName ); \ 60 | } \ 61 | } 62 | 63 | #endif /* configCHECK_FOR_STACK_OVERFLOW == 1 */ 64 | /*-----------------------------------------------------------*/ 65 | 66 | #if( ( configCHECK_FOR_STACK_OVERFLOW == 1 ) && ( portSTACK_GROWTH > 0 ) ) 67 | 68 | /* Only the current stack state is to be checked. */ 69 | #define taskCHECK_FOR_STACK_OVERFLOW() \ 70 | { \ 71 | \ 72 | /* Is the currently saved stack pointer within the stack limit? */ \ 73 | if( pxCurrentTCB->pxTopOfStack >= pxCurrentTCB->pxEndOfStack ) \ 74 | { \ 75 | vApplicationStackOverflowHook( ( TaskHandle_t ) pxCurrentTCB, pxCurrentTCB->pcTaskName ); \ 76 | } \ 77 | } 78 | 79 | #endif /* configCHECK_FOR_STACK_OVERFLOW == 1 */ 80 | /*-----------------------------------------------------------*/ 81 | 82 | #if( ( configCHECK_FOR_STACK_OVERFLOW > 1 ) && ( portSTACK_GROWTH < 0 ) ) 83 | 84 | #define taskCHECK_FOR_STACK_OVERFLOW() \ 85 | { \ 86 | const uint32_t * const pulStack = ( uint32_t * ) pxCurrentTCB->pxStack; \ 87 | const uint32_t ulCheckValue = ( uint32_t ) 0xa5a5a5a5; \ 88 | \ 89 | if( ( pulStack[ 0 ] != ulCheckValue ) || \ 90 | ( pulStack[ 1 ] != ulCheckValue ) || \ 91 | ( pulStack[ 2 ] != ulCheckValue ) || \ 92 | ( pulStack[ 3 ] != ulCheckValue ) ) \ 93 | { \ 94 | vApplicationStackOverflowHook( ( TaskHandle_t ) pxCurrentTCB, pxCurrentTCB->pcTaskName ); \ 95 | } \ 96 | } 97 | 98 | #endif /* #if( configCHECK_FOR_STACK_OVERFLOW > 1 ) */ 99 | /*-----------------------------------------------------------*/ 100 | 101 | #if( ( configCHECK_FOR_STACK_OVERFLOW > 1 ) && ( portSTACK_GROWTH > 0 ) ) 102 | 103 | #define taskCHECK_FOR_STACK_OVERFLOW() \ 104 | { \ 105 | int8_t *pcEndOfStack = ( int8_t * ) pxCurrentTCB->pxEndOfStack; \ 106 | static const uint8_t ucExpectedStackBytes[] = { tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, \ 107 | tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, \ 108 | tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, \ 109 | tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, \ 110 | tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE }; \ 111 | \ 112 | \ 113 | pcEndOfStack -= sizeof( ucExpectedStackBytes ); \ 114 | \ 115 | /* Has the extremity of the task stack ever been written over? */ \ 116 | if( memcmp( ( void * ) pcEndOfStack, ( void * ) ucExpectedStackBytes, sizeof( ucExpectedStackBytes ) ) != 0 ) \ 117 | { \ 118 | vApplicationStackOverflowHook( ( TaskHandle_t ) pxCurrentTCB, pxCurrentTCB->pcTaskName ); \ 119 | } \ 120 | } 121 | 122 | #endif /* #if( configCHECK_FOR_STACK_OVERFLOW > 1 ) */ 123 | /*-----------------------------------------------------------*/ 124 | 125 | /* Remove stack overflow macro if not being used. */ 126 | #ifndef taskCHECK_FOR_STACK_OVERFLOW 127 | #define taskCHECK_FOR_STACK_OVERFLOW() 128 | #endif 129 | 130 | 131 | 132 | #endif /* STACK_MACROS_H */ 133 | 134 | -------------------------------------------------------------------------------- /lib/FreeRTOS/include/deprecated_definitions.h: -------------------------------------------------------------------------------- 1 | /* 2 | * FreeRTOS Kernel V10.3.1 3 | * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | * this software and associated documentation files (the "Software"), to deal in 7 | * the Software without restriction, including without limitation the rights to 8 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | * the Software, and to permit persons to whom the Software is furnished to do so, 10 | * subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | * 22 | * http://www.FreeRTOS.org 23 | * http://aws.amazon.com/freertos 24 | * 25 | * 1 tab == 4 spaces! 26 | */ 27 | 28 | #ifndef DEPRECATED_DEFINITIONS_H 29 | #define DEPRECATED_DEFINITIONS_H 30 | 31 | 32 | /* Each FreeRTOS port has a unique portmacro.h header file. Originally a 33 | pre-processor definition was used to ensure the pre-processor found the correct 34 | portmacro.h file for the port being used. That scheme was deprecated in favour 35 | of setting the compiler's include path such that it found the correct 36 | portmacro.h file - removing the need for the constant and allowing the 37 | portmacro.h file to be located anywhere in relation to the port being used. The 38 | definitions below remain in the code for backward compatibility only. New 39 | projects should not use them. */ 40 | 41 | #ifdef OPEN_WATCOM_INDUSTRIAL_PC_PORT 42 | #include "..\..\Source\portable\owatcom\16bitdos\pc\portmacro.h" 43 | typedef void ( __interrupt __far *pxISR )(); 44 | #endif 45 | 46 | #ifdef OPEN_WATCOM_FLASH_LITE_186_PORT 47 | #include "..\..\Source\portable\owatcom\16bitdos\flsh186\portmacro.h" 48 | typedef void ( __interrupt __far *pxISR )(); 49 | #endif 50 | 51 | #ifdef GCC_MEGA_AVR 52 | #include "../portable/GCC/ATMega323/portmacro.h" 53 | #endif 54 | 55 | #ifdef IAR_MEGA_AVR 56 | #include "../portable/IAR/ATMega323/portmacro.h" 57 | #endif 58 | 59 | #ifdef MPLAB_PIC24_PORT 60 | #include "../../Source/portable/MPLAB/PIC24_dsPIC/portmacro.h" 61 | #endif 62 | 63 | #ifdef MPLAB_DSPIC_PORT 64 | #include "../../Source/portable/MPLAB/PIC24_dsPIC/portmacro.h" 65 | #endif 66 | 67 | #ifdef MPLAB_PIC18F_PORT 68 | #include "../../Source/portable/MPLAB/PIC18F/portmacro.h" 69 | #endif 70 | 71 | #ifdef MPLAB_PIC32MX_PORT 72 | #include "../../Source/portable/MPLAB/PIC32MX/portmacro.h" 73 | #endif 74 | 75 | #ifdef _FEDPICC 76 | #include "libFreeRTOS/Include/portmacro.h" 77 | #endif 78 | 79 | #ifdef SDCC_CYGNAL 80 | #include "../../Source/portable/SDCC/Cygnal/portmacro.h" 81 | #endif 82 | 83 | #ifdef GCC_ARM7 84 | #include "../../Source/portable/GCC/ARM7_LPC2000/portmacro.h" 85 | #endif 86 | 87 | #ifdef GCC_ARM7_ECLIPSE 88 | #include "portmacro.h" 89 | #endif 90 | 91 | #ifdef ROWLEY_LPC23xx 92 | #include "../../Source/portable/GCC/ARM7_LPC23xx/portmacro.h" 93 | #endif 94 | 95 | #ifdef IAR_MSP430 96 | #include "..\..\Source\portable\IAR\MSP430\portmacro.h" 97 | #endif 98 | 99 | #ifdef GCC_MSP430 100 | #include "../../Source/portable/GCC/MSP430F449/portmacro.h" 101 | #endif 102 | 103 | #ifdef ROWLEY_MSP430 104 | #include "../../Source/portable/Rowley/MSP430F449/portmacro.h" 105 | #endif 106 | 107 | #ifdef ARM7_LPC21xx_KEIL_RVDS 108 | #include "..\..\Source\portable\RVDS\ARM7_LPC21xx\portmacro.h" 109 | #endif 110 | 111 | #ifdef SAM7_GCC 112 | #include "../../Source/portable/GCC/ARM7_AT91SAM7S/portmacro.h" 113 | #endif 114 | 115 | #ifdef SAM7_IAR 116 | #include "..\..\Source\portable\IAR\AtmelSAM7S64\portmacro.h" 117 | #endif 118 | 119 | #ifdef SAM9XE_IAR 120 | #include "..\..\Source\portable\IAR\AtmelSAM9XE\portmacro.h" 121 | #endif 122 | 123 | #ifdef LPC2000_IAR 124 | #include "..\..\Source\portable\IAR\LPC2000\portmacro.h" 125 | #endif 126 | 127 | #ifdef STR71X_IAR 128 | #include "..\..\Source\portable\IAR\STR71x\portmacro.h" 129 | #endif 130 | 131 | #ifdef STR75X_IAR 132 | #include "..\..\Source\portable\IAR\STR75x\portmacro.h" 133 | #endif 134 | 135 | #ifdef STR75X_GCC 136 | #include "..\..\Source\portable\GCC\STR75x\portmacro.h" 137 | #endif 138 | 139 | #ifdef STR91X_IAR 140 | #include "..\..\Source\portable\IAR\STR91x\portmacro.h" 141 | #endif 142 | 143 | #ifdef GCC_H8S 144 | #include "../../Source/portable/GCC/H8S2329/portmacro.h" 145 | #endif 146 | 147 | #ifdef GCC_AT91FR40008 148 | #include "../../Source/portable/GCC/ARM7_AT91FR40008/portmacro.h" 149 | #endif 150 | 151 | #ifdef RVDS_ARMCM3_LM3S102 152 | #include "../../Source/portable/RVDS/ARM_CM3/portmacro.h" 153 | #endif 154 | 155 | #ifdef GCC_ARMCM3_LM3S102 156 | #include "../../Source/portable/GCC/ARM_CM3/portmacro.h" 157 | #endif 158 | 159 | #ifdef GCC_ARMCM3 160 | #include "../../Source/portable/GCC/ARM_CM3/portmacro.h" 161 | #endif 162 | 163 | #ifdef IAR_ARM_CM3 164 | #include "../../Source/portable/IAR/ARM_CM3/portmacro.h" 165 | #endif 166 | 167 | #ifdef IAR_ARMCM3_LM 168 | #include "../../Source/portable/IAR/ARM_CM3/portmacro.h" 169 | #endif 170 | 171 | #ifdef HCS12_CODE_WARRIOR 172 | #include "../../Source/portable/CodeWarrior/HCS12/portmacro.h" 173 | #endif 174 | 175 | #ifdef MICROBLAZE_GCC 176 | #include "../../Source/portable/GCC/MicroBlaze/portmacro.h" 177 | #endif 178 | 179 | #ifdef TERN_EE 180 | #include "..\..\Source\portable\Paradigm\Tern_EE\small\portmacro.h" 181 | #endif 182 | 183 | #ifdef GCC_HCS12 184 | #include "../../Source/portable/GCC/HCS12/portmacro.h" 185 | #endif 186 | 187 | #ifdef GCC_MCF5235 188 | #include "../../Source/portable/GCC/MCF5235/portmacro.h" 189 | #endif 190 | 191 | #ifdef COLDFIRE_V2_GCC 192 | #include "../../../Source/portable/GCC/ColdFire_V2/portmacro.h" 193 | #endif 194 | 195 | #ifdef COLDFIRE_V2_CODEWARRIOR 196 | #include "../../Source/portable/CodeWarrior/ColdFire_V2/portmacro.h" 197 | #endif 198 | 199 | #ifdef GCC_PPC405 200 | #include "../../Source/portable/GCC/PPC405_Xilinx/portmacro.h" 201 | #endif 202 | 203 | #ifdef GCC_PPC440 204 | #include "../../Source/portable/GCC/PPC440_Xilinx/portmacro.h" 205 | #endif 206 | 207 | #ifdef _16FX_SOFTUNE 208 | #include "..\..\Source\portable\Softune\MB96340\portmacro.h" 209 | #endif 210 | 211 | #ifdef BCC_INDUSTRIAL_PC_PORT 212 | /* A short file name has to be used in place of the normal 213 | FreeRTOSConfig.h when using the Borland compiler. */ 214 | #include "frconfig.h" 215 | #include "..\portable\BCC\16BitDOS\PC\prtmacro.h" 216 | typedef void ( __interrupt __far *pxISR )(); 217 | #endif 218 | 219 | #ifdef BCC_FLASH_LITE_186_PORT 220 | /* A short file name has to be used in place of the normal 221 | FreeRTOSConfig.h when using the Borland compiler. */ 222 | #include "frconfig.h" 223 | #include "..\portable\BCC\16BitDOS\flsh186\prtmacro.h" 224 | typedef void ( __interrupt __far *pxISR )(); 225 | #endif 226 | 227 | #ifdef __GNUC__ 228 | #ifdef __AVR32_AVR32A__ 229 | #include "portmacro.h" 230 | #endif 231 | #endif 232 | 233 | #ifdef __ICCAVR32__ 234 | #ifdef __CORE__ 235 | #if __CORE__ == __AVR32A__ 236 | #include "portmacro.h" 237 | #endif 238 | #endif 239 | #endif 240 | 241 | #ifdef __91467D 242 | #include "portmacro.h" 243 | #endif 244 | 245 | #ifdef __96340 246 | #include "portmacro.h" 247 | #endif 248 | 249 | 250 | #ifdef __IAR_V850ES_Fx3__ 251 | #include "../../Source/portable/IAR/V850ES/portmacro.h" 252 | #endif 253 | 254 | #ifdef __IAR_V850ES_Jx3__ 255 | #include "../../Source/portable/IAR/V850ES/portmacro.h" 256 | #endif 257 | 258 | #ifdef __IAR_V850ES_Jx3_L__ 259 | #include "../../Source/portable/IAR/V850ES/portmacro.h" 260 | #endif 261 | 262 | #ifdef __IAR_V850ES_Jx2__ 263 | #include "../../Source/portable/IAR/V850ES/portmacro.h" 264 | #endif 265 | 266 | #ifdef __IAR_V850ES_Hx2__ 267 | #include "../../Source/portable/IAR/V850ES/portmacro.h" 268 | #endif 269 | 270 | #ifdef __IAR_78K0R_Kx3__ 271 | #include "../../Source/portable/IAR/78K0R/portmacro.h" 272 | #endif 273 | 274 | #ifdef __IAR_78K0R_Kx3L__ 275 | #include "../../Source/portable/IAR/78K0R/portmacro.h" 276 | #endif 277 | 278 | #endif /* DEPRECATED_DEFINITIONS_H */ 279 | 280 | -------------------------------------------------------------------------------- /lib/FreeRTOS/include/portable.h: -------------------------------------------------------------------------------- 1 | /* 2 | * FreeRTOS Kernel V10.3.1 3 | * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | * this software and associated documentation files (the "Software"), to deal in 7 | * the Software without restriction, including without limitation the rights to 8 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | * the Software, and to permit persons to whom the Software is furnished to do so, 10 | * subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | * 22 | * http://www.FreeRTOS.org 23 | * http://aws.amazon.com/freertos 24 | * 25 | * 1 tab == 4 spaces! 26 | */ 27 | 28 | /*----------------------------------------------------------- 29 | * Portable layer API. Each function must be defined for each port. 30 | *----------------------------------------------------------*/ 31 | 32 | #ifndef PORTABLE_H 33 | #define PORTABLE_H 34 | 35 | /* Each FreeRTOS port has a unique portmacro.h header file. Originally a 36 | pre-processor definition was used to ensure the pre-processor found the correct 37 | portmacro.h file for the port being used. That scheme was deprecated in favour 38 | of setting the compiler's include path such that it found the correct 39 | portmacro.h file - removing the need for the constant and allowing the 40 | portmacro.h file to be located anywhere in relation to the port being used. 41 | Purely for reasons of backward compatibility the old method is still valid, but 42 | to make it clear that new projects should not use it, support for the port 43 | specific constants has been moved into the deprecated_definitions.h header 44 | file. */ 45 | #include "deprecated_definitions.h" 46 | 47 | /* If portENTER_CRITICAL is not defined then including deprecated_definitions.h 48 | did not result in a portmacro.h header file being included - and it should be 49 | included here. In this case the path to the correct portmacro.h header file 50 | must be set in the compiler's include path. */ 51 | #ifndef portENTER_CRITICAL 52 | #include "portmacro.h" 53 | #endif 54 | 55 | #if portBYTE_ALIGNMENT == 32 56 | #define portBYTE_ALIGNMENT_MASK ( 0x001f ) 57 | #endif 58 | 59 | #if portBYTE_ALIGNMENT == 16 60 | #define portBYTE_ALIGNMENT_MASK ( 0x000f ) 61 | #endif 62 | 63 | #if portBYTE_ALIGNMENT == 8 64 | #define portBYTE_ALIGNMENT_MASK ( 0x0007 ) 65 | #endif 66 | 67 | #if portBYTE_ALIGNMENT == 4 68 | #define portBYTE_ALIGNMENT_MASK ( 0x0003 ) 69 | #endif 70 | 71 | #if portBYTE_ALIGNMENT == 2 72 | #define portBYTE_ALIGNMENT_MASK ( 0x0001 ) 73 | #endif 74 | 75 | #if portBYTE_ALIGNMENT == 1 76 | #define portBYTE_ALIGNMENT_MASK ( 0x0000 ) 77 | #endif 78 | 79 | #ifndef portBYTE_ALIGNMENT_MASK 80 | #error "Invalid portBYTE_ALIGNMENT definition" 81 | #endif 82 | 83 | #ifndef portNUM_CONFIGURABLE_REGIONS 84 | #define portNUM_CONFIGURABLE_REGIONS 1 85 | #endif 86 | 87 | #ifndef portHAS_STACK_OVERFLOW_CHECKING 88 | #define portHAS_STACK_OVERFLOW_CHECKING 0 89 | #endif 90 | 91 | #ifndef portARCH_NAME 92 | #define portARCH_NAME NULL 93 | #endif 94 | 95 | #ifdef __cplusplus 96 | extern "C" { 97 | #endif 98 | 99 | #include "mpu_wrappers.h" 100 | 101 | /* 102 | * Setup the stack of a new task so it is ready to be placed under the 103 | * scheduler control. The registers have to be placed on the stack in 104 | * the order that the port expects to find them. 105 | * 106 | */ 107 | #if( portUSING_MPU_WRAPPERS == 1 ) 108 | #if( portHAS_STACK_OVERFLOW_CHECKING == 1 ) 109 | StackType_t *pxPortInitialiseStack( StackType_t *pxTopOfStack, StackType_t *pxEndOfStack, TaskFunction_t pxCode, void *pvParameters, BaseType_t xRunPrivileged ) PRIVILEGED_FUNCTION; 110 | #else 111 | StackType_t *pxPortInitialiseStack( StackType_t *pxTopOfStack, TaskFunction_t pxCode, void *pvParameters, BaseType_t xRunPrivileged ) PRIVILEGED_FUNCTION; 112 | #endif 113 | #else 114 | #if( portHAS_STACK_OVERFLOW_CHECKING == 1 ) 115 | StackType_t *pxPortInitialiseStack( StackType_t *pxTopOfStack, StackType_t *pxEndOfStack, TaskFunction_t pxCode, void *pvParameters ) PRIVILEGED_FUNCTION; 116 | #else 117 | StackType_t *pxPortInitialiseStack( StackType_t *pxTopOfStack, TaskFunction_t pxCode, void *pvParameters ) PRIVILEGED_FUNCTION; 118 | #endif 119 | #endif 120 | 121 | /* Used by heap_5.c to define the start address and size of each memory region 122 | that together comprise the total FreeRTOS heap space. */ 123 | typedef struct HeapRegion 124 | { 125 | uint8_t *pucStartAddress; 126 | size_t xSizeInBytes; 127 | } HeapRegion_t; 128 | 129 | /* Used to pass information about the heap out of vPortGetHeapStats(). */ 130 | typedef struct xHeapStats 131 | { 132 | size_t xAvailableHeapSpaceInBytes; /* The total heap size currently available - this is the sum of all the free blocks, not the largest block that can be allocated. */ 133 | size_t xSizeOfLargestFreeBlockInBytes; /* The maximum size, in bytes, of all the free blocks within the heap at the time vPortGetHeapStats() is called. */ 134 | size_t xSizeOfSmallestFreeBlockInBytes; /* The minimum size, in bytes, of all the free blocks within the heap at the time vPortGetHeapStats() is called. */ 135 | size_t xNumberOfFreeBlocks; /* The number of free memory blocks within the heap at the time vPortGetHeapStats() is called. */ 136 | size_t xMinimumEverFreeBytesRemaining; /* The minimum amount of total free memory (sum of all free blocks) there has been in the heap since the system booted. */ 137 | size_t xNumberOfSuccessfulAllocations; /* The number of calls to pvPortMalloc() that have returned a valid memory block. */ 138 | size_t xNumberOfSuccessfulFrees; /* The number of calls to vPortFree() that has successfully freed a block of memory. */ 139 | } HeapStats_t; 140 | 141 | /* 142 | * Used to define multiple heap regions for use by heap_5.c. This function 143 | * must be called before any calls to pvPortMalloc() - not creating a task, 144 | * queue, semaphore, mutex, software timer, event group, etc. will result in 145 | * pvPortMalloc being called. 146 | * 147 | * pxHeapRegions passes in an array of HeapRegion_t structures - each of which 148 | * defines a region of memory that can be used as the heap. The array is 149 | * terminated by a HeapRegions_t structure that has a size of 0. The region 150 | * with the lowest start address must appear first in the array. 151 | */ 152 | void vPortDefineHeapRegions( const HeapRegion_t * const pxHeapRegions ) PRIVILEGED_FUNCTION; 153 | 154 | /* 155 | * Returns a HeapStats_t structure filled with information about the current 156 | * heap state. 157 | */ 158 | void vPortGetHeapStats( HeapStats_t *pxHeapStats ); 159 | 160 | /* 161 | * Map to the memory management routines required for the port. 162 | */ 163 | void *pvPortMalloc( size_t xSize ) PRIVILEGED_FUNCTION; 164 | void vPortFree( void *pv ) PRIVILEGED_FUNCTION; 165 | void vPortInitialiseBlocks( void ) PRIVILEGED_FUNCTION; 166 | size_t xPortGetFreeHeapSize( void ) PRIVILEGED_FUNCTION; 167 | size_t xPortGetMinimumEverFreeHeapSize( void ) PRIVILEGED_FUNCTION; 168 | 169 | /* 170 | * Setup the hardware ready for the scheduler to take control. This generally 171 | * sets up a tick interrupt and sets timers for the correct tick frequency. 172 | */ 173 | BaseType_t xPortStartScheduler( void ) PRIVILEGED_FUNCTION; 174 | 175 | /* 176 | * Undo any hardware/ISR setup that was performed by xPortStartScheduler() so 177 | * the hardware is left in its original condition after the scheduler stops 178 | * executing. 179 | */ 180 | void vPortEndScheduler( void ) PRIVILEGED_FUNCTION; 181 | 182 | /* 183 | * The structures and methods of manipulating the MPU are contained within the 184 | * port layer. 185 | * 186 | * Fills the xMPUSettings structure with the memory region information 187 | * contained in xRegions. 188 | */ 189 | #if( portUSING_MPU_WRAPPERS == 1 ) 190 | struct xMEMORY_REGION; 191 | void vPortStoreTaskMPUSettings( xMPU_SETTINGS *xMPUSettings, const struct xMEMORY_REGION * const xRegions, StackType_t *pxBottomOfStack, uint32_t ulStackDepth ) PRIVILEGED_FUNCTION; 192 | #endif 193 | 194 | #ifdef __cplusplus 195 | } 196 | #endif 197 | 198 | #endif /* PORTABLE_H */ 199 | 200 | -------------------------------------------------------------------------------- /lib/FreeRTOS/include/projdefs.h: -------------------------------------------------------------------------------- 1 | /* 2 | * FreeRTOS Kernel V10.3.1 3 | * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | * this software and associated documentation files (the "Software"), to deal in 7 | * the Software without restriction, including without limitation the rights to 8 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | * the Software, and to permit persons to whom the Software is furnished to do so, 10 | * subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | * 22 | * http://www.FreeRTOS.org 23 | * http://aws.amazon.com/freertos 24 | * 25 | * 1 tab == 4 spaces! 26 | */ 27 | 28 | #ifndef PROJDEFS_H 29 | #define PROJDEFS_H 30 | 31 | /* 32 | * Defines the prototype to which task functions must conform. Defined in this 33 | * file to ensure the type is known before portable.h is included. 34 | */ 35 | typedef void (*TaskFunction_t)( void * ); 36 | 37 | /* Converts a time in milliseconds to a time in ticks. This macro can be 38 | overridden by a macro of the same name defined in FreeRTOSConfig.h in case the 39 | definition here is not suitable for your application. */ 40 | #ifndef pdMS_TO_TICKS 41 | #define pdMS_TO_TICKS( xTimeInMs ) ( ( TickType_t ) ( ( ( TickType_t ) ( xTimeInMs ) * ( TickType_t ) configTICK_RATE_HZ ) / ( TickType_t ) 1000 ) ) 42 | #endif 43 | 44 | #define pdFALSE ( ( BaseType_t ) 0 ) 45 | #define pdTRUE ( ( BaseType_t ) 1 ) 46 | 47 | #define pdPASS ( pdTRUE ) 48 | #define pdFAIL ( pdFALSE ) 49 | #define errQUEUE_EMPTY ( ( BaseType_t ) 0 ) 50 | #define errQUEUE_FULL ( ( BaseType_t ) 0 ) 51 | 52 | /* FreeRTOS error definitions. */ 53 | #define errCOULD_NOT_ALLOCATE_REQUIRED_MEMORY ( -1 ) 54 | #define errQUEUE_BLOCKED ( -4 ) 55 | #define errQUEUE_YIELD ( -5 ) 56 | 57 | /* Macros used for basic data corruption checks. */ 58 | #ifndef configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES 59 | #define configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES 0 60 | #endif 61 | 62 | #if( configUSE_16_BIT_TICKS == 1 ) 63 | #define pdINTEGRITY_CHECK_VALUE 0x5a5a 64 | #else 65 | #define pdINTEGRITY_CHECK_VALUE 0x5a5a5a5aUL 66 | #endif 67 | 68 | /* The following errno values are used by FreeRTOS+ components, not FreeRTOS 69 | itself. */ 70 | #define pdFREERTOS_ERRNO_NONE 0 /* No errors */ 71 | #define pdFREERTOS_ERRNO_ENOENT 2 /* No such file or directory */ 72 | #define pdFREERTOS_ERRNO_EINTR 4 /* Interrupted system call */ 73 | #define pdFREERTOS_ERRNO_EIO 5 /* I/O error */ 74 | #define pdFREERTOS_ERRNO_ENXIO 6 /* No such device or address */ 75 | #define pdFREERTOS_ERRNO_EBADF 9 /* Bad file number */ 76 | #define pdFREERTOS_ERRNO_EAGAIN 11 /* No more processes */ 77 | #define pdFREERTOS_ERRNO_EWOULDBLOCK 11 /* Operation would block */ 78 | #define pdFREERTOS_ERRNO_ENOMEM 12 /* Not enough memory */ 79 | #define pdFREERTOS_ERRNO_EACCES 13 /* Permission denied */ 80 | #define pdFREERTOS_ERRNO_EFAULT 14 /* Bad address */ 81 | #define pdFREERTOS_ERRNO_EBUSY 16 /* Mount device busy */ 82 | #define pdFREERTOS_ERRNO_EEXIST 17 /* File exists */ 83 | #define pdFREERTOS_ERRNO_EXDEV 18 /* Cross-device link */ 84 | #define pdFREERTOS_ERRNO_ENODEV 19 /* No such device */ 85 | #define pdFREERTOS_ERRNO_ENOTDIR 20 /* Not a directory */ 86 | #define pdFREERTOS_ERRNO_EISDIR 21 /* Is a directory */ 87 | #define pdFREERTOS_ERRNO_EINVAL 22 /* Invalid argument */ 88 | #define pdFREERTOS_ERRNO_ENOSPC 28 /* No space left on device */ 89 | #define pdFREERTOS_ERRNO_ESPIPE 29 /* Illegal seek */ 90 | #define pdFREERTOS_ERRNO_EROFS 30 /* Read only file system */ 91 | #define pdFREERTOS_ERRNO_EUNATCH 42 /* Protocol driver not attached */ 92 | #define pdFREERTOS_ERRNO_EBADE 50 /* Invalid exchange */ 93 | #define pdFREERTOS_ERRNO_EFTYPE 79 /* Inappropriate file type or format */ 94 | #define pdFREERTOS_ERRNO_ENMFILE 89 /* No more files */ 95 | #define pdFREERTOS_ERRNO_ENOTEMPTY 90 /* Directory not empty */ 96 | #define pdFREERTOS_ERRNO_ENAMETOOLONG 91 /* File or path name too long */ 97 | #define pdFREERTOS_ERRNO_EOPNOTSUPP 95 /* Operation not supported on transport endpoint */ 98 | #define pdFREERTOS_ERRNO_ENOBUFS 105 /* No buffer space available */ 99 | #define pdFREERTOS_ERRNO_ENOPROTOOPT 109 /* Protocol not available */ 100 | #define pdFREERTOS_ERRNO_EADDRINUSE 112 /* Address already in use */ 101 | #define pdFREERTOS_ERRNO_ETIMEDOUT 116 /* Connection timed out */ 102 | #define pdFREERTOS_ERRNO_EINPROGRESS 119 /* Connection already in progress */ 103 | #define pdFREERTOS_ERRNO_EALREADY 120 /* Socket already connected */ 104 | #define pdFREERTOS_ERRNO_EADDRNOTAVAIL 125 /* Address not available */ 105 | #define pdFREERTOS_ERRNO_EISCONN 127 /* Socket is already connected */ 106 | #define pdFREERTOS_ERRNO_ENOTCONN 128 /* Socket is not connected */ 107 | #define pdFREERTOS_ERRNO_ENOMEDIUM 135 /* No medium inserted */ 108 | #define pdFREERTOS_ERRNO_EILSEQ 138 /* An invalid UTF-16 sequence was encountered. */ 109 | #define pdFREERTOS_ERRNO_ECANCELED 140 /* Operation canceled. */ 110 | 111 | /* The following endian values are used by FreeRTOS+ components, not FreeRTOS 112 | itself. */ 113 | #define pdFREERTOS_LITTLE_ENDIAN 0 114 | #define pdFREERTOS_BIG_ENDIAN 1 115 | 116 | /* Re-defining endian values for generic naming. */ 117 | #define pdLITTLE_ENDIAN pdFREERTOS_LITTLE_ENDIAN 118 | #define pdBIG_ENDIAN pdFREERTOS_BIG_ENDIAN 119 | 120 | 121 | #endif /* PROJDEFS_H */ 122 | 123 | 124 | 125 | -------------------------------------------------------------------------------- /lib/FreeRTOS/include/stack_macros.h: -------------------------------------------------------------------------------- 1 | /* 2 | * FreeRTOS Kernel V10.3.1 3 | * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | * this software and associated documentation files (the "Software"), to deal in 7 | * the Software without restriction, including without limitation the rights to 8 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | * the Software, and to permit persons to whom the Software is furnished to do so, 10 | * subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | * 22 | * http://www.FreeRTOS.org 23 | * http://aws.amazon.com/freertos 24 | * 25 | * 1 tab == 4 spaces! 26 | */ 27 | 28 | #ifndef STACK_MACROS_H 29 | #define STACK_MACROS_H 30 | 31 | /* 32 | * Call the stack overflow hook function if the stack of the task being swapped 33 | * out is currently overflowed, or looks like it might have overflowed in the 34 | * past. 35 | * 36 | * Setting configCHECK_FOR_STACK_OVERFLOW to 1 will cause the macro to check 37 | * the current stack state only - comparing the current top of stack value to 38 | * the stack limit. Setting configCHECK_FOR_STACK_OVERFLOW to greater than 1 39 | * will also cause the last few stack bytes to be checked to ensure the value 40 | * to which the bytes were set when the task was created have not been 41 | * overwritten. Note this second test does not guarantee that an overflowed 42 | * stack will always be recognised. 43 | */ 44 | 45 | /*-----------------------------------------------------------*/ 46 | 47 | #if( ( configCHECK_FOR_STACK_OVERFLOW == 1 ) && ( portSTACK_GROWTH < 0 ) ) 48 | 49 | /* Only the current stack state is to be checked. */ 50 | #define taskCHECK_FOR_STACK_OVERFLOW() \ 51 | { \ 52 | /* Is the currently saved stack pointer within the stack limit? */ \ 53 | if( pxCurrentTCB->pxTopOfStack <= pxCurrentTCB->pxStack ) \ 54 | { \ 55 | vApplicationStackOverflowHook( ( TaskHandle_t ) pxCurrentTCB, pxCurrentTCB->pcTaskName ); \ 56 | } \ 57 | } 58 | 59 | #endif /* configCHECK_FOR_STACK_OVERFLOW == 1 */ 60 | /*-----------------------------------------------------------*/ 61 | 62 | #if( ( configCHECK_FOR_STACK_OVERFLOW == 1 ) && ( portSTACK_GROWTH > 0 ) ) 63 | 64 | /* Only the current stack state is to be checked. */ 65 | #define taskCHECK_FOR_STACK_OVERFLOW() \ 66 | { \ 67 | \ 68 | /* Is the currently saved stack pointer within the stack limit? */ \ 69 | if( pxCurrentTCB->pxTopOfStack >= pxCurrentTCB->pxEndOfStack ) \ 70 | { \ 71 | vApplicationStackOverflowHook( ( TaskHandle_t ) pxCurrentTCB, pxCurrentTCB->pcTaskName ); \ 72 | } \ 73 | } 74 | 75 | #endif /* configCHECK_FOR_STACK_OVERFLOW == 1 */ 76 | /*-----------------------------------------------------------*/ 77 | 78 | #if( ( configCHECK_FOR_STACK_OVERFLOW > 1 ) && ( portSTACK_GROWTH < 0 ) ) 79 | 80 | #define taskCHECK_FOR_STACK_OVERFLOW() \ 81 | { \ 82 | const uint32_t * const pulStack = ( uint32_t * ) pxCurrentTCB->pxStack; \ 83 | const uint32_t ulCheckValue = ( uint32_t ) 0xa5a5a5a5; \ 84 | \ 85 | if( ( pulStack[ 0 ] != ulCheckValue ) || \ 86 | ( pulStack[ 1 ] != ulCheckValue ) || \ 87 | ( pulStack[ 2 ] != ulCheckValue ) || \ 88 | ( pulStack[ 3 ] != ulCheckValue ) ) \ 89 | { \ 90 | vApplicationStackOverflowHook( ( TaskHandle_t ) pxCurrentTCB, pxCurrentTCB->pcTaskName ); \ 91 | } \ 92 | } 93 | 94 | #endif /* #if( configCHECK_FOR_STACK_OVERFLOW > 1 ) */ 95 | /*-----------------------------------------------------------*/ 96 | 97 | #if( ( configCHECK_FOR_STACK_OVERFLOW > 1 ) && ( portSTACK_GROWTH > 0 ) ) 98 | 99 | #define taskCHECK_FOR_STACK_OVERFLOW() \ 100 | { \ 101 | int8_t *pcEndOfStack = ( int8_t * ) pxCurrentTCB->pxEndOfStack; \ 102 | static const uint8_t ucExpectedStackBytes[] = { tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, \ 103 | tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, \ 104 | tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, \ 105 | tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, \ 106 | tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE }; \ 107 | \ 108 | \ 109 | pcEndOfStack -= sizeof( ucExpectedStackBytes ); \ 110 | \ 111 | /* Has the extremity of the task stack ever been written over? */ \ 112 | if( memcmp( ( void * ) pcEndOfStack, ( void * ) ucExpectedStackBytes, sizeof( ucExpectedStackBytes ) ) != 0 ) \ 113 | { \ 114 | vApplicationStackOverflowHook( ( TaskHandle_t ) pxCurrentTCB, pxCurrentTCB->pcTaskName ); \ 115 | } \ 116 | } 117 | 118 | #endif /* #if( configCHECK_FOR_STACK_OVERFLOW > 1 ) */ 119 | /*-----------------------------------------------------------*/ 120 | 121 | /* Remove stack overflow macro if not being used. */ 122 | #ifndef taskCHECK_FOR_STACK_OVERFLOW 123 | #define taskCHECK_FOR_STACK_OVERFLOW() 124 | #endif 125 | 126 | 127 | 128 | #endif /* STACK_MACROS_H */ 129 | 130 | -------------------------------------------------------------------------------- /lib/FreeRTOS/list.c: -------------------------------------------------------------------------------- 1 | /* 2 | * FreeRTOS Kernel V10.3.1 3 | * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | * this software and associated documentation files (the "Software"), to deal in 7 | * the Software without restriction, including without limitation the rights to 8 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | * the Software, and to permit persons to whom the Software is furnished to do so, 10 | * subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | * 22 | * http://www.FreeRTOS.org 23 | * http://aws.amazon.com/freertos 24 | * 25 | * 1 tab == 4 spaces! 26 | */ 27 | 28 | 29 | #include 30 | #include "FreeRTOS.h" 31 | #include "list.h" 32 | 33 | /*----------------------------------------------------------- 34 | * PUBLIC LIST API documented in list.h 35 | *----------------------------------------------------------*/ 36 | 37 | void vListInitialise( List_t * const pxList ) 38 | { 39 | /* The list structure contains a list item which is used to mark the 40 | end of the list. To initialise the list the list end is inserted 41 | as the only list entry. */ 42 | pxList->pxIndex = ( ListItem_t * ) &( pxList->xListEnd ); /*lint !e826 !e740 !e9087 The mini list structure is used as the list end to save RAM. This is checked and valid. */ 43 | 44 | /* The list end value is the highest possible value in the list to 45 | ensure it remains at the end of the list. */ 46 | pxList->xListEnd.xItemValue = portMAX_DELAY; 47 | 48 | /* The list end next and previous pointers point to itself so we know 49 | when the list is empty. */ 50 | pxList->xListEnd.pxNext = ( ListItem_t * ) &( pxList->xListEnd ); /*lint !e826 !e740 !e9087 The mini list structure is used as the list end to save RAM. This is checked and valid. */ 51 | pxList->xListEnd.pxPrevious = ( ListItem_t * ) &( pxList->xListEnd );/*lint !e826 !e740 !e9087 The mini list structure is used as the list end to save RAM. This is checked and valid. */ 52 | 53 | pxList->uxNumberOfItems = ( UBaseType_t ) 0U; 54 | 55 | /* Write known values into the list if 56 | configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES is set to 1. */ 57 | listSET_LIST_INTEGRITY_CHECK_1_VALUE( pxList ); 58 | listSET_LIST_INTEGRITY_CHECK_2_VALUE( pxList ); 59 | } 60 | /*-----------------------------------------------------------*/ 61 | 62 | void vListInitialiseItem( ListItem_t * const pxItem ) 63 | { 64 | /* Make sure the list item is not recorded as being on a list. */ 65 | pxItem->pxContainer = NULL; 66 | 67 | /* Write known values into the list item if 68 | configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES is set to 1. */ 69 | listSET_FIRST_LIST_ITEM_INTEGRITY_CHECK_VALUE( pxItem ); 70 | listSET_SECOND_LIST_ITEM_INTEGRITY_CHECK_VALUE( pxItem ); 71 | } 72 | /*-----------------------------------------------------------*/ 73 | 74 | void vListInsertEnd( List_t * const pxList, ListItem_t * const pxNewListItem ) 75 | { 76 | ListItem_t * const pxIndex = pxList->pxIndex; 77 | 78 | /* Only effective when configASSERT() is also defined, these tests may catch 79 | the list data structures being overwritten in memory. They will not catch 80 | data errors caused by incorrect configuration or use of FreeRTOS. */ 81 | listTEST_LIST_INTEGRITY( pxList ); 82 | listTEST_LIST_ITEM_INTEGRITY( pxNewListItem ); 83 | 84 | /* Insert a new list item into pxList, but rather than sort the list, 85 | makes the new list item the last item to be removed by a call to 86 | listGET_OWNER_OF_NEXT_ENTRY(). */ 87 | pxNewListItem->pxNext = pxIndex; 88 | pxNewListItem->pxPrevious = pxIndex->pxPrevious; 89 | 90 | /* Only used during decision coverage testing. */ 91 | mtCOVERAGE_TEST_DELAY(); 92 | 93 | pxIndex->pxPrevious->pxNext = pxNewListItem; 94 | pxIndex->pxPrevious = pxNewListItem; 95 | 96 | /* Remember which list the item is in. */ 97 | pxNewListItem->pxContainer = pxList; 98 | 99 | ( pxList->uxNumberOfItems )++; 100 | } 101 | /*-----------------------------------------------------------*/ 102 | 103 | void vListInsert( List_t * const pxList, ListItem_t * const pxNewListItem ) 104 | { 105 | ListItem_t *pxIterator; 106 | const TickType_t xValueOfInsertion = pxNewListItem->xItemValue; 107 | 108 | /* Only effective when configASSERT() is also defined, these tests may catch 109 | the list data structures being overwritten in memory. They will not catch 110 | data errors caused by incorrect configuration or use of FreeRTOS. */ 111 | listTEST_LIST_INTEGRITY( pxList ); 112 | listTEST_LIST_ITEM_INTEGRITY( pxNewListItem ); 113 | 114 | /* Insert the new list item into the list, sorted in xItemValue order. 115 | 116 | If the list already contains a list item with the same item value then the 117 | new list item should be placed after it. This ensures that TCBs which are 118 | stored in ready lists (all of which have the same xItemValue value) get a 119 | share of the CPU. However, if the xItemValue is the same as the back marker 120 | the iteration loop below will not end. Therefore the value is checked 121 | first, and the algorithm slightly modified if necessary. */ 122 | if( xValueOfInsertion == portMAX_DELAY ) 123 | { 124 | pxIterator = pxList->xListEnd.pxPrevious; 125 | } 126 | else 127 | { 128 | /* *** NOTE *********************************************************** 129 | If you find your application is crashing here then likely causes are 130 | listed below. In addition see https://www.freertos.org/FAQHelp.html for 131 | more tips, and ensure configASSERT() is defined! 132 | https://www.freertos.org/a00110.html#configASSERT 133 | 134 | 1) Stack overflow - 135 | see https://www.freertos.org/Stacks-and-stack-overflow-checking.html 136 | 2) Incorrect interrupt priority assignment, especially on Cortex-M 137 | parts where numerically high priority values denote low actual 138 | interrupt priorities, which can seem counter intuitive. See 139 | https://www.freertos.org/RTOS-Cortex-M3-M4.html and the definition 140 | of configMAX_SYSCALL_INTERRUPT_PRIORITY on 141 | https://www.freertos.org/a00110.html 142 | 3) Calling an API function from within a critical section or when 143 | the scheduler is suspended, or calling an API function that does 144 | not end in "FromISR" from an interrupt. 145 | 4) Using a queue or semaphore before it has been initialised or 146 | before the scheduler has been started (are interrupts firing 147 | before vTaskStartScheduler() has been called?). 148 | **********************************************************************/ 149 | 150 | for( pxIterator = ( ListItem_t * ) &( pxList->xListEnd ); pxIterator->pxNext->xItemValue <= xValueOfInsertion; pxIterator = pxIterator->pxNext ) /*lint !e826 !e740 !e9087 The mini list structure is used as the list end to save RAM. This is checked and valid. *//*lint !e440 The iterator moves to a different value, not xValueOfInsertion. */ 151 | { 152 | /* There is nothing to do here, just iterating to the wanted 153 | insertion position. */ 154 | } 155 | } 156 | 157 | pxNewListItem->pxNext = pxIterator->pxNext; 158 | pxNewListItem->pxNext->pxPrevious = pxNewListItem; 159 | pxNewListItem->pxPrevious = pxIterator; 160 | pxIterator->pxNext = pxNewListItem; 161 | 162 | /* Remember which list the item is in. This allows fast removal of the 163 | item later. */ 164 | pxNewListItem->pxContainer = pxList; 165 | 166 | ( pxList->uxNumberOfItems )++; 167 | } 168 | /*-----------------------------------------------------------*/ 169 | 170 | UBaseType_t uxListRemove( ListItem_t * const pxItemToRemove ) 171 | { 172 | /* The list item knows which list it is in. Obtain the list from the list 173 | item. */ 174 | List_t * const pxList = pxItemToRemove->pxContainer; 175 | 176 | pxItemToRemove->pxNext->pxPrevious = pxItemToRemove->pxPrevious; 177 | pxItemToRemove->pxPrevious->pxNext = pxItemToRemove->pxNext; 178 | 179 | /* Only used during decision coverage testing. */ 180 | mtCOVERAGE_TEST_DELAY(); 181 | 182 | /* Make sure the index is left pointing to a valid item. */ 183 | if( pxList->pxIndex == pxItemToRemove ) 184 | { 185 | pxList->pxIndex = pxItemToRemove->pxPrevious; 186 | } 187 | else 188 | { 189 | mtCOVERAGE_TEST_MARKER(); 190 | } 191 | 192 | pxItemToRemove->pxContainer = NULL; 193 | ( pxList->uxNumberOfItems )--; 194 | 195 | return pxList->uxNumberOfItems; 196 | } 197 | /*-----------------------------------------------------------*/ 198 | 199 | -------------------------------------------------------------------------------- /lib/README: -------------------------------------------------------------------------------- 1 | 2 | This directory is intended for project specific (private) libraries. 3 | PlatformIO will compile them to static libraries and link into executable file. 4 | 5 | The source code of each library should be placed in a an own separate directory 6 | ("lib/your_library_name/[here are source files]"). 7 | 8 | For example, see a structure of the following two libraries `Foo` and `Bar`: 9 | 10 | |--lib 11 | | | 12 | | |--Bar 13 | | | |--docs 14 | | | |--examples 15 | | | |--src 16 | | | |- Bar.c 17 | | | |- Bar.h 18 | | | |- library.json (optional, custom build options, etc) https://docs.platformio.org/page/librarymanager/config.html 19 | | | 20 | | |--Foo 21 | | | |- Foo.c 22 | | | |- Foo.h 23 | | | 24 | | |- README --> THIS FILE 25 | | 26 | |- platformio.ini 27 | |--src 28 | |- main.c 29 | 30 | and a contents of `src/main.c`: 31 | ``` 32 | #include 33 | #include 34 | 35 | int main (void) 36 | { 37 | ... 38 | } 39 | 40 | ``` 41 | 42 | PlatformIO Library Dependency Finder will find automatically dependent 43 | libraries scanning project source files. 44 | 45 | More information about PlatformIO Library Dependency Finder 46 | - https://docs.platformio.org/page/librarymanager/ldf.html 47 | -------------------------------------------------------------------------------- /platformio.ini: -------------------------------------------------------------------------------- 1 | ; PlatformIO Project Configuration File 2 | ; 3 | ; Build options: build flags, source filter 4 | ; Upload options: custom upload port, speed and extra flags 5 | ; Library options: dependencies, extra library storages 6 | ; Advanced options: extra scripting 7 | ; 8 | ; Please visit documentation for the other options and examples 9 | ; https://docs.platformio.org/page/projectconf.html 10 | 11 | [env:nucleo_h723zg] 12 | platform = ststm32 13 | board = nucleo_h723zg 14 | framework = stm32cube 15 | ; select linker file generated by CubeMX 16 | board_build.ldscript = STM32H723ZGTX_FLASH.ld 17 | ; make build system use our HAL config file 18 | board_build.stm32cube.custom_config_header = yes 19 | ; force inclusion of lib/FreeRTOS 20 | lib_deps = FreeRTOS 21 | ; needed compiler flags to 22 | ; correctly build the port assembly files 23 | ; and add freertos subfolders to include path 24 | build_flags = 25 | -mfpu=fpv4-sp-d16 26 | -mfloat-abi=softfp 27 | -Ilib/FreeRTOS/include 28 | -Ilib/FreeRTOS/CMSIS_RTOS_V2 29 | -Ilib/FreeRTOS/portable/GCC/ARM_CM4F 30 | -Iinclude 31 | ; link FreeRTOS as objectf files, not as 32 | ; archives. otherwise weak ISR functions 33 | ; don't get linked properly! 34 | lib_archive = no 35 | ; fix for RAM size / initial SP. 36 | ; see https://community.platformio.org/t/arm-versus-thumb/23540/ 37 | ; actually **not** needed because we have selected a fixed linkerfile!! 38 | ;board_upload.maximum_ram_size = 131072 39 | -------------------------------------------------------------------------------- /reference_stm32cube_project/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | h7_freertos_stm32cube 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.cdt.managedbuilder.core.genmakebuilder 10 | clean,full,incremental, 11 | 12 | 13 | 14 | 15 | org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder 16 | full,incremental, 17 | 18 | 19 | 20 | 21 | 22 | com.st.stm32cube.ide.mcu.MCUProjectNature 23 | org.eclipse.cdt.core.cnature 24 | com.st.stm32cube.ide.mcu.MCUCubeIdeServicesRevAev2ProjectNature 25 | com.st.stm32cube.ide.mcu.MCUCubeProjectNature 26 | com.st.stm32cube.ide.mcu.MCUAdvancedStructureProjectNature 27 | com.st.stm32cube.ide.mcu.MCUSingleCpuProjectNature 28 | com.st.stm32cube.ide.mcu.MCURootProjectNature 29 | org.eclipse.cdt.managedbuilder.core.managedBuildNature 30 | org.eclipse.cdt.managedbuilder.core.ScannerConfigNature 31 | 32 | 33 | -------------------------------------------------------------------------------- /reference_stm32cube_project/Core/Inc/FreeRTOSConfig.h: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /* 3 | * FreeRTOS Kernel V10.3.1 4 | * Portion Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. 5 | * Portion Copyright (C) 2019 StMicroelectronics, Inc. All Rights Reserved. 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a copy of 8 | * this software and associated documentation files (the "Software"), to deal in 9 | * the Software without restriction, including without limitation the rights to 10 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 11 | * the Software, and to permit persons to whom the Software is furnished to do so, 12 | * subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in all 15 | * copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 19 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 20 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 21 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 22 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | * 24 | * http://www.FreeRTOS.org 25 | * http://aws.amazon.com/freertos 26 | * 27 | * 1 tab == 4 spaces! 28 | */ 29 | /* USER CODE END Header */ 30 | 31 | #ifndef FREERTOS_CONFIG_H 32 | #define FREERTOS_CONFIG_H 33 | 34 | /*----------------------------------------------------------- 35 | * Application specific definitions. 36 | * 37 | * These definitions should be adjusted for your particular hardware and 38 | * application requirements. 39 | * 40 | * These parameters and more are described within the 'configuration' section of the 41 | * FreeRTOS API documentation available on the FreeRTOS.org web site. 42 | * 43 | * See http://www.freertos.org/a00110.html 44 | *----------------------------------------------------------*/ 45 | 46 | /* USER CODE BEGIN Includes */ 47 | /* Section where include file can be added */ 48 | /* USER CODE END Includes */ 49 | 50 | /* Ensure definitions are only used by the compiler, and not by the assembler. */ 51 | #if defined(__ICCARM__) || defined(__CC_ARM) || defined(__GNUC__) 52 | #include 53 | extern uint32_t SystemCoreClock; 54 | #endif 55 | #ifndef CMSIS_device_header 56 | #define CMSIS_device_header "stm32h7xx.h" 57 | #endif /* CMSIS_device_header */ 58 | 59 | #define configENABLE_FPU 0 60 | #define configENABLE_MPU 0 61 | 62 | #define configUSE_PREEMPTION 1 63 | #define configSUPPORT_STATIC_ALLOCATION 1 64 | #define configSUPPORT_DYNAMIC_ALLOCATION 1 65 | #define configUSE_IDLE_HOOK 0 66 | #define configUSE_TICK_HOOK 0 67 | #define configCPU_CLOCK_HZ ( SystemCoreClock ) 68 | #define configTICK_RATE_HZ ((TickType_t)1000) 69 | #define configMAX_PRIORITIES ( 56 ) 70 | #define configMINIMAL_STACK_SIZE ((uint16_t)128) 71 | #define configTOTAL_HEAP_SIZE ((size_t)15360) 72 | #define configMAX_TASK_NAME_LEN ( 16 ) 73 | #define configUSE_TRACE_FACILITY 1 74 | #define configUSE_16_BIT_TICKS 0 75 | #define configUSE_MUTEXES 1 76 | #define configQUEUE_REGISTRY_SIZE 8 77 | #define configUSE_RECURSIVE_MUTEXES 1 78 | #define configUSE_COUNTING_SEMAPHORES 1 79 | #define configUSE_PORT_OPTIMISED_TASK_SELECTION 0 80 | /* USER CODE BEGIN MESSAGE_BUFFER_LENGTH_TYPE */ 81 | /* Defaults to size_t for backward compatibility, but can be changed 82 | if lengths will always be less than the number of bytes in a size_t. */ 83 | #define configMESSAGE_BUFFER_LENGTH_TYPE size_t 84 | /* USER CODE END MESSAGE_BUFFER_LENGTH_TYPE */ 85 | 86 | /* Co-routine definitions. */ 87 | #define configUSE_CO_ROUTINES 0 88 | #define configMAX_CO_ROUTINE_PRIORITIES ( 2 ) 89 | 90 | /* Software timer definitions. */ 91 | #define configUSE_TIMERS 1 92 | #define configTIMER_TASK_PRIORITY ( 2 ) 93 | #define configTIMER_QUEUE_LENGTH 10 94 | #define configTIMER_TASK_STACK_DEPTH 256 95 | 96 | /* CMSIS-RTOS V2 flags */ 97 | #define configUSE_OS2_THREAD_SUSPEND_RESUME 1 98 | #define configUSE_OS2_THREAD_ENUMERATE 1 99 | #define configUSE_OS2_EVENTFLAGS_FROM_ISR 1 100 | #define configUSE_OS2_THREAD_FLAGS 1 101 | #define configUSE_OS2_TIMER 1 102 | #define configUSE_OS2_MUTEX 1 103 | 104 | /* Set the following definitions to 1 to include the API function, or zero 105 | to exclude the API function. */ 106 | #define INCLUDE_vTaskPrioritySet 1 107 | #define INCLUDE_uxTaskPriorityGet 1 108 | #define INCLUDE_vTaskDelete 1 109 | #define INCLUDE_vTaskCleanUpResources 0 110 | #define INCLUDE_vTaskSuspend 1 111 | #define INCLUDE_vTaskDelayUntil 1 112 | #define INCLUDE_vTaskDelay 1 113 | #define INCLUDE_xTaskGetSchedulerState 1 114 | #define INCLUDE_xTimerPendFunctionCall 1 115 | #define INCLUDE_xQueueGetMutexHolder 1 116 | #define INCLUDE_uxTaskGetStackHighWaterMark 1 117 | #define INCLUDE_xTaskGetCurrentTaskHandle 1 118 | #define INCLUDE_eTaskGetState 1 119 | 120 | /* 121 | * The CMSIS-RTOS V2 FreeRTOS wrapper is dependent on the heap implementation used 122 | * by the application thus the correct define need to be enabled below 123 | */ 124 | #define USE_FreeRTOS_HEAP_4 125 | 126 | /* Cortex-M specific definitions. */ 127 | #ifdef __NVIC_PRIO_BITS 128 | /* __BVIC_PRIO_BITS will be specified when CMSIS is being used. */ 129 | #define configPRIO_BITS __NVIC_PRIO_BITS 130 | #else 131 | #define configPRIO_BITS 4 132 | #endif 133 | 134 | /* The lowest interrupt priority that can be used in a call to a "set priority" 135 | function. */ 136 | #define configLIBRARY_LOWEST_INTERRUPT_PRIORITY 15 137 | 138 | /* The highest interrupt priority that can be used by any interrupt service 139 | routine that makes calls to interrupt safe FreeRTOS API functions. DO NOT CALL 140 | INTERRUPT SAFE FREERTOS API FUNCTIONS FROM ANY INTERRUPT THAT HAS A HIGHER 141 | PRIORITY THAN THIS! (higher priorities are lower numeric values. */ 142 | #define configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY 5 143 | 144 | /* Interrupt priorities used by the kernel port layer itself. These are generic 145 | to all Cortex-M ports, and do not rely on any particular library functions. */ 146 | #define configKERNEL_INTERRUPT_PRIORITY ( configLIBRARY_LOWEST_INTERRUPT_PRIORITY << (8 - configPRIO_BITS) ) 147 | /* !!!! configMAX_SYSCALL_INTERRUPT_PRIORITY must not be set to zero !!!! 148 | See http://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html. */ 149 | #define configMAX_SYSCALL_INTERRUPT_PRIORITY ( configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY << (8 - configPRIO_BITS) ) 150 | 151 | /* Normal assert() semantics without relying on the provision of an assert.h 152 | header file. */ 153 | /* USER CODE BEGIN 1 */ 154 | #define configASSERT( x ) if ((x) == 0) {taskDISABLE_INTERRUPTS(); for( ;; );} 155 | /* USER CODE END 1 */ 156 | 157 | /* Definitions that map the FreeRTOS port interrupt handlers to their CMSIS 158 | standard names. */ 159 | #define vPortSVCHandler SVC_Handler 160 | #define xPortPendSVHandler PendSV_Handler 161 | 162 | /* IMPORTANT: After 10.3.1 update, Systick_Handler comes from NVIC (if SYS timebase = systick), otherwise from cmsis_os2.c */ 163 | 164 | #define USE_CUSTOM_SYSTICK_HANDLER_IMPLEMENTATION 0 165 | 166 | /* USER CODE BEGIN Defines */ 167 | /* Section where parameter definitions can be added (for instance, to override default ones in FreeRTOS.h) */ 168 | /* USER CODE END Defines */ 169 | 170 | #endif /* FREERTOS_CONFIG_H */ 171 | -------------------------------------------------------------------------------- /reference_stm32cube_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) 2021 STMicroelectronics. 11 | * All rights reserved.

12 | * 13 | * This software component is licensed by ST under Ultimate Liberty license 14 | * SLA0044, the "License"; You may not use this file except in compliance with 15 | * the License. You may obtain a copy of the License at: 16 | * www.st.com/SLA0044 17 | * 18 | ****************************************************************************** 19 | */ 20 | /* USER CODE END Header */ 21 | 22 | /* Define to prevent recursive inclusion -------------------------------------*/ 23 | #ifndef __MAIN_H 24 | #define __MAIN_H 25 | 26 | #ifdef __cplusplus 27 | extern "C" { 28 | #endif 29 | 30 | /* Includes ------------------------------------------------------------------*/ 31 | #include "stm32h7xx_hal.h" 32 | 33 | /* Private includes ----------------------------------------------------------*/ 34 | /* USER CODE BEGIN Includes */ 35 | 36 | /* USER CODE END Includes */ 37 | 38 | /* Exported types ------------------------------------------------------------*/ 39 | /* USER CODE BEGIN ET */ 40 | 41 | /* USER CODE END ET */ 42 | 43 | /* Exported constants --------------------------------------------------------*/ 44 | /* USER CODE BEGIN EC */ 45 | 46 | /* USER CODE END EC */ 47 | 48 | /* Exported macro ------------------------------------------------------------*/ 49 | /* USER CODE BEGIN EM */ 50 | 51 | /* USER CODE END EM */ 52 | 53 | /* Exported functions prototypes ---------------------------------------------*/ 54 | void Error_Handler(void); 55 | 56 | /* USER CODE BEGIN EFP */ 57 | 58 | /* USER CODE END EFP */ 59 | 60 | /* Private defines -----------------------------------------------------------*/ 61 | #define B1_Pin GPIO_PIN_13 62 | #define B1_GPIO_Port GPIOC 63 | #define MCO_Pin GPIO_PIN_0 64 | #define MCO_GPIO_Port GPIOH 65 | #define RMII_MDC_Pin GPIO_PIN_1 66 | #define RMII_MDC_GPIO_Port GPIOC 67 | #define RMII_REF_CLK_Pin GPIO_PIN_1 68 | #define RMII_REF_CLK_GPIO_Port GPIOA 69 | #define RMII_MDIO_Pin GPIO_PIN_2 70 | #define RMII_MDIO_GPIO_Port GPIOA 71 | #define RMII_CRS_DV_Pin GPIO_PIN_7 72 | #define RMII_CRS_DV_GPIO_Port GPIOA 73 | #define RMII_RXD0_Pin GPIO_PIN_4 74 | #define RMII_RXD0_GPIO_Port GPIOC 75 | #define RMII_RXD1_Pin GPIO_PIN_5 76 | #define RMII_RXD1_GPIO_Port GPIOC 77 | #define LED_GREEN_Pin GPIO_PIN_0 78 | #define LED_GREEN_GPIO_Port GPIOB 79 | #define RMII_TXD1_Pin GPIO_PIN_13 80 | #define RMII_TXD1_GPIO_Port GPIOB 81 | #define LED_RED_Pin GPIO_PIN_14 82 | #define LED_RED_GPIO_Port GPIOB 83 | #define STLK_VCP_RX_Pin GPIO_PIN_8 84 | #define STLK_VCP_RX_GPIO_Port GPIOD 85 | #define STLK_VCP_TX_Pin GPIO_PIN_9 86 | #define STLK_VCP_TX_GPIO_Port GPIOD 87 | #define USB_FS_PWR_EN_Pin GPIO_PIN_10 88 | #define USB_FS_PWR_EN_GPIO_Port GPIOD 89 | #define USB_FS_OVCR_Pin GPIO_PIN_7 90 | #define USB_FS_OVCR_GPIO_Port GPIOG 91 | #define USB_FS_VBUS_Pin GPIO_PIN_9 92 | #define USB_FS_VBUS_GPIO_Port GPIOA 93 | #define USB_FS_ID_Pin GPIO_PIN_10 94 | #define USB_FS_ID_GPIO_Port GPIOA 95 | #define USB_FS_DM_Pin GPIO_PIN_11 96 | #define USB_FS_DM_GPIO_Port GPIOA 97 | #define USB_FS_DP_Pin GPIO_PIN_12 98 | #define USB_FS_DP_GPIO_Port GPIOA 99 | #define SWDIO_Pin GPIO_PIN_13 100 | #define SWDIO_GPIO_Port GPIOA 101 | #define SWCLK_Pin GPIO_PIN_14 102 | #define SWCLK_GPIO_Port GPIOA 103 | #define RMII_TX_EN_Pin GPIO_PIN_11 104 | #define RMII_TX_EN_GPIO_Port GPIOG 105 | #define RMII_TXD0_Pin GPIO_PIN_13 106 | #define RMII_TXD0_GPIO_Port GPIOG 107 | #define SWO_Pin GPIO_PIN_3 108 | #define SWO_GPIO_Port GPIOB 109 | #define LED_YELLOW_Pin GPIO_PIN_1 110 | #define LED_YELLOW_GPIO_Port GPIOE 111 | /* USER CODE BEGIN Private defines */ 112 | 113 | /* USER CODE END Private defines */ 114 | 115 | #ifdef __cplusplus 116 | } 117 | #endif 118 | 119 | #endif /* __MAIN_H */ 120 | 121 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 122 | -------------------------------------------------------------------------------- /reference_stm32cube_project/Core/Inc/stm32h7xx_it.h: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file stm32h7xx_it.h 5 | * @brief This file contains the headers of the interrupt handlers. 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | *

© Copyright (c) 2021 STMicroelectronics. 10 | * All rights reserved.

11 | * 12 | * This software component is licensed by ST under Ultimate Liberty license 13 | * SLA0044, the "License"; You may not use this file except in compliance with 14 | * the License. You may obtain a copy of the License at: 15 | * www.st.com/SLA0044 16 | * 17 | ****************************************************************************** 18 | */ 19 | /* USER CODE END Header */ 20 | 21 | /* Define to prevent recursive inclusion -------------------------------------*/ 22 | #ifndef __STM32H7xx_IT_H 23 | #define __STM32H7xx_IT_H 24 | 25 | #ifdef __cplusplus 26 | extern "C" { 27 | #endif 28 | 29 | /* Private includes ----------------------------------------------------------*/ 30 | /* USER CODE BEGIN Includes */ 31 | 32 | /* USER CODE END Includes */ 33 | 34 | /* Exported types ------------------------------------------------------------*/ 35 | /* USER CODE BEGIN ET */ 36 | 37 | /* USER CODE END ET */ 38 | 39 | /* Exported constants --------------------------------------------------------*/ 40 | /* USER CODE BEGIN EC */ 41 | 42 | /* USER CODE END EC */ 43 | 44 | /* Exported macro ------------------------------------------------------------*/ 45 | /* USER CODE BEGIN EM */ 46 | 47 | /* USER CODE END EM */ 48 | 49 | /* Exported functions prototypes ---------------------------------------------*/ 50 | void NMI_Handler(void); 51 | void HardFault_Handler(void); 52 | void MemManage_Handler(void); 53 | void BusFault_Handler(void); 54 | void UsageFault_Handler(void); 55 | void DebugMon_Handler(void); 56 | void TIM2_IRQHandler(void); 57 | /* USER CODE BEGIN EFP */ 58 | 59 | /* USER CODE END EFP */ 60 | 61 | #ifdef __cplusplus 62 | } 63 | #endif 64 | 65 | #endif /* __STM32H7xx_IT_H */ 66 | 67 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 68 | -------------------------------------------------------------------------------- /reference_stm32cube_project/Core/Src/freertos.c: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * File Name : freertos.c 5 | * Description : Code for freertos applications 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | *

© Copyright (c) 2021 STMicroelectronics. 10 | * All rights reserved.

11 | * 12 | * This software component is licensed by ST under Ultimate Liberty license 13 | * SLA0044, the "License"; You may not use this file except in compliance with 14 | * the License. You may obtain a copy of the License at: 15 | * www.st.com/SLA0044 16 | * 17 | ****************************************************************************** 18 | */ 19 | /* USER CODE END Header */ 20 | 21 | /* Includes ------------------------------------------------------------------*/ 22 | #include "FreeRTOS.h" 23 | #include "task.h" 24 | #include "main.h" 25 | 26 | /* Private includes ----------------------------------------------------------*/ 27 | /* USER CODE BEGIN Includes */ 28 | 29 | /* USER CODE END Includes */ 30 | 31 | /* Private typedef -----------------------------------------------------------*/ 32 | /* USER CODE BEGIN PTD */ 33 | 34 | /* USER CODE END PTD */ 35 | 36 | /* Private define ------------------------------------------------------------*/ 37 | /* USER CODE BEGIN PD */ 38 | 39 | /* USER CODE END PD */ 40 | 41 | /* Private macro -------------------------------------------------------------*/ 42 | /* USER CODE BEGIN PM */ 43 | 44 | /* USER CODE END PM */ 45 | 46 | /* Private variables ---------------------------------------------------------*/ 47 | /* USER CODE BEGIN Variables */ 48 | 49 | /* USER CODE END Variables */ 50 | 51 | /* Private function prototypes -----------------------------------------------*/ 52 | /* USER CODE BEGIN FunctionPrototypes */ 53 | 54 | /* USER CODE END FunctionPrototypes */ 55 | 56 | /* Private application code --------------------------------------------------*/ 57 | /* USER CODE BEGIN Application */ 58 | 59 | /* USER CODE END Application */ 60 | 61 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 62 | -------------------------------------------------------------------------------- /reference_stm32cube_project/Core/Src/stm32h7xx_hal_msp.c: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file stm32h7xx_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) 2021 STMicroelectronics. 11 | * All rights reserved.

12 | * 13 | * This software component is licensed by ST under Ultimate Liberty license 14 | * SLA0044, the "License"; You may not use this file except in compliance with 15 | * the License. You may obtain a copy of the License at: 16 | * www.st.com/SLA0044 17 | * 18 | ****************************************************************************** 19 | */ 20 | /* USER CODE END Header */ 21 | 22 | /* Includes ------------------------------------------------------------------*/ 23 | #include "main.h" 24 | /* USER CODE BEGIN Includes */ 25 | 26 | /* USER CODE END Includes */ 27 | 28 | /* Private typedef -----------------------------------------------------------*/ 29 | /* USER CODE BEGIN TD */ 30 | 31 | /* USER CODE END TD */ 32 | 33 | /* Private define ------------------------------------------------------------*/ 34 | /* USER CODE BEGIN Define */ 35 | 36 | /* USER CODE END Define */ 37 | 38 | /* Private macro -------------------------------------------------------------*/ 39 | /* USER CODE BEGIN Macro */ 40 | 41 | /* USER CODE END Macro */ 42 | 43 | /* Private variables ---------------------------------------------------------*/ 44 | /* USER CODE BEGIN PV */ 45 | 46 | /* USER CODE END PV */ 47 | 48 | /* Private function prototypes -----------------------------------------------*/ 49 | /* USER CODE BEGIN PFP */ 50 | 51 | /* USER CODE END PFP */ 52 | 53 | /* External functions --------------------------------------------------------*/ 54 | /* USER CODE BEGIN ExternalFunctions */ 55 | 56 | /* USER CODE END ExternalFunctions */ 57 | 58 | /* USER CODE BEGIN 0 */ 59 | 60 | /* USER CODE END 0 */ 61 | /** 62 | * Initializes the Global MSP. 63 | */ 64 | void HAL_MspInit(void) 65 | { 66 | /* USER CODE BEGIN MspInit 0 */ 67 | 68 | /* USER CODE END MspInit 0 */ 69 | 70 | __HAL_RCC_SYSCFG_CLK_ENABLE(); 71 | 72 | /* System interrupt init*/ 73 | /* PendSV_IRQn interrupt configuration */ 74 | HAL_NVIC_SetPriority(PendSV_IRQn, 15, 0); 75 | 76 | /* USER CODE BEGIN MspInit 1 */ 77 | 78 | /* USER CODE END MspInit 1 */ 79 | } 80 | 81 | /** 82 | * @brief ETH MSP Initialization 83 | * This function configures the hardware resources used in this example 84 | * @param heth: ETH handle pointer 85 | * @retval None 86 | */ 87 | void HAL_ETH_MspInit(ETH_HandleTypeDef* heth) 88 | { 89 | GPIO_InitTypeDef GPIO_InitStruct = {0}; 90 | if(heth->Instance==ETH) 91 | { 92 | /* USER CODE BEGIN ETH_MspInit 0 */ 93 | 94 | /* USER CODE END ETH_MspInit 0 */ 95 | /* Peripheral clock enable */ 96 | __HAL_RCC_ETH1MAC_CLK_ENABLE(); 97 | __HAL_RCC_ETH1TX_CLK_ENABLE(); 98 | __HAL_RCC_ETH1RX_CLK_ENABLE(); 99 | 100 | __HAL_RCC_GPIOC_CLK_ENABLE(); 101 | __HAL_RCC_GPIOA_CLK_ENABLE(); 102 | __HAL_RCC_GPIOB_CLK_ENABLE(); 103 | __HAL_RCC_GPIOG_CLK_ENABLE(); 104 | /**ETH GPIO Configuration 105 | PC1 ------> ETH_MDC 106 | PA1 ------> ETH_REF_CLK 107 | PA2 ------> ETH_MDIO 108 | PA7 ------> ETH_CRS_DV 109 | PC4 ------> ETH_RXD0 110 | PC5 ------> ETH_RXD1 111 | PB13 ------> ETH_TXD1 112 | PG11 ------> ETH_TX_EN 113 | PG13 ------> ETH_TXD0 114 | */ 115 | GPIO_InitStruct.Pin = RMII_MDC_Pin|RMII_RXD0_Pin|RMII_RXD1_Pin; 116 | GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; 117 | GPIO_InitStruct.Pull = GPIO_NOPULL; 118 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; 119 | GPIO_InitStruct.Alternate = GPIO_AF11_ETH; 120 | HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); 121 | 122 | GPIO_InitStruct.Pin = RMII_REF_CLK_Pin|RMII_MDIO_Pin|RMII_CRS_DV_Pin; 123 | GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; 124 | GPIO_InitStruct.Pull = GPIO_NOPULL; 125 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; 126 | GPIO_InitStruct.Alternate = GPIO_AF11_ETH; 127 | HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); 128 | 129 | GPIO_InitStruct.Pin = RMII_TXD1_Pin; 130 | GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; 131 | GPIO_InitStruct.Pull = GPIO_NOPULL; 132 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; 133 | GPIO_InitStruct.Alternate = GPIO_AF11_ETH; 134 | HAL_GPIO_Init(RMII_TXD1_GPIO_Port, &GPIO_InitStruct); 135 | 136 | GPIO_InitStruct.Pin = RMII_TX_EN_Pin|RMII_TXD0_Pin; 137 | GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; 138 | GPIO_InitStruct.Pull = GPIO_NOPULL; 139 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; 140 | GPIO_InitStruct.Alternate = GPIO_AF11_ETH; 141 | HAL_GPIO_Init(GPIOG, &GPIO_InitStruct); 142 | 143 | /* USER CODE BEGIN ETH_MspInit 1 */ 144 | 145 | /* USER CODE END ETH_MspInit 1 */ 146 | } 147 | 148 | } 149 | 150 | /** 151 | * @brief ETH MSP De-Initialization 152 | * This function freeze the hardware resources used in this example 153 | * @param heth: ETH handle pointer 154 | * @retval None 155 | */ 156 | void HAL_ETH_MspDeInit(ETH_HandleTypeDef* heth) 157 | { 158 | if(heth->Instance==ETH) 159 | { 160 | /* USER CODE BEGIN ETH_MspDeInit 0 */ 161 | 162 | /* USER CODE END ETH_MspDeInit 0 */ 163 | /* Peripheral clock disable */ 164 | __HAL_RCC_ETH1MAC_CLK_DISABLE(); 165 | __HAL_RCC_ETH1TX_CLK_DISABLE(); 166 | __HAL_RCC_ETH1RX_CLK_DISABLE(); 167 | 168 | /**ETH GPIO Configuration 169 | PC1 ------> ETH_MDC 170 | PA1 ------> ETH_REF_CLK 171 | PA2 ------> ETH_MDIO 172 | PA7 ------> ETH_CRS_DV 173 | PC4 ------> ETH_RXD0 174 | PC5 ------> ETH_RXD1 175 | PB13 ------> ETH_TXD1 176 | PG11 ------> ETH_TX_EN 177 | PG13 ------> ETH_TXD0 178 | */ 179 | HAL_GPIO_DeInit(GPIOC, RMII_MDC_Pin|RMII_RXD0_Pin|RMII_RXD1_Pin); 180 | 181 | HAL_GPIO_DeInit(GPIOA, RMII_REF_CLK_Pin|RMII_MDIO_Pin|RMII_CRS_DV_Pin); 182 | 183 | HAL_GPIO_DeInit(RMII_TXD1_GPIO_Port, RMII_TXD1_Pin); 184 | 185 | HAL_GPIO_DeInit(GPIOG, RMII_TX_EN_Pin|RMII_TXD0_Pin); 186 | 187 | /* USER CODE BEGIN ETH_MspDeInit 1 */ 188 | 189 | /* USER CODE END ETH_MspDeInit 1 */ 190 | } 191 | 192 | } 193 | 194 | /** 195 | * @brief UART MSP Initialization 196 | * This function configures the hardware resources used in this example 197 | * @param huart: UART handle pointer 198 | * @retval None 199 | */ 200 | void HAL_UART_MspInit(UART_HandleTypeDef* huart) 201 | { 202 | GPIO_InitTypeDef GPIO_InitStruct = {0}; 203 | RCC_PeriphCLKInitTypeDef PeriphClkInitStruct = {0}; 204 | if(huart->Instance==USART3) 205 | { 206 | /* USER CODE BEGIN USART3_MspInit 0 */ 207 | 208 | /* USER CODE END USART3_MspInit 0 */ 209 | /** Initializes the peripherals clock 210 | */ 211 | PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_USART3; 212 | PeriphClkInitStruct.Usart234578ClockSelection = RCC_USART234578CLKSOURCE_D2PCLK1; 213 | if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK) 214 | { 215 | Error_Handler(); 216 | } 217 | 218 | /* Peripheral clock enable */ 219 | __HAL_RCC_USART3_CLK_ENABLE(); 220 | 221 | __HAL_RCC_GPIOD_CLK_ENABLE(); 222 | /**USART3 GPIO Configuration 223 | PD8 ------> USART3_TX 224 | PD9 ------> USART3_RX 225 | */ 226 | GPIO_InitStruct.Pin = STLK_VCP_RX_Pin|STLK_VCP_TX_Pin; 227 | GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; 228 | GPIO_InitStruct.Pull = GPIO_NOPULL; 229 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; 230 | GPIO_InitStruct.Alternate = GPIO_AF7_USART3; 231 | HAL_GPIO_Init(GPIOD, &GPIO_InitStruct); 232 | 233 | /* USER CODE BEGIN USART3_MspInit 1 */ 234 | 235 | /* USER CODE END USART3_MspInit 1 */ 236 | } 237 | 238 | } 239 | 240 | /** 241 | * @brief UART MSP De-Initialization 242 | * This function freeze the hardware resources used in this example 243 | * @param huart: UART handle pointer 244 | * @retval None 245 | */ 246 | void HAL_UART_MspDeInit(UART_HandleTypeDef* huart) 247 | { 248 | if(huart->Instance==USART3) 249 | { 250 | /* USER CODE BEGIN USART3_MspDeInit 0 */ 251 | 252 | /* USER CODE END USART3_MspDeInit 0 */ 253 | /* Peripheral clock disable */ 254 | __HAL_RCC_USART3_CLK_DISABLE(); 255 | 256 | /**USART3 GPIO Configuration 257 | PD8 ------> USART3_TX 258 | PD9 ------> USART3_RX 259 | */ 260 | HAL_GPIO_DeInit(GPIOD, STLK_VCP_RX_Pin|STLK_VCP_TX_Pin); 261 | 262 | /* USER CODE BEGIN USART3_MspDeInit 1 */ 263 | 264 | /* USER CODE END USART3_MspDeInit 1 */ 265 | } 266 | 267 | } 268 | 269 | /* USER CODE BEGIN 1 */ 270 | 271 | /* USER CODE END 1 */ 272 | 273 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 274 | -------------------------------------------------------------------------------- /reference_stm32cube_project/Core/Src/stm32h7xx_hal_timebase_tim.c: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file stm32h7xx_hal_timebase_TIM.c 5 | * @brief HAL time base based on the hardware TIM. 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | *

© Copyright (c) 2021 STMicroelectronics. 10 | * All rights reserved.

11 | * 12 | * This software component is licensed by ST under Ultimate Liberty license 13 | * SLA0044, the "License"; You may not use this file except in compliance with 14 | * the License. You may obtain a copy of the License at: 15 | * www.st.com/SLA0044 16 | * 17 | ****************************************************************************** 18 | */ 19 | /* USER CODE END Header */ 20 | 21 | /* Includes ------------------------------------------------------------------*/ 22 | #include "stm32h7xx_hal.h" 23 | #include "stm32h7xx_hal_tim.h" 24 | 25 | /* Private typedef -----------------------------------------------------------*/ 26 | /* Private define ------------------------------------------------------------*/ 27 | /* Private macro -------------------------------------------------------------*/ 28 | /* Private variables ---------------------------------------------------------*/ 29 | TIM_HandleTypeDef htim2; 30 | /* Private function prototypes -----------------------------------------------*/ 31 | /* Private functions ---------------------------------------------------------*/ 32 | 33 | /** 34 | * @brief This function configures the TIM2 as a time base source. 35 | * The time source is configured to have 1ms time base with a dedicated 36 | * Tick interrupt priority. 37 | * @note This function is called automatically at the beginning of program after 38 | * reset by HAL_Init() or at any time when clock is configured, by HAL_RCC_ClockConfig(). 39 | * @param TickPriority: Tick interrupt priority. 40 | * @retval HAL status 41 | */ 42 | HAL_StatusTypeDef HAL_InitTick(uint32_t TickPriority) 43 | { 44 | RCC_ClkInitTypeDef clkconfig; 45 | uint32_t uwTimclock, uwAPB1Prescaler; 46 | 47 | uint32_t uwPrescalerValue; 48 | uint32_t pFLatency; 49 | /*Configure the TIM2 IRQ priority */ 50 | if (TickPriority < (1UL << __NVIC_PRIO_BITS)) 51 | { 52 | HAL_NVIC_SetPriority(TIM2_IRQn, TickPriority ,0U); 53 | 54 | /* Enable the TIM2 global Interrupt */ 55 | HAL_NVIC_EnableIRQ(TIM2_IRQn); 56 | uwTickPrio = TickPriority; 57 | } 58 | else 59 | { 60 | return HAL_ERROR; 61 | } 62 | /* Enable TIM2 clock */ 63 | __HAL_RCC_TIM2_CLK_ENABLE(); 64 | 65 | /* Get clock configuration */ 66 | HAL_RCC_GetClockConfig(&clkconfig, &pFLatency); 67 | 68 | /* Get APB1 prescaler */ 69 | uwAPB1Prescaler = clkconfig.APB1CLKDivider; 70 | /* Compute TIM2 clock */ 71 | if (uwAPB1Prescaler == RCC_HCLK_DIV1) 72 | { 73 | uwTimclock = HAL_RCC_GetPCLK1Freq(); 74 | } 75 | else 76 | { 77 | uwTimclock = 2UL * HAL_RCC_GetPCLK1Freq(); 78 | } 79 | 80 | /* Compute the prescaler value to have TIM2 counter clock equal to 1MHz */ 81 | uwPrescalerValue = (uint32_t) ((uwTimclock / 1000000U) - 1U); 82 | 83 | /* Initialize TIM2 */ 84 | htim2.Instance = TIM2; 85 | 86 | /* Initialize TIMx peripheral as follow: 87 | + Period = [(TIM2CLK/1000) - 1]. to have a (1/1000) s time base. 88 | + Prescaler = (uwTimclock/1000000 - 1) to have a 1MHz counter clock. 89 | + ClockDivision = 0 90 | + Counter direction = Up 91 | */ 92 | htim2.Init.Period = (1000000U / 1000U) - 1U; 93 | htim2.Init.Prescaler = uwPrescalerValue; 94 | htim2.Init.ClockDivision = 0; 95 | htim2.Init.CounterMode = TIM_COUNTERMODE_UP; 96 | if(HAL_TIM_Base_Init(&htim2) == HAL_OK) 97 | { 98 | /* Start the TIM time Base generation in interrupt mode */ 99 | return HAL_TIM_Base_Start_IT(&htim2); 100 | } 101 | 102 | /* Return function status */ 103 | return HAL_ERROR; 104 | } 105 | 106 | /** 107 | * @brief Suspend Tick increment. 108 | * @note Disable the tick increment by disabling TIM2 update interrupt. 109 | * @param None 110 | * @retval None 111 | */ 112 | void HAL_SuspendTick(void) 113 | { 114 | /* Disable TIM2 update Interrupt */ 115 | __HAL_TIM_DISABLE_IT(&htim2, TIM_IT_UPDATE); 116 | } 117 | 118 | /** 119 | * @brief Resume Tick increment. 120 | * @note Enable the tick increment by Enabling TIM2 update interrupt. 121 | * @param None 122 | * @retval None 123 | */ 124 | void HAL_ResumeTick(void) 125 | { 126 | /* Enable TIM2 Update interrupt */ 127 | __HAL_TIM_ENABLE_IT(&htim2, TIM_IT_UPDATE); 128 | } 129 | 130 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 131 | -------------------------------------------------------------------------------- /reference_stm32cube_project/Core/Src/stm32h7xx_it.c: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file stm32h7xx_it.c 5 | * @brief Interrupt Service Routines. 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | *

© Copyright (c) 2021 STMicroelectronics. 10 | * All rights reserved.

11 | * 12 | * This software component is licensed by ST under Ultimate Liberty license 13 | * SLA0044, the "License"; You may not use this file except in compliance with 14 | * the License. You may obtain a copy of the License at: 15 | * www.st.com/SLA0044 16 | * 17 | ****************************************************************************** 18 | */ 19 | /* USER CODE END Header */ 20 | 21 | /* Includes ------------------------------------------------------------------*/ 22 | #include "main.h" 23 | #include "stm32h7xx_it.h" 24 | /* Private includes ----------------------------------------------------------*/ 25 | /* USER CODE BEGIN Includes */ 26 | /* USER CODE END Includes */ 27 | 28 | /* Private typedef -----------------------------------------------------------*/ 29 | /* USER CODE BEGIN TD */ 30 | 31 | /* USER CODE END TD */ 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 | /* USER CODE BEGIN PV */ 45 | 46 | /* USER CODE END PV */ 47 | 48 | /* Private function prototypes -----------------------------------------------*/ 49 | /* USER CODE BEGIN PFP */ 50 | 51 | /* USER CODE END PFP */ 52 | 53 | /* Private user code ---------------------------------------------------------*/ 54 | /* USER CODE BEGIN 0 */ 55 | 56 | /* USER CODE END 0 */ 57 | 58 | /* External variables --------------------------------------------------------*/ 59 | extern TIM_HandleTypeDef htim2; 60 | 61 | /* USER CODE BEGIN EV */ 62 | 63 | /* USER CODE END EV */ 64 | 65 | /******************************************************************************/ 66 | /* Cortex Processor Interruption and Exception Handlers */ 67 | /******************************************************************************/ 68 | /** 69 | * @brief This function handles Non maskable interrupt. 70 | */ 71 | void NMI_Handler(void) 72 | { 73 | /* USER CODE BEGIN NonMaskableInt_IRQn 0 */ 74 | 75 | /* USER CODE END NonMaskableInt_IRQn 0 */ 76 | /* USER CODE BEGIN NonMaskableInt_IRQn 1 */ 77 | while (1) 78 | { 79 | } 80 | /* USER CODE END NonMaskableInt_IRQn 1 */ 81 | } 82 | 83 | /** 84 | * @brief This function handles Hard fault interrupt. 85 | */ 86 | void HardFault_Handler(void) 87 | { 88 | /* USER CODE BEGIN HardFault_IRQn 0 */ 89 | 90 | /* USER CODE END HardFault_IRQn 0 */ 91 | while (1) 92 | { 93 | /* USER CODE BEGIN W1_HardFault_IRQn 0 */ 94 | /* USER CODE END W1_HardFault_IRQn 0 */ 95 | } 96 | } 97 | 98 | /** 99 | * @brief This function handles Memory management fault. 100 | */ 101 | void MemManage_Handler(void) 102 | { 103 | /* USER CODE BEGIN MemoryManagement_IRQn 0 */ 104 | 105 | /* USER CODE END MemoryManagement_IRQn 0 */ 106 | while (1) 107 | { 108 | /* USER CODE BEGIN W1_MemoryManagement_IRQn 0 */ 109 | /* USER CODE END W1_MemoryManagement_IRQn 0 */ 110 | } 111 | } 112 | 113 | /** 114 | * @brief This function handles Pre-fetch fault, memory access fault. 115 | */ 116 | void BusFault_Handler(void) 117 | { 118 | /* USER CODE BEGIN BusFault_IRQn 0 */ 119 | 120 | /* USER CODE END BusFault_IRQn 0 */ 121 | while (1) 122 | { 123 | /* USER CODE BEGIN W1_BusFault_IRQn 0 */ 124 | /* USER CODE END W1_BusFault_IRQn 0 */ 125 | } 126 | } 127 | 128 | /** 129 | * @brief This function handles Undefined instruction or illegal state. 130 | */ 131 | void UsageFault_Handler(void) 132 | { 133 | /* USER CODE BEGIN UsageFault_IRQn 0 */ 134 | 135 | /* USER CODE END UsageFault_IRQn 0 */ 136 | while (1) 137 | { 138 | /* USER CODE BEGIN W1_UsageFault_IRQn 0 */ 139 | /* USER CODE END W1_UsageFault_IRQn 0 */ 140 | } 141 | } 142 | 143 | /** 144 | * @brief This function handles Debug monitor. 145 | */ 146 | void DebugMon_Handler(void) 147 | { 148 | /* USER CODE BEGIN DebugMonitor_IRQn 0 */ 149 | 150 | /* USER CODE END DebugMonitor_IRQn 0 */ 151 | /* USER CODE BEGIN DebugMonitor_IRQn 1 */ 152 | 153 | /* USER CODE END DebugMonitor_IRQn 1 */ 154 | } 155 | 156 | /******************************************************************************/ 157 | /* STM32H7xx Peripheral Interrupt Handlers */ 158 | /* Add here the Interrupt Handlers for the used peripherals. */ 159 | /* For the available peripheral interrupt handler names, */ 160 | /* please refer to the startup file (startup_stm32h7xx.s). */ 161 | /******************************************************************************/ 162 | 163 | /** 164 | * @brief This function handles TIM2 global interrupt. 165 | */ 166 | void TIM2_IRQHandler(void) 167 | { 168 | /* USER CODE BEGIN TIM2_IRQn 0 */ 169 | 170 | /* USER CODE END TIM2_IRQn 0 */ 171 | HAL_TIM_IRQHandler(&htim2); 172 | /* USER CODE BEGIN TIM2_IRQn 1 */ 173 | 174 | /* USER CODE END TIM2_IRQn 1 */ 175 | } 176 | 177 | /* USER CODE BEGIN 1 */ 178 | 179 | /* USER CODE END 1 */ 180 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 181 | -------------------------------------------------------------------------------- /reference_stm32cube_project/Core/Src/syscalls.c: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file syscalls.c 4 | * @author Auto-generated by STM32CubeIDE 5 | * @brief STM32CubeIDE 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 STMicroelectronics. 14 | * All rights reserved.

15 | * 16 | * This software component is licensed by ST under BSD 3-Clause license, 17 | * the "License"; You may not use this file except in compliance with the 18 | * License. You may obtain a copy of the License at: 19 | * opensource.org/licenses/BSD-3-Clause 20 | * 21 | ****************************************************************************** 22 | */ 23 | 24 | /* Includes */ 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | 34 | 35 | /* Variables */ 36 | extern int __io_putchar(int ch) __attribute__((weak)); 37 | extern int __io_getchar(void) __attribute__((weak)); 38 | 39 | 40 | char *__env[1] = { 0 }; 41 | char **environ = __env; 42 | 43 | 44 | /* Functions */ 45 | void initialise_monitor_handles() 46 | { 47 | } 48 | 49 | int _getpid(void) 50 | { 51 | return 1; 52 | } 53 | 54 | int _kill(int pid, int sig) 55 | { 56 | errno = EINVAL; 57 | return -1; 58 | } 59 | 60 | void _exit (int status) 61 | { 62 | _kill(status, -1); 63 | while (1) {} /* Make sure we hang here */ 64 | } 65 | 66 | __attribute__((weak)) int _read(int file, char *ptr, int len) 67 | { 68 | int DataIdx; 69 | 70 | for (DataIdx = 0; DataIdx < len; DataIdx++) 71 | { 72 | *ptr++ = __io_getchar(); 73 | } 74 | 75 | return len; 76 | } 77 | 78 | __attribute__((weak)) int _write(int file, char *ptr, int len) 79 | { 80 | int DataIdx; 81 | 82 | for (DataIdx = 0; DataIdx < len; DataIdx++) 83 | { 84 | __io_putchar(*ptr++); 85 | } 86 | return len; 87 | } 88 | 89 | int _close(int file) 90 | { 91 | return -1; 92 | } 93 | 94 | 95 | int _fstat(int file, struct stat *st) 96 | { 97 | st->st_mode = S_IFCHR; 98 | return 0; 99 | } 100 | 101 | int _isatty(int file) 102 | { 103 | return 1; 104 | } 105 | 106 | int _lseek(int file, int ptr, int dir) 107 | { 108 | return 0; 109 | } 110 | 111 | int _open(char *path, int flags, ...) 112 | { 113 | /* Pretend like we always fail */ 114 | return -1; 115 | } 116 | 117 | int _wait(int *status) 118 | { 119 | errno = ECHILD; 120 | return -1; 121 | } 122 | 123 | int _unlink(char *name) 124 | { 125 | errno = ENOENT; 126 | return -1; 127 | } 128 | 129 | int _times(struct tms *buf) 130 | { 131 | return -1; 132 | } 133 | 134 | int _stat(char *file, struct stat *st) 135 | { 136 | st->st_mode = S_IFCHR; 137 | return 0; 138 | } 139 | 140 | int _link(char *old, char *new) 141 | { 142 | errno = EMLINK; 143 | return -1; 144 | } 145 | 146 | int _fork(void) 147 | { 148 | errno = EAGAIN; 149 | return -1; 150 | } 151 | 152 | int _execve(char *name, char **argv, char **env) 153 | { 154 | errno = ENOMEM; 155 | return -1; 156 | } 157 | -------------------------------------------------------------------------------- /reference_stm32cube_project/Core/Src/sysmem.c: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file sysmem.c 4 | * @author Generated by STM32CubeIDE 5 | * @brief STM32CubeIDE 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) 2020 STMicroelectronics. 14 | * All rights reserved.

15 | * 16 | * This software component is licensed by ST under BSD 3-Clause license, 17 | * the "License"; You may not use this file except in compliance with the 18 | * License. You may obtain a copy of the License at: 19 | * opensource.org/licenses/BSD-3-Clause 20 | * 21 | ****************************************************************************** 22 | */ 23 | 24 | /* Includes */ 25 | #include 26 | #include 27 | 28 | /** 29 | * Pointer to the current high watermark of the heap usage 30 | */ 31 | static uint8_t *__sbrk_heap_end = NULL; 32 | 33 | /** 34 | * @brief _sbrk() allocates memory to the newlib heap and is used by malloc 35 | * and others from the C library 36 | * 37 | * @verbatim 38 | * ############################################################################ 39 | * # .data # .bss # newlib heap # MSP stack # 40 | * # # # # Reserved by _Min_Stack_Size # 41 | * ############################################################################ 42 | * ^-- RAM start ^-- _end _estack, RAM end --^ 43 | * @endverbatim 44 | * 45 | * This implementation starts allocating at the '_end' linker symbol 46 | * The '_Min_Stack_Size' linker symbol reserves a memory for the MSP stack 47 | * The implementation considers '_estack' linker symbol to be RAM end 48 | * NOTE: If the MSP stack, at any point during execution, grows larger than the 49 | * reserved size, please increase the '_Min_Stack_Size'. 50 | * 51 | * @param incr Memory size 52 | * @return Pointer to allocated memory 53 | */ 54 | void *_sbrk(ptrdiff_t incr) 55 | { 56 | extern uint8_t _end; /* Symbol defined in the linker script */ 57 | extern uint8_t _estack; /* Symbol defined in the linker script */ 58 | extern uint32_t _Min_Stack_Size; /* Symbol defined in the linker script */ 59 | const uint32_t stack_limit = (uint32_t)&_estack - (uint32_t)&_Min_Stack_Size; 60 | const uint8_t *max_heap = (uint8_t *)stack_limit; 61 | uint8_t *prev_heap_end; 62 | 63 | /* Initialize heap end at first call */ 64 | if (NULL == __sbrk_heap_end) 65 | { 66 | __sbrk_heap_end = &_end; 67 | } 68 | 69 | /* Protect heap from growing into the reserved MSP stack */ 70 | if (__sbrk_heap_end + incr > max_heap) 71 | { 72 | errno = ENOMEM; 73 | return (void *)-1; 74 | } 75 | 76 | prev_heap_end = __sbrk_heap_end; 77 | __sbrk_heap_end += incr; 78 | 79 | return (void *)prev_heap_end; 80 | } 81 | -------------------------------------------------------------------------------- /reference_stm32cube_project/Drivers/CMSIS/Device/ST/STM32H7xx/Include/stm32h7xx.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxgerhardt/pio-stm32h7-stm32cube-freertos/86b416892881ae4cc84ac4ffedcdfdfde0c02edf/reference_stm32cube_project/Drivers/CMSIS/Device/ST/STM32H7xx/Include/stm32h7xx.h -------------------------------------------------------------------------------- /reference_stm32cube_project/Drivers/CMSIS/Device/ST/STM32H7xx/Include/system_stm32h7xx.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file system_stm32h7xx.h 4 | * @author MCD Application Team 5 | * @brief CMSIS Cortex-Mx Device System Source File for STM32H7xx devices. 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | *

© Copyright (c) 2017 STMicroelectronics. 10 | * All rights reserved.

11 | * 12 | * This software component is licensed by ST under BSD 3-Clause license, 13 | * the "License"; You may not use this file except in compliance with the 14 | * License. You may obtain a copy of the License at: 15 | * opensource.org/licenses/BSD-3-Clause 16 | * 17 | ****************************************************************************** 18 | */ 19 | 20 | /** @addtogroup CMSIS 21 | * @{ 22 | */ 23 | 24 | /** @addtogroup stm32h7xx_system 25 | * @{ 26 | */ 27 | 28 | /** 29 | * @brief Define to prevent recursive inclusion 30 | */ 31 | #ifndef SYSTEM_STM32H7XX_H 32 | #define SYSTEM_STM32H7XX_H 33 | 34 | #ifdef __cplusplus 35 | extern "C" { 36 | #endif 37 | 38 | /** @addtogroup STM32H7xx_System_Includes 39 | * @{ 40 | */ 41 | 42 | /** 43 | * @} 44 | */ 45 | 46 | 47 | /** @addtogroup STM32H7xx_System_Exported_types 48 | * @{ 49 | */ 50 | /* This variable is updated in three ways: 51 | 1) by calling CMSIS function SystemCoreClockUpdate() 52 | 2) by calling HAL API function HAL_RCC_GetSysClockFreq() 53 | 3) each time HAL_RCC_ClockConfig() is called to configure the system clock frequency 54 | Note: If you use this function to configure the system clock; then there 55 | is no need to call the 2 first functions listed above, since SystemCoreClock 56 | variable is updated automatically. 57 | */ 58 | extern uint32_t SystemCoreClock; /*!< System Domain1 Clock Frequency */ 59 | extern uint32_t SystemD2Clock; /*!< System Domain2 Clock Frequency */ 60 | extern const uint8_t D1CorePrescTable[16] ; /*!< D1CorePrescTable prescalers table values */ 61 | 62 | /** 63 | * @} 64 | */ 65 | 66 | /** @addtogroup STM32H7xx_System_Exported_Constants 67 | * @{ 68 | */ 69 | 70 | /** 71 | * @} 72 | */ 73 | 74 | /** @addtogroup STM32H7xx_System_Exported_Macros 75 | * @{ 76 | */ 77 | 78 | /** 79 | * @} 80 | */ 81 | 82 | /** @addtogroup STM32H7xx_System_Exported_Functions 83 | * @{ 84 | */ 85 | 86 | extern void SystemInit(void); 87 | extern void SystemCoreClockUpdate(void); 88 | /** 89 | * @} 90 | */ 91 | 92 | #ifdef __cplusplus 93 | } 94 | #endif 95 | 96 | #endif /* SYSTEM_STM32H7XX_H */ 97 | 98 | /** 99 | * @} 100 | */ 101 | 102 | /** 103 | * @} 104 | */ 105 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 106 | -------------------------------------------------------------------------------- /reference_stm32cube_project/Drivers/CMSIS/Include/cmsis_version.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************//** 2 | * @file cmsis_version.h 3 | * @brief CMSIS Core(M) Version definitions 4 | * @version V5.0.3 5 | * @date 24. June 2019 6 | ******************************************************************************/ 7 | /* 8 | * Copyright (c) 2009-2019 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 ( 3U) /*!< [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 | -------------------------------------------------------------------------------- /reference_stm32cube_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 | -------------------------------------------------------------------------------- /reference_stm32cube_project/Drivers/STM32H7xx_HAL_Driver/Inc/stm32h7xx_hal_def.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32h7xx_hal_def.h 4 | * @author MCD Application Team 5 | * @brief This file contains HAL common defines, enumeration, macros and 6 | * structures definitions. 7 | ****************************************************************************** 8 | * @attention 9 | * 10 | *

© Copyright (c) 2017 STMicroelectronics. 11 | * All rights reserved.

12 | * 13 | * This software component is licensed by ST under BSD 3-Clause license, 14 | * the "License"; You may not use this file except in compliance with the 15 | * License. You may obtain a copy of the License at: 16 | * opensource.org/licenses/BSD-3-Clause 17 | * 18 | ****************************************************************************** 19 | */ 20 | 21 | /* Define to prevent recursive inclusion -------------------------------------*/ 22 | #ifndef STM32H7xx_HAL_DEF 23 | #define STM32H7xx_HAL_DEF 24 | 25 | #ifdef __cplusplus 26 | extern "C" { 27 | #endif 28 | 29 | /* Includes ------------------------------------------------------------------*/ 30 | #include "stm32h7xx.h" 31 | #include "Legacy/stm32_hal_legacy.h" 32 | #include 33 | #include 34 | 35 | /* Exported types ------------------------------------------------------------*/ 36 | 37 | /** 38 | * @brief HAL Status structures definition 39 | */ 40 | typedef enum 41 | { 42 | HAL_OK = 0x00, 43 | HAL_ERROR = 0x01, 44 | HAL_BUSY = 0x02, 45 | HAL_TIMEOUT = 0x03 46 | } HAL_StatusTypeDef; 47 | 48 | /** 49 | * @brief HAL Lock structures definition 50 | */ 51 | typedef enum 52 | { 53 | HAL_UNLOCKED = 0x00, 54 | HAL_LOCKED = 0x01 55 | } HAL_LockTypeDef; 56 | 57 | /* Exported macro ------------------------------------------------------------*/ 58 | 59 | #define HAL_MAX_DELAY 0xFFFFFFFFU 60 | 61 | #define HAL_IS_BIT_SET(REG, BIT) (((REG) & (BIT)) == (BIT)) 62 | #define HAL_IS_BIT_CLR(REG, BIT) (((REG) & (BIT)) == 0U) 63 | 64 | #define __HAL_LINKDMA(__HANDLE__, __PPP_DMA_FIELD__, __DMA_HANDLE__) \ 65 | do{ \ 66 | (__HANDLE__)->__PPP_DMA_FIELD__ = &(__DMA_HANDLE__); \ 67 | (__DMA_HANDLE__).Parent = (__HANDLE__); \ 68 | } while(0) 69 | 70 | #define UNUSED(x) ((void)(x)) 71 | 72 | /** @brief Reset the Handle's State field. 73 | * @param __HANDLE__: specifies the Peripheral Handle. 74 | * @note This macro can be used for the following purpose: 75 | * - When the Handle is declared as local variable; before passing it as parameter 76 | * to HAL_PPP_Init() for the first time, it is mandatory to use this macro 77 | * to set to 0 the Handle's "State" field. 78 | * Otherwise, "State" field may have any random value and the first time the function 79 | * HAL_PPP_Init() is called, the low level hardware initialization will be missed 80 | * (i.e. HAL_PPP_MspInit() will not be executed). 81 | * - When there is a need to reconfigure the low level hardware: instead of calling 82 | * HAL_PPP_DeInit() then HAL_PPP_Init(), user can make a call to this macro then HAL_PPP_Init(). 83 | * In this later function, when the Handle's "State" field is set to 0, it will execute the function 84 | * HAL_PPP_MspInit() which will reconfigure the low level hardware. 85 | * @retval None 86 | */ 87 | #define __HAL_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = 0) 88 | 89 | #if (USE_RTOS == 1) 90 | #error " USE_RTOS should be 0 in the current HAL release " 91 | #else 92 | #define __HAL_LOCK(__HANDLE__) \ 93 | do{ \ 94 | if((__HANDLE__)->Lock == HAL_LOCKED) \ 95 | { \ 96 | return HAL_BUSY; \ 97 | } \ 98 | else \ 99 | { \ 100 | (__HANDLE__)->Lock = HAL_LOCKED; \ 101 | } \ 102 | }while (0) 103 | 104 | #define __HAL_UNLOCK(__HANDLE__) \ 105 | do{ \ 106 | (__HANDLE__)->Lock = HAL_UNLOCKED; \ 107 | }while (0) 108 | #endif /* USE_RTOS */ 109 | 110 | 111 | #if defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) /* ARM Compiler V6 */ 112 | #ifndef __weak 113 | #define __weak __attribute__((weak)) 114 | #endif 115 | #ifndef __packed 116 | #define __packed __attribute__((packed)) 117 | #endif 118 | #elif defined ( __GNUC__ ) && !defined (__CC_ARM) /* GNU Compiler */ 119 | #ifndef __weak 120 | #define __weak __attribute__((weak)) 121 | #endif /* __weak */ 122 | #ifndef __packed 123 | #define __packed __attribute__((__packed__)) 124 | #endif /* __packed */ 125 | #endif /* __GNUC__ */ 126 | 127 | 128 | /* Macro to get variable aligned on 4-bytes, for __ICCARM__ the directive "#pragma data_alignment=4" must be used instead */ 129 | #if defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) /* ARM Compiler V6 */ 130 | #ifndef __ALIGN_BEGIN 131 | #define __ALIGN_BEGIN 132 | #endif 133 | #ifndef __ALIGN_END 134 | #define __ALIGN_END __attribute__ ((aligned (4))) 135 | #endif 136 | #elif defined ( __GNUC__ ) && !defined (__CC_ARM) /* GNU Compiler */ 137 | #ifndef __ALIGN_END 138 | #define __ALIGN_END __attribute__ ((aligned (4))) 139 | #endif /* __ALIGN_END */ 140 | #ifndef __ALIGN_BEGIN 141 | #define __ALIGN_BEGIN 142 | #endif /* __ALIGN_BEGIN */ 143 | #else 144 | #ifndef __ALIGN_END 145 | #define __ALIGN_END 146 | #endif /* __ALIGN_END */ 147 | #ifndef __ALIGN_BEGIN 148 | #if defined (__CC_ARM) /* ARM Compiler V5 */ 149 | #define __ALIGN_BEGIN __align(4) 150 | #elif defined (__ICCARM__) /* IAR Compiler */ 151 | #define __ALIGN_BEGIN 152 | #endif /* __CC_ARM */ 153 | #endif /* __ALIGN_BEGIN */ 154 | #endif /* __GNUC__ */ 155 | 156 | /* Macro to get variable aligned on 32-bytes,needed for cache maintenance purpose */ 157 | #if defined (__GNUC__) /* GNU Compiler */ 158 | #define ALIGN_32BYTES(buf) buf __attribute__ ((aligned (32))) 159 | #elif defined (__ICCARM__) /* IAR Compiler */ 160 | #define ALIGN_32BYTES(buf) _Pragma("data_alignment=32") buf 161 | #elif defined (__CC_ARM) /* ARM Compiler */ 162 | #define ALIGN_32BYTES(buf) __align(32) buf 163 | #endif 164 | 165 | /** 166 | * @brief __RAM_FUNC definition 167 | */ 168 | #if defined ( __CC_ARM ) || (defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)) 169 | /* ARM Compiler V4/V5 and V6 170 | -------------------------- 171 | RAM functions are defined using the toolchain options. 172 | Functions that are executed in RAM should reside in a separate source module. 173 | Using the 'Options for File' dialog you can simply change the 'Code / Const' 174 | area of a module to a memory space in physical RAM. 175 | Available memory areas are declared in the 'Target' tab of the 'Options for Target' 176 | dialog. 177 | */ 178 | #define __RAM_FUNC 179 | 180 | #elif defined ( __ICCARM__ ) 181 | /* ICCARM Compiler 182 | --------------- 183 | RAM functions are defined using a specific toolchain keyword "__ramfunc". 184 | */ 185 | #define __RAM_FUNC __ramfunc 186 | 187 | #elif defined ( __GNUC__ ) 188 | /* GNU Compiler 189 | ------------ 190 | RAM functions are defined using a specific toolchain attribute 191 | "__attribute__((section(".RamFunc")))". 192 | */ 193 | #define __RAM_FUNC __attribute__((section(".RamFunc"))) 194 | 195 | #endif 196 | 197 | /** 198 | * @brief __NOINLINE definition 199 | */ 200 | #if defined ( __CC_ARM ) || (defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)) || defined ( __GNUC__ ) 201 | /* ARM V4/V5 and V6 & GNU Compiler 202 | ------------------------------- 203 | */ 204 | #define __NOINLINE __attribute__ ( (noinline) ) 205 | 206 | #elif defined ( __ICCARM__ ) 207 | /* ICCARM Compiler 208 | --------------- 209 | */ 210 | #define __NOINLINE _Pragma("optimize = no_inline") 211 | 212 | #endif 213 | 214 | 215 | #ifdef __cplusplus 216 | } 217 | #endif 218 | 219 | #endif /* STM32H7xx_HAL_DEF */ 220 | 221 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 222 | -------------------------------------------------------------------------------- /reference_stm32cube_project/Drivers/STM32H7xx_HAL_Driver/Inc/stm32h7xx_hal_hsem.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32h7xx_hal_hsem.h 4 | * @author MCD Application Team 5 | * @brief Header file of HSEM HAL module. 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | *

© Copyright (c) 2017 STMicroelectronics. 10 | * All rights reserved.

11 | * 12 | * This software component is licensed by ST under BSD 3-Clause license, 13 | * the "License"; You may not use this file except in compliance with the 14 | * License. You may obtain a copy of the License at: 15 | * opensource.org/licenses/BSD-3-Clause 16 | * 17 | ****************************************************************************** 18 | */ 19 | 20 | /* Define to prevent recursive inclusion -------------------------------------*/ 21 | #ifndef STM32H7xx_HAL_HSEM_H 22 | #define STM32H7xx_HAL_HSEM_H 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | /* Includes ------------------------------------------------------------------*/ 29 | #include "stm32h7xx_hal_def.h" 30 | 31 | /** @addtogroup STM32H7xx_HAL_Driver 32 | * @{ 33 | */ 34 | 35 | /** @addtogroup HSEM 36 | * @{ 37 | */ 38 | 39 | /* Exported macro ------------------------------------------------------------*/ 40 | /** @defgroup HSEM_Exported_Macros HSEM Exported Macros 41 | * @{ 42 | */ 43 | 44 | /** 45 | * @brief SemID to mask helper Macro. 46 | * @param __SEMID__: semaphore ID from 0 to 31 47 | * @retval Semaphore Mask. 48 | */ 49 | #define __HAL_HSEM_SEMID_TO_MASK(__SEMID__) (1 << (__SEMID__)) 50 | 51 | /** 52 | * @brief Enables the specified HSEM interrupts. 53 | * @param __SEM_MASK__: semaphores Mask 54 | * @retval None. 55 | */ 56 | #if defined(DUAL_CORE) 57 | #define __HAL_HSEM_ENABLE_IT(__SEM_MASK__) ((((SCB->CPUID & 0x000000F0) >> 4 )== 0x7) ? \ 58 | (HSEM->C1IER |= (__SEM_MASK__)) : \ 59 | (HSEM->C2IER |= (__SEM_MASK__))) 60 | #else 61 | #define __HAL_HSEM_ENABLE_IT(__SEM_MASK__) (HSEM->IER |= (__SEM_MASK__)) 62 | #endif /* DUAL_CORE */ 63 | /** 64 | * @brief Disables the specified HSEM interrupts. 65 | * @param __SEM_MASK__: semaphores Mask 66 | * @retval None. 67 | */ 68 | #if defined(DUAL_CORE) 69 | #define __HAL_HSEM_DISABLE_IT(__SEM_MASK__) ((((SCB->CPUID & 0x000000F0) >> 4 )== 0x7) ? \ 70 | (HSEM->C1IER &= ~(__SEM_MASK__)) : \ 71 | (HSEM->C2IER &= ~(__SEM_MASK__))) 72 | #else 73 | #define __HAL_HSEM_DISABLE_IT(__SEM_MASK__) (HSEM->IER &= ~(__SEM_MASK__)) 74 | #endif /* DUAL_CORE */ 75 | 76 | /** 77 | * @brief Checks whether interrupt has occurred or not for semaphores specified by a mask. 78 | * @param __SEM_MASK__: semaphores Mask 79 | * @retval semaphores Mask : Semaphores where an interrupt occurred. 80 | */ 81 | #if defined(DUAL_CORE) 82 | #define __HAL_HSEM_GET_IT(__SEM_MASK__) ((((SCB->CPUID & 0x000000F0) >> 4 )== 0x7) ? \ 83 | ((__SEM_MASK__) & HSEM->C1MISR) : \ 84 | ((__SEM_MASK__) & HSEM->C2MISR1)) 85 | #else 86 | #define __HAL_HSEM_GET_IT(__SEM_MASK__) ((__SEM_MASK__) & HSEM->MISR) 87 | #endif /* DUAL_CORE */ 88 | 89 | /** 90 | * @brief Get the semaphores release status flags. 91 | * @param __SEM_MASK__: semaphores Mask 92 | * @retval semaphores Mask : Semaphores where Release flags rise. 93 | */ 94 | #if defined(DUAL_CORE) 95 | #define __HAL_HSEM_GET_FLAG(__SEM_MASK__) ((((SCB->CPUID & 0x000000F0) >> 4 )== 0x7) ? \ 96 | (__SEM_MASK__) & HSEM->C1ISR : \ 97 | (__SEM_MASK__) & HSEM->C2ISR) 98 | #else 99 | #define __HAL_HSEM_GET_FLAG(__SEM_MASK__) ((__SEM_MASK__) & HSEM->ISR) 100 | #endif /* DUAL_CORE */ 101 | 102 | /** 103 | * @brief Clears the HSEM Interrupt flags. 104 | * @param __SEM_MASK__: semaphores Mask 105 | * @retval None. 106 | */ 107 | #if defined(DUAL_CORE) 108 | #define __HAL_HSEM_CLEAR_FLAG(__SEM_MASK__) ((((SCB->CPUID & 0x000000F0) >> 4 )== 0x7) ? \ 109 | (HSEM->C1ICR |= (__SEM_MASK__)) : \ 110 | (HSEM->C2ICR |= (__SEM_MASK__))) 111 | #else 112 | #define __HAL_HSEM_CLEAR_FLAG(__SEM_MASK__) (HSEM->ICR |= (__SEM_MASK__)) 113 | #endif /* DUAL_CORE */ 114 | 115 | /** 116 | * @} 117 | */ 118 | 119 | /* Exported functions --------------------------------------------------------*/ 120 | /** @defgroup HSEM_Exported_Functions HSEM Exported Functions 121 | * @{ 122 | */ 123 | 124 | /** @addtogroup HSEM_Exported_Functions_Group1 Take and Release functions 125 | * @brief HSEM Take and Release functions 126 | * @{ 127 | */ 128 | 129 | /* HSEM semaphore take (lock) using 2-Step method ****************************/ 130 | HAL_StatusTypeDef HAL_HSEM_Take(uint32_t SemID, uint32_t ProcessID); 131 | /* HSEM semaphore fast take (lock) using 1-Step method ***********************/ 132 | HAL_StatusTypeDef HAL_HSEM_FastTake(uint32_t SemID); 133 | /* HSEM Check semaphore state Taken or not **********************************/ 134 | uint32_t HAL_HSEM_IsSemTaken(uint32_t SemID); 135 | /* HSEM Release **************************************************************/ 136 | void HAL_HSEM_Release(uint32_t SemID, uint32_t ProcessID); 137 | /* HSEM Release All************************************************************/ 138 | void HAL_HSEM_ReleaseAll(uint32_t Key, uint32_t CoreID); 139 | 140 | /** 141 | * @} 142 | */ 143 | 144 | /** @addtogroup HSEM_Exported_Functions_Group2 HSEM Set and Get Key functions 145 | * @brief HSEM Set and Get Key functions. 146 | * @{ 147 | */ 148 | /* HSEM Set Clear Key *********************************************************/ 149 | void HAL_HSEM_SetClearKey(uint32_t Key); 150 | /* HSEM Get Clear Key *********************************************************/ 151 | uint32_t HAL_HSEM_GetClearKey(void); 152 | /** 153 | * @} 154 | */ 155 | 156 | /** @addtogroup HSEM_Exported_Functions_Group3 157 | * @brief HSEM Notification functions 158 | * @{ 159 | */ 160 | /* HSEM Activate HSEM Notification (When a semaphore is released) ) *****************/ 161 | void HAL_HSEM_ActivateNotification(uint32_t SemMask); 162 | /* HSEM Deactivate HSEM Notification (When a semaphore is released) ****************/ 163 | void HAL_HSEM_DeactivateNotification(uint32_t SemMask); 164 | /* HSEM Free Callback (When a semaphore is released) *******************************/ 165 | void HAL_HSEM_FreeCallback(uint32_t SemMask); 166 | /* HSEM IRQ Handler **********************************************************/ 167 | void HAL_HSEM_IRQHandler(void); 168 | 169 | /** 170 | * @} 171 | */ 172 | 173 | /** 174 | * @} 175 | */ 176 | 177 | /* Private macros ------------------------------------------------------------*/ 178 | /** @defgroup HSEM_Private_Macros HSEM Private Macros 179 | * @{ 180 | */ 181 | 182 | #define IS_HSEM_SEMID(__SEMID__) ((__SEMID__) <= HSEM_SEMID_MAX ) 183 | 184 | #define IS_HSEM_PROCESSID(__PROCESSID__) ((__PROCESSID__) <= HSEM_PROCESSID_MAX ) 185 | 186 | #define IS_HSEM_KEY(__KEY__) ((__KEY__) <= HSEM_CLEAR_KEY_MAX ) 187 | 188 | #if defined(DUAL_CORE) 189 | #define IS_HSEM_COREID(__COREID__) (((__COREID__) == HSEM_CPU1_COREID) || \ 190 | ((__COREID__) == HSEM_CPU2_COREID)) 191 | #else 192 | #define IS_HSEM_COREID(__COREID__) ((__COREID__) == HSEM_CPU1_COREID) 193 | #endif 194 | 195 | 196 | /** 197 | * @} 198 | */ 199 | 200 | /** 201 | * @} 202 | */ 203 | 204 | /** 205 | * @} 206 | */ 207 | 208 | #ifdef __cplusplus 209 | } 210 | #endif 211 | 212 | #endif /* STM32H7xx_HAL_HSEM_H */ 213 | 214 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 215 | -------------------------------------------------------------------------------- /reference_stm32cube_project/Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS_V2/freertos_mpool.h: -------------------------------------------------------------------------------- 1 | /* -------------------------------------------------------------------------- 2 | * Copyright (c) 2013-2020 Arm Limited. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the License); you may 7 | * not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an AS IS BASIS, WITHOUT 14 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | * 18 | * Name: freertos_mpool.h 19 | * Purpose: CMSIS RTOS2 wrapper for FreeRTOS 20 | * 21 | *---------------------------------------------------------------------------*/ 22 | 23 | #ifndef FREERTOS_MPOOL_H_ 24 | #define FREERTOS_MPOOL_H_ 25 | 26 | #include 27 | #include "FreeRTOS.h" 28 | #include "semphr.h" 29 | 30 | /* Memory Pool implementation definitions */ 31 | #define MPOOL_STATUS 0x5EED0000U 32 | 33 | /* Memory Block header */ 34 | typedef struct { 35 | void *next; /* Pointer to next block */ 36 | } MemPoolBlock_t; 37 | 38 | /* Memory Pool control block */ 39 | typedef struct MemPoolDef_t { 40 | MemPoolBlock_t *head; /* Pointer to head block */ 41 | SemaphoreHandle_t sem; /* Pool semaphore handle */ 42 | uint8_t *mem_arr; /* Pool memory array */ 43 | uint32_t mem_sz; /* Pool memory array size */ 44 | const char *name; /* Pointer to name string */ 45 | uint32_t bl_sz; /* Size of a single block */ 46 | uint32_t bl_cnt; /* Number of blocks */ 47 | uint32_t n; /* Block allocation index */ 48 | volatile uint32_t status; /* Object status flags */ 49 | #if (configSUPPORT_STATIC_ALLOCATION == 1) 50 | StaticSemaphore_t mem_sem; /* Semaphore object memory */ 51 | #endif 52 | } MemPool_t; 53 | 54 | /* No need to hide static object type, just align to coding style */ 55 | #define StaticMemPool_t MemPool_t 56 | 57 | /* Define memory pool control block size */ 58 | #define MEMPOOL_CB_SIZE (sizeof(StaticMemPool_t)) 59 | 60 | /* Define size of the byte array required to create count of blocks of given size */ 61 | #define MEMPOOL_ARR_SIZE(bl_count, bl_size) (((((bl_size) + (4 - 1)) / 4) * 4)*(bl_count)) 62 | 63 | #endif /* FREERTOS_MPOOL_H_ */ 64 | -------------------------------------------------------------------------------- /reference_stm32cube_project/Middlewares/Third_Party/FreeRTOS/Source/include/StackMacros.h: -------------------------------------------------------------------------------- 1 | /* 2 | * FreeRTOS Kernel V10.3.1 3 | * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | * this software and associated documentation files (the "Software"), to deal in 7 | * the Software without restriction, including without limitation the rights to 8 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | * the Software, and to permit persons to whom the Software is furnished to do so, 10 | * subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | * 22 | * http://www.FreeRTOS.org 23 | * http://aws.amazon.com/freertos 24 | * 25 | * 1 tab == 4 spaces! 26 | */ 27 | 28 | #ifndef STACK_MACROS_H 29 | #define STACK_MACROS_H 30 | 31 | #ifndef _MSC_VER /* Visual Studio doesn't support #warning. */ 32 | #warning The name of this file has changed to stack_macros.h. Please update your code accordingly. This source file (which has the original name) will be removed in future released. 33 | #endif 34 | 35 | /* 36 | * Call the stack overflow hook function if the stack of the task being swapped 37 | * out is currently overflowed, or looks like it might have overflowed in the 38 | * past. 39 | * 40 | * Setting configCHECK_FOR_STACK_OVERFLOW to 1 will cause the macro to check 41 | * the current stack state only - comparing the current top of stack value to 42 | * the stack limit. Setting configCHECK_FOR_STACK_OVERFLOW to greater than 1 43 | * will also cause the last few stack bytes to be checked to ensure the value 44 | * to which the bytes were set when the task was created have not been 45 | * overwritten. Note this second test does not guarantee that an overflowed 46 | * stack will always be recognised. 47 | */ 48 | 49 | /*-----------------------------------------------------------*/ 50 | 51 | #if( ( configCHECK_FOR_STACK_OVERFLOW == 1 ) && ( portSTACK_GROWTH < 0 ) ) 52 | 53 | /* Only the current stack state is to be checked. */ 54 | #define taskCHECK_FOR_STACK_OVERFLOW() \ 55 | { \ 56 | /* Is the currently saved stack pointer within the stack limit? */ \ 57 | if( pxCurrentTCB->pxTopOfStack <= pxCurrentTCB->pxStack ) \ 58 | { \ 59 | vApplicationStackOverflowHook( ( TaskHandle_t ) pxCurrentTCB, pxCurrentTCB->pcTaskName ); \ 60 | } \ 61 | } 62 | 63 | #endif /* configCHECK_FOR_STACK_OVERFLOW == 1 */ 64 | /*-----------------------------------------------------------*/ 65 | 66 | #if( ( configCHECK_FOR_STACK_OVERFLOW == 1 ) && ( portSTACK_GROWTH > 0 ) ) 67 | 68 | /* Only the current stack state is to be checked. */ 69 | #define taskCHECK_FOR_STACK_OVERFLOW() \ 70 | { \ 71 | \ 72 | /* Is the currently saved stack pointer within the stack limit? */ \ 73 | if( pxCurrentTCB->pxTopOfStack >= pxCurrentTCB->pxEndOfStack ) \ 74 | { \ 75 | vApplicationStackOverflowHook( ( TaskHandle_t ) pxCurrentTCB, pxCurrentTCB->pcTaskName ); \ 76 | } \ 77 | } 78 | 79 | #endif /* configCHECK_FOR_STACK_OVERFLOW == 1 */ 80 | /*-----------------------------------------------------------*/ 81 | 82 | #if( ( configCHECK_FOR_STACK_OVERFLOW > 1 ) && ( portSTACK_GROWTH < 0 ) ) 83 | 84 | #define taskCHECK_FOR_STACK_OVERFLOW() \ 85 | { \ 86 | const uint32_t * const pulStack = ( uint32_t * ) pxCurrentTCB->pxStack; \ 87 | const uint32_t ulCheckValue = ( uint32_t ) 0xa5a5a5a5; \ 88 | \ 89 | if( ( pulStack[ 0 ] != ulCheckValue ) || \ 90 | ( pulStack[ 1 ] != ulCheckValue ) || \ 91 | ( pulStack[ 2 ] != ulCheckValue ) || \ 92 | ( pulStack[ 3 ] != ulCheckValue ) ) \ 93 | { \ 94 | vApplicationStackOverflowHook( ( TaskHandle_t ) pxCurrentTCB, pxCurrentTCB->pcTaskName ); \ 95 | } \ 96 | } 97 | 98 | #endif /* #if( configCHECK_FOR_STACK_OVERFLOW > 1 ) */ 99 | /*-----------------------------------------------------------*/ 100 | 101 | #if( ( configCHECK_FOR_STACK_OVERFLOW > 1 ) && ( portSTACK_GROWTH > 0 ) ) 102 | 103 | #define taskCHECK_FOR_STACK_OVERFLOW() \ 104 | { \ 105 | int8_t *pcEndOfStack = ( int8_t * ) pxCurrentTCB->pxEndOfStack; \ 106 | static const uint8_t ucExpectedStackBytes[] = { tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, \ 107 | tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, \ 108 | tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, \ 109 | tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, \ 110 | tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE }; \ 111 | \ 112 | \ 113 | pcEndOfStack -= sizeof( ucExpectedStackBytes ); \ 114 | \ 115 | /* Has the extremity of the task stack ever been written over? */ \ 116 | if( memcmp( ( void * ) pcEndOfStack, ( void * ) ucExpectedStackBytes, sizeof( ucExpectedStackBytes ) ) != 0 ) \ 117 | { \ 118 | vApplicationStackOverflowHook( ( TaskHandle_t ) pxCurrentTCB, pxCurrentTCB->pcTaskName ); \ 119 | } \ 120 | } 121 | 122 | #endif /* #if( configCHECK_FOR_STACK_OVERFLOW > 1 ) */ 123 | /*-----------------------------------------------------------*/ 124 | 125 | /* Remove stack overflow macro if not being used. */ 126 | #ifndef taskCHECK_FOR_STACK_OVERFLOW 127 | #define taskCHECK_FOR_STACK_OVERFLOW() 128 | #endif 129 | 130 | 131 | 132 | #endif /* STACK_MACROS_H */ 133 | 134 | -------------------------------------------------------------------------------- /reference_stm32cube_project/Middlewares/Third_Party/FreeRTOS/Source/include/deprecated_definitions.h: -------------------------------------------------------------------------------- 1 | /* 2 | * FreeRTOS Kernel V10.3.1 3 | * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | * this software and associated documentation files (the "Software"), to deal in 7 | * the Software without restriction, including without limitation the rights to 8 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | * the Software, and to permit persons to whom the Software is furnished to do so, 10 | * subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | * 22 | * http://www.FreeRTOS.org 23 | * http://aws.amazon.com/freertos 24 | * 25 | * 1 tab == 4 spaces! 26 | */ 27 | 28 | #ifndef DEPRECATED_DEFINITIONS_H 29 | #define DEPRECATED_DEFINITIONS_H 30 | 31 | 32 | /* Each FreeRTOS port has a unique portmacro.h header file. Originally a 33 | pre-processor definition was used to ensure the pre-processor found the correct 34 | portmacro.h file for the port being used. That scheme was deprecated in favour 35 | of setting the compiler's include path such that it found the correct 36 | portmacro.h file - removing the need for the constant and allowing the 37 | portmacro.h file to be located anywhere in relation to the port being used. The 38 | definitions below remain in the code for backward compatibility only. New 39 | projects should not use them. */ 40 | 41 | #ifdef OPEN_WATCOM_INDUSTRIAL_PC_PORT 42 | #include "..\..\Source\portable\owatcom\16bitdos\pc\portmacro.h" 43 | typedef void ( __interrupt __far *pxISR )(); 44 | #endif 45 | 46 | #ifdef OPEN_WATCOM_FLASH_LITE_186_PORT 47 | #include "..\..\Source\portable\owatcom\16bitdos\flsh186\portmacro.h" 48 | typedef void ( __interrupt __far *pxISR )(); 49 | #endif 50 | 51 | #ifdef GCC_MEGA_AVR 52 | #include "../portable/GCC/ATMega323/portmacro.h" 53 | #endif 54 | 55 | #ifdef IAR_MEGA_AVR 56 | #include "../portable/IAR/ATMega323/portmacro.h" 57 | #endif 58 | 59 | #ifdef MPLAB_PIC24_PORT 60 | #include "../../Source/portable/MPLAB/PIC24_dsPIC/portmacro.h" 61 | #endif 62 | 63 | #ifdef MPLAB_DSPIC_PORT 64 | #include "../../Source/portable/MPLAB/PIC24_dsPIC/portmacro.h" 65 | #endif 66 | 67 | #ifdef MPLAB_PIC18F_PORT 68 | #include "../../Source/portable/MPLAB/PIC18F/portmacro.h" 69 | #endif 70 | 71 | #ifdef MPLAB_PIC32MX_PORT 72 | #include "../../Source/portable/MPLAB/PIC32MX/portmacro.h" 73 | #endif 74 | 75 | #ifdef _FEDPICC 76 | #include "libFreeRTOS/Include/portmacro.h" 77 | #endif 78 | 79 | #ifdef SDCC_CYGNAL 80 | #include "../../Source/portable/SDCC/Cygnal/portmacro.h" 81 | #endif 82 | 83 | #ifdef GCC_ARM7 84 | #include "../../Source/portable/GCC/ARM7_LPC2000/portmacro.h" 85 | #endif 86 | 87 | #ifdef GCC_ARM7_ECLIPSE 88 | #include "portmacro.h" 89 | #endif 90 | 91 | #ifdef ROWLEY_LPC23xx 92 | #include "../../Source/portable/GCC/ARM7_LPC23xx/portmacro.h" 93 | #endif 94 | 95 | #ifdef IAR_MSP430 96 | #include "..\..\Source\portable\IAR\MSP430\portmacro.h" 97 | #endif 98 | 99 | #ifdef GCC_MSP430 100 | #include "../../Source/portable/GCC/MSP430F449/portmacro.h" 101 | #endif 102 | 103 | #ifdef ROWLEY_MSP430 104 | #include "../../Source/portable/Rowley/MSP430F449/portmacro.h" 105 | #endif 106 | 107 | #ifdef ARM7_LPC21xx_KEIL_RVDS 108 | #include "..\..\Source\portable\RVDS\ARM7_LPC21xx\portmacro.h" 109 | #endif 110 | 111 | #ifdef SAM7_GCC 112 | #include "../../Source/portable/GCC/ARM7_AT91SAM7S/portmacro.h" 113 | #endif 114 | 115 | #ifdef SAM7_IAR 116 | #include "..\..\Source\portable\IAR\AtmelSAM7S64\portmacro.h" 117 | #endif 118 | 119 | #ifdef SAM9XE_IAR 120 | #include "..\..\Source\portable\IAR\AtmelSAM9XE\portmacro.h" 121 | #endif 122 | 123 | #ifdef LPC2000_IAR 124 | #include "..\..\Source\portable\IAR\LPC2000\portmacro.h" 125 | #endif 126 | 127 | #ifdef STR71X_IAR 128 | #include "..\..\Source\portable\IAR\STR71x\portmacro.h" 129 | #endif 130 | 131 | #ifdef STR75X_IAR 132 | #include "..\..\Source\portable\IAR\STR75x\portmacro.h" 133 | #endif 134 | 135 | #ifdef STR75X_GCC 136 | #include "..\..\Source\portable\GCC\STR75x\portmacro.h" 137 | #endif 138 | 139 | #ifdef STR91X_IAR 140 | #include "..\..\Source\portable\IAR\STR91x\portmacro.h" 141 | #endif 142 | 143 | #ifdef GCC_H8S 144 | #include "../../Source/portable/GCC/H8S2329/portmacro.h" 145 | #endif 146 | 147 | #ifdef GCC_AT91FR40008 148 | #include "../../Source/portable/GCC/ARM7_AT91FR40008/portmacro.h" 149 | #endif 150 | 151 | #ifdef RVDS_ARMCM3_LM3S102 152 | #include "../../Source/portable/RVDS/ARM_CM3/portmacro.h" 153 | #endif 154 | 155 | #ifdef GCC_ARMCM3_LM3S102 156 | #include "../../Source/portable/GCC/ARM_CM3/portmacro.h" 157 | #endif 158 | 159 | #ifdef GCC_ARMCM3 160 | #include "../../Source/portable/GCC/ARM_CM3/portmacro.h" 161 | #endif 162 | 163 | #ifdef IAR_ARM_CM3 164 | #include "../../Source/portable/IAR/ARM_CM3/portmacro.h" 165 | #endif 166 | 167 | #ifdef IAR_ARMCM3_LM 168 | #include "../../Source/portable/IAR/ARM_CM3/portmacro.h" 169 | #endif 170 | 171 | #ifdef HCS12_CODE_WARRIOR 172 | #include "../../Source/portable/CodeWarrior/HCS12/portmacro.h" 173 | #endif 174 | 175 | #ifdef MICROBLAZE_GCC 176 | #include "../../Source/portable/GCC/MicroBlaze/portmacro.h" 177 | #endif 178 | 179 | #ifdef TERN_EE 180 | #include "..\..\Source\portable\Paradigm\Tern_EE\small\portmacro.h" 181 | #endif 182 | 183 | #ifdef GCC_HCS12 184 | #include "../../Source/portable/GCC/HCS12/portmacro.h" 185 | #endif 186 | 187 | #ifdef GCC_MCF5235 188 | #include "../../Source/portable/GCC/MCF5235/portmacro.h" 189 | #endif 190 | 191 | #ifdef COLDFIRE_V2_GCC 192 | #include "../../../Source/portable/GCC/ColdFire_V2/portmacro.h" 193 | #endif 194 | 195 | #ifdef COLDFIRE_V2_CODEWARRIOR 196 | #include "../../Source/portable/CodeWarrior/ColdFire_V2/portmacro.h" 197 | #endif 198 | 199 | #ifdef GCC_PPC405 200 | #include "../../Source/portable/GCC/PPC405_Xilinx/portmacro.h" 201 | #endif 202 | 203 | #ifdef GCC_PPC440 204 | #include "../../Source/portable/GCC/PPC440_Xilinx/portmacro.h" 205 | #endif 206 | 207 | #ifdef _16FX_SOFTUNE 208 | #include "..\..\Source\portable\Softune\MB96340\portmacro.h" 209 | #endif 210 | 211 | #ifdef BCC_INDUSTRIAL_PC_PORT 212 | /* A short file name has to be used in place of the normal 213 | FreeRTOSConfig.h when using the Borland compiler. */ 214 | #include "frconfig.h" 215 | #include "..\portable\BCC\16BitDOS\PC\prtmacro.h" 216 | typedef void ( __interrupt __far *pxISR )(); 217 | #endif 218 | 219 | #ifdef BCC_FLASH_LITE_186_PORT 220 | /* A short file name has to be used in place of the normal 221 | FreeRTOSConfig.h when using the Borland compiler. */ 222 | #include "frconfig.h" 223 | #include "..\portable\BCC\16BitDOS\flsh186\prtmacro.h" 224 | typedef void ( __interrupt __far *pxISR )(); 225 | #endif 226 | 227 | #ifdef __GNUC__ 228 | #ifdef __AVR32_AVR32A__ 229 | #include "portmacro.h" 230 | #endif 231 | #endif 232 | 233 | #ifdef __ICCAVR32__ 234 | #ifdef __CORE__ 235 | #if __CORE__ == __AVR32A__ 236 | #include "portmacro.h" 237 | #endif 238 | #endif 239 | #endif 240 | 241 | #ifdef __91467D 242 | #include "portmacro.h" 243 | #endif 244 | 245 | #ifdef __96340 246 | #include "portmacro.h" 247 | #endif 248 | 249 | 250 | #ifdef __IAR_V850ES_Fx3__ 251 | #include "../../Source/portable/IAR/V850ES/portmacro.h" 252 | #endif 253 | 254 | #ifdef __IAR_V850ES_Jx3__ 255 | #include "../../Source/portable/IAR/V850ES/portmacro.h" 256 | #endif 257 | 258 | #ifdef __IAR_V850ES_Jx3_L__ 259 | #include "../../Source/portable/IAR/V850ES/portmacro.h" 260 | #endif 261 | 262 | #ifdef __IAR_V850ES_Jx2__ 263 | #include "../../Source/portable/IAR/V850ES/portmacro.h" 264 | #endif 265 | 266 | #ifdef __IAR_V850ES_Hx2__ 267 | #include "../../Source/portable/IAR/V850ES/portmacro.h" 268 | #endif 269 | 270 | #ifdef __IAR_78K0R_Kx3__ 271 | #include "../../Source/portable/IAR/78K0R/portmacro.h" 272 | #endif 273 | 274 | #ifdef __IAR_78K0R_Kx3L__ 275 | #include "../../Source/portable/IAR/78K0R/portmacro.h" 276 | #endif 277 | 278 | #endif /* DEPRECATED_DEFINITIONS_H */ 279 | 280 | -------------------------------------------------------------------------------- /reference_stm32cube_project/Middlewares/Third_Party/FreeRTOS/Source/include/portable.h: -------------------------------------------------------------------------------- 1 | /* 2 | * FreeRTOS Kernel V10.3.1 3 | * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | * this software and associated documentation files (the "Software"), to deal in 7 | * the Software without restriction, including without limitation the rights to 8 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | * the Software, and to permit persons to whom the Software is furnished to do so, 10 | * subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | * 22 | * http://www.FreeRTOS.org 23 | * http://aws.amazon.com/freertos 24 | * 25 | * 1 tab == 4 spaces! 26 | */ 27 | 28 | /*----------------------------------------------------------- 29 | * Portable layer API. Each function must be defined for each port. 30 | *----------------------------------------------------------*/ 31 | 32 | #ifndef PORTABLE_H 33 | #define PORTABLE_H 34 | 35 | /* Each FreeRTOS port has a unique portmacro.h header file. Originally a 36 | pre-processor definition was used to ensure the pre-processor found the correct 37 | portmacro.h file for the port being used. That scheme was deprecated in favour 38 | of setting the compiler's include path such that it found the correct 39 | portmacro.h file - removing the need for the constant and allowing the 40 | portmacro.h file to be located anywhere in relation to the port being used. 41 | Purely for reasons of backward compatibility the old method is still valid, but 42 | to make it clear that new projects should not use it, support for the port 43 | specific constants has been moved into the deprecated_definitions.h header 44 | file. */ 45 | #include "deprecated_definitions.h" 46 | 47 | /* If portENTER_CRITICAL is not defined then including deprecated_definitions.h 48 | did not result in a portmacro.h header file being included - and it should be 49 | included here. In this case the path to the correct portmacro.h header file 50 | must be set in the compiler's include path. */ 51 | #ifndef portENTER_CRITICAL 52 | #include "portmacro.h" 53 | #endif 54 | 55 | #if portBYTE_ALIGNMENT == 32 56 | #define portBYTE_ALIGNMENT_MASK ( 0x001f ) 57 | #endif 58 | 59 | #if portBYTE_ALIGNMENT == 16 60 | #define portBYTE_ALIGNMENT_MASK ( 0x000f ) 61 | #endif 62 | 63 | #if portBYTE_ALIGNMENT == 8 64 | #define portBYTE_ALIGNMENT_MASK ( 0x0007 ) 65 | #endif 66 | 67 | #if portBYTE_ALIGNMENT == 4 68 | #define portBYTE_ALIGNMENT_MASK ( 0x0003 ) 69 | #endif 70 | 71 | #if portBYTE_ALIGNMENT == 2 72 | #define portBYTE_ALIGNMENT_MASK ( 0x0001 ) 73 | #endif 74 | 75 | #if portBYTE_ALIGNMENT == 1 76 | #define portBYTE_ALIGNMENT_MASK ( 0x0000 ) 77 | #endif 78 | 79 | #ifndef portBYTE_ALIGNMENT_MASK 80 | #error "Invalid portBYTE_ALIGNMENT definition" 81 | #endif 82 | 83 | #ifndef portNUM_CONFIGURABLE_REGIONS 84 | #define portNUM_CONFIGURABLE_REGIONS 1 85 | #endif 86 | 87 | #ifndef portHAS_STACK_OVERFLOW_CHECKING 88 | #define portHAS_STACK_OVERFLOW_CHECKING 0 89 | #endif 90 | 91 | #ifndef portARCH_NAME 92 | #define portARCH_NAME NULL 93 | #endif 94 | 95 | #ifdef __cplusplus 96 | extern "C" { 97 | #endif 98 | 99 | #include "mpu_wrappers.h" 100 | 101 | /* 102 | * Setup the stack of a new task so it is ready to be placed under the 103 | * scheduler control. The registers have to be placed on the stack in 104 | * the order that the port expects to find them. 105 | * 106 | */ 107 | #if( portUSING_MPU_WRAPPERS == 1 ) 108 | #if( portHAS_STACK_OVERFLOW_CHECKING == 1 ) 109 | StackType_t *pxPortInitialiseStack( StackType_t *pxTopOfStack, StackType_t *pxEndOfStack, TaskFunction_t pxCode, void *pvParameters, BaseType_t xRunPrivileged ) PRIVILEGED_FUNCTION; 110 | #else 111 | StackType_t *pxPortInitialiseStack( StackType_t *pxTopOfStack, TaskFunction_t pxCode, void *pvParameters, BaseType_t xRunPrivileged ) PRIVILEGED_FUNCTION; 112 | #endif 113 | #else 114 | #if( portHAS_STACK_OVERFLOW_CHECKING == 1 ) 115 | StackType_t *pxPortInitialiseStack( StackType_t *pxTopOfStack, StackType_t *pxEndOfStack, TaskFunction_t pxCode, void *pvParameters ) PRIVILEGED_FUNCTION; 116 | #else 117 | StackType_t *pxPortInitialiseStack( StackType_t *pxTopOfStack, TaskFunction_t pxCode, void *pvParameters ) PRIVILEGED_FUNCTION; 118 | #endif 119 | #endif 120 | 121 | /* Used by heap_5.c to define the start address and size of each memory region 122 | that together comprise the total FreeRTOS heap space. */ 123 | typedef struct HeapRegion 124 | { 125 | uint8_t *pucStartAddress; 126 | size_t xSizeInBytes; 127 | } HeapRegion_t; 128 | 129 | /* Used to pass information about the heap out of vPortGetHeapStats(). */ 130 | typedef struct xHeapStats 131 | { 132 | size_t xAvailableHeapSpaceInBytes; /* The total heap size currently available - this is the sum of all the free blocks, not the largest block that can be allocated. */ 133 | size_t xSizeOfLargestFreeBlockInBytes; /* The maximum size, in bytes, of all the free blocks within the heap at the time vPortGetHeapStats() is called. */ 134 | size_t xSizeOfSmallestFreeBlockInBytes; /* The minimum size, in bytes, of all the free blocks within the heap at the time vPortGetHeapStats() is called. */ 135 | size_t xNumberOfFreeBlocks; /* The number of free memory blocks within the heap at the time vPortGetHeapStats() is called. */ 136 | size_t xMinimumEverFreeBytesRemaining; /* The minimum amount of total free memory (sum of all free blocks) there has been in the heap since the system booted. */ 137 | size_t xNumberOfSuccessfulAllocations; /* The number of calls to pvPortMalloc() that have returned a valid memory block. */ 138 | size_t xNumberOfSuccessfulFrees; /* The number of calls to vPortFree() that has successfully freed a block of memory. */ 139 | } HeapStats_t; 140 | 141 | /* 142 | * Used to define multiple heap regions for use by heap_5.c. This function 143 | * must be called before any calls to pvPortMalloc() - not creating a task, 144 | * queue, semaphore, mutex, software timer, event group, etc. will result in 145 | * pvPortMalloc being called. 146 | * 147 | * pxHeapRegions passes in an array of HeapRegion_t structures - each of which 148 | * defines a region of memory that can be used as the heap. The array is 149 | * terminated by a HeapRegions_t structure that has a size of 0. The region 150 | * with the lowest start address must appear first in the array. 151 | */ 152 | void vPortDefineHeapRegions( const HeapRegion_t * const pxHeapRegions ) PRIVILEGED_FUNCTION; 153 | 154 | /* 155 | * Returns a HeapStats_t structure filled with information about the current 156 | * heap state. 157 | */ 158 | void vPortGetHeapStats( HeapStats_t *pxHeapStats ); 159 | 160 | /* 161 | * Map to the memory management routines required for the port. 162 | */ 163 | void *pvPortMalloc( size_t xSize ) PRIVILEGED_FUNCTION; 164 | void vPortFree( void *pv ) PRIVILEGED_FUNCTION; 165 | void vPortInitialiseBlocks( void ) PRIVILEGED_FUNCTION; 166 | size_t xPortGetFreeHeapSize( void ) PRIVILEGED_FUNCTION; 167 | size_t xPortGetMinimumEverFreeHeapSize( void ) PRIVILEGED_FUNCTION; 168 | 169 | /* 170 | * Setup the hardware ready for the scheduler to take control. This generally 171 | * sets up a tick interrupt and sets timers for the correct tick frequency. 172 | */ 173 | BaseType_t xPortStartScheduler( void ) PRIVILEGED_FUNCTION; 174 | 175 | /* 176 | * Undo any hardware/ISR setup that was performed by xPortStartScheduler() so 177 | * the hardware is left in its original condition after the scheduler stops 178 | * executing. 179 | */ 180 | void vPortEndScheduler( void ) PRIVILEGED_FUNCTION; 181 | 182 | /* 183 | * The structures and methods of manipulating the MPU are contained within the 184 | * port layer. 185 | * 186 | * Fills the xMPUSettings structure with the memory region information 187 | * contained in xRegions. 188 | */ 189 | #if( portUSING_MPU_WRAPPERS == 1 ) 190 | struct xMEMORY_REGION; 191 | void vPortStoreTaskMPUSettings( xMPU_SETTINGS *xMPUSettings, const struct xMEMORY_REGION * const xRegions, StackType_t *pxBottomOfStack, uint32_t ulStackDepth ) PRIVILEGED_FUNCTION; 192 | #endif 193 | 194 | #ifdef __cplusplus 195 | } 196 | #endif 197 | 198 | #endif /* PORTABLE_H */ 199 | 200 | -------------------------------------------------------------------------------- /reference_stm32cube_project/Middlewares/Third_Party/FreeRTOS/Source/include/projdefs.h: -------------------------------------------------------------------------------- 1 | /* 2 | * FreeRTOS Kernel V10.3.1 3 | * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | * this software and associated documentation files (the "Software"), to deal in 7 | * the Software without restriction, including without limitation the rights to 8 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | * the Software, and to permit persons to whom the Software is furnished to do so, 10 | * subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | * 22 | * http://www.FreeRTOS.org 23 | * http://aws.amazon.com/freertos 24 | * 25 | * 1 tab == 4 spaces! 26 | */ 27 | 28 | #ifndef PROJDEFS_H 29 | #define PROJDEFS_H 30 | 31 | /* 32 | * Defines the prototype to which task functions must conform. Defined in this 33 | * file to ensure the type is known before portable.h is included. 34 | */ 35 | typedef void (*TaskFunction_t)( void * ); 36 | 37 | /* Converts a time in milliseconds to a time in ticks. This macro can be 38 | overridden by a macro of the same name defined in FreeRTOSConfig.h in case the 39 | definition here is not suitable for your application. */ 40 | #ifndef pdMS_TO_TICKS 41 | #define pdMS_TO_TICKS( xTimeInMs ) ( ( TickType_t ) ( ( ( TickType_t ) ( xTimeInMs ) * ( TickType_t ) configTICK_RATE_HZ ) / ( TickType_t ) 1000 ) ) 42 | #endif 43 | 44 | #define pdFALSE ( ( BaseType_t ) 0 ) 45 | #define pdTRUE ( ( BaseType_t ) 1 ) 46 | 47 | #define pdPASS ( pdTRUE ) 48 | #define pdFAIL ( pdFALSE ) 49 | #define errQUEUE_EMPTY ( ( BaseType_t ) 0 ) 50 | #define errQUEUE_FULL ( ( BaseType_t ) 0 ) 51 | 52 | /* FreeRTOS error definitions. */ 53 | #define errCOULD_NOT_ALLOCATE_REQUIRED_MEMORY ( -1 ) 54 | #define errQUEUE_BLOCKED ( -4 ) 55 | #define errQUEUE_YIELD ( -5 ) 56 | 57 | /* Macros used for basic data corruption checks. */ 58 | #ifndef configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES 59 | #define configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES 0 60 | #endif 61 | 62 | #if( configUSE_16_BIT_TICKS == 1 ) 63 | #define pdINTEGRITY_CHECK_VALUE 0x5a5a 64 | #else 65 | #define pdINTEGRITY_CHECK_VALUE 0x5a5a5a5aUL 66 | #endif 67 | 68 | /* The following errno values are used by FreeRTOS+ components, not FreeRTOS 69 | itself. */ 70 | #define pdFREERTOS_ERRNO_NONE 0 /* No errors */ 71 | #define pdFREERTOS_ERRNO_ENOENT 2 /* No such file or directory */ 72 | #define pdFREERTOS_ERRNO_EINTR 4 /* Interrupted system call */ 73 | #define pdFREERTOS_ERRNO_EIO 5 /* I/O error */ 74 | #define pdFREERTOS_ERRNO_ENXIO 6 /* No such device or address */ 75 | #define pdFREERTOS_ERRNO_EBADF 9 /* Bad file number */ 76 | #define pdFREERTOS_ERRNO_EAGAIN 11 /* No more processes */ 77 | #define pdFREERTOS_ERRNO_EWOULDBLOCK 11 /* Operation would block */ 78 | #define pdFREERTOS_ERRNO_ENOMEM 12 /* Not enough memory */ 79 | #define pdFREERTOS_ERRNO_EACCES 13 /* Permission denied */ 80 | #define pdFREERTOS_ERRNO_EFAULT 14 /* Bad address */ 81 | #define pdFREERTOS_ERRNO_EBUSY 16 /* Mount device busy */ 82 | #define pdFREERTOS_ERRNO_EEXIST 17 /* File exists */ 83 | #define pdFREERTOS_ERRNO_EXDEV 18 /* Cross-device link */ 84 | #define pdFREERTOS_ERRNO_ENODEV 19 /* No such device */ 85 | #define pdFREERTOS_ERRNO_ENOTDIR 20 /* Not a directory */ 86 | #define pdFREERTOS_ERRNO_EISDIR 21 /* Is a directory */ 87 | #define pdFREERTOS_ERRNO_EINVAL 22 /* Invalid argument */ 88 | #define pdFREERTOS_ERRNO_ENOSPC 28 /* No space left on device */ 89 | #define pdFREERTOS_ERRNO_ESPIPE 29 /* Illegal seek */ 90 | #define pdFREERTOS_ERRNO_EROFS 30 /* Read only file system */ 91 | #define pdFREERTOS_ERRNO_EUNATCH 42 /* Protocol driver not attached */ 92 | #define pdFREERTOS_ERRNO_EBADE 50 /* Invalid exchange */ 93 | #define pdFREERTOS_ERRNO_EFTYPE 79 /* Inappropriate file type or format */ 94 | #define pdFREERTOS_ERRNO_ENMFILE 89 /* No more files */ 95 | #define pdFREERTOS_ERRNO_ENOTEMPTY 90 /* Directory not empty */ 96 | #define pdFREERTOS_ERRNO_ENAMETOOLONG 91 /* File or path name too long */ 97 | #define pdFREERTOS_ERRNO_EOPNOTSUPP 95 /* Operation not supported on transport endpoint */ 98 | #define pdFREERTOS_ERRNO_ENOBUFS 105 /* No buffer space available */ 99 | #define pdFREERTOS_ERRNO_ENOPROTOOPT 109 /* Protocol not available */ 100 | #define pdFREERTOS_ERRNO_EADDRINUSE 112 /* Address already in use */ 101 | #define pdFREERTOS_ERRNO_ETIMEDOUT 116 /* Connection timed out */ 102 | #define pdFREERTOS_ERRNO_EINPROGRESS 119 /* Connection already in progress */ 103 | #define pdFREERTOS_ERRNO_EALREADY 120 /* Socket already connected */ 104 | #define pdFREERTOS_ERRNO_EADDRNOTAVAIL 125 /* Address not available */ 105 | #define pdFREERTOS_ERRNO_EISCONN 127 /* Socket is already connected */ 106 | #define pdFREERTOS_ERRNO_ENOTCONN 128 /* Socket is not connected */ 107 | #define pdFREERTOS_ERRNO_ENOMEDIUM 135 /* No medium inserted */ 108 | #define pdFREERTOS_ERRNO_EILSEQ 138 /* An invalid UTF-16 sequence was encountered. */ 109 | #define pdFREERTOS_ERRNO_ECANCELED 140 /* Operation canceled. */ 110 | 111 | /* The following endian values are used by FreeRTOS+ components, not FreeRTOS 112 | itself. */ 113 | #define pdFREERTOS_LITTLE_ENDIAN 0 114 | #define pdFREERTOS_BIG_ENDIAN 1 115 | 116 | /* Re-defining endian values for generic naming. */ 117 | #define pdLITTLE_ENDIAN pdFREERTOS_LITTLE_ENDIAN 118 | #define pdBIG_ENDIAN pdFREERTOS_BIG_ENDIAN 119 | 120 | 121 | #endif /* PROJDEFS_H */ 122 | 123 | 124 | 125 | -------------------------------------------------------------------------------- /reference_stm32cube_project/Middlewares/Third_Party/FreeRTOS/Source/include/stack_macros.h: -------------------------------------------------------------------------------- 1 | /* 2 | * FreeRTOS Kernel V10.3.1 3 | * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | * this software and associated documentation files (the "Software"), to deal in 7 | * the Software without restriction, including without limitation the rights to 8 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | * the Software, and to permit persons to whom the Software is furnished to do so, 10 | * subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | * 22 | * http://www.FreeRTOS.org 23 | * http://aws.amazon.com/freertos 24 | * 25 | * 1 tab == 4 spaces! 26 | */ 27 | 28 | #ifndef STACK_MACROS_H 29 | #define STACK_MACROS_H 30 | 31 | /* 32 | * Call the stack overflow hook function if the stack of the task being swapped 33 | * out is currently overflowed, or looks like it might have overflowed in the 34 | * past. 35 | * 36 | * Setting configCHECK_FOR_STACK_OVERFLOW to 1 will cause the macro to check 37 | * the current stack state only - comparing the current top of stack value to 38 | * the stack limit. Setting configCHECK_FOR_STACK_OVERFLOW to greater than 1 39 | * will also cause the last few stack bytes to be checked to ensure the value 40 | * to which the bytes were set when the task was created have not been 41 | * overwritten. Note this second test does not guarantee that an overflowed 42 | * stack will always be recognised. 43 | */ 44 | 45 | /*-----------------------------------------------------------*/ 46 | 47 | #if( ( configCHECK_FOR_STACK_OVERFLOW == 1 ) && ( portSTACK_GROWTH < 0 ) ) 48 | 49 | /* Only the current stack state is to be checked. */ 50 | #define taskCHECK_FOR_STACK_OVERFLOW() \ 51 | { \ 52 | /* Is the currently saved stack pointer within the stack limit? */ \ 53 | if( pxCurrentTCB->pxTopOfStack <= pxCurrentTCB->pxStack ) \ 54 | { \ 55 | vApplicationStackOverflowHook( ( TaskHandle_t ) pxCurrentTCB, pxCurrentTCB->pcTaskName ); \ 56 | } \ 57 | } 58 | 59 | #endif /* configCHECK_FOR_STACK_OVERFLOW == 1 */ 60 | /*-----------------------------------------------------------*/ 61 | 62 | #if( ( configCHECK_FOR_STACK_OVERFLOW == 1 ) && ( portSTACK_GROWTH > 0 ) ) 63 | 64 | /* Only the current stack state is to be checked. */ 65 | #define taskCHECK_FOR_STACK_OVERFLOW() \ 66 | { \ 67 | \ 68 | /* Is the currently saved stack pointer within the stack limit? */ \ 69 | if( pxCurrentTCB->pxTopOfStack >= pxCurrentTCB->pxEndOfStack ) \ 70 | { \ 71 | vApplicationStackOverflowHook( ( TaskHandle_t ) pxCurrentTCB, pxCurrentTCB->pcTaskName ); \ 72 | } \ 73 | } 74 | 75 | #endif /* configCHECK_FOR_STACK_OVERFLOW == 1 */ 76 | /*-----------------------------------------------------------*/ 77 | 78 | #if( ( configCHECK_FOR_STACK_OVERFLOW > 1 ) && ( portSTACK_GROWTH < 0 ) ) 79 | 80 | #define taskCHECK_FOR_STACK_OVERFLOW() \ 81 | { \ 82 | const uint32_t * const pulStack = ( uint32_t * ) pxCurrentTCB->pxStack; \ 83 | const uint32_t ulCheckValue = ( uint32_t ) 0xa5a5a5a5; \ 84 | \ 85 | if( ( pulStack[ 0 ] != ulCheckValue ) || \ 86 | ( pulStack[ 1 ] != ulCheckValue ) || \ 87 | ( pulStack[ 2 ] != ulCheckValue ) || \ 88 | ( pulStack[ 3 ] != ulCheckValue ) ) \ 89 | { \ 90 | vApplicationStackOverflowHook( ( TaskHandle_t ) pxCurrentTCB, pxCurrentTCB->pcTaskName ); \ 91 | } \ 92 | } 93 | 94 | #endif /* #if( configCHECK_FOR_STACK_OVERFLOW > 1 ) */ 95 | /*-----------------------------------------------------------*/ 96 | 97 | #if( ( configCHECK_FOR_STACK_OVERFLOW > 1 ) && ( portSTACK_GROWTH > 0 ) ) 98 | 99 | #define taskCHECK_FOR_STACK_OVERFLOW() \ 100 | { \ 101 | int8_t *pcEndOfStack = ( int8_t * ) pxCurrentTCB->pxEndOfStack; \ 102 | static const uint8_t ucExpectedStackBytes[] = { tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, \ 103 | tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, \ 104 | tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, \ 105 | tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, \ 106 | tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE }; \ 107 | \ 108 | \ 109 | pcEndOfStack -= sizeof( ucExpectedStackBytes ); \ 110 | \ 111 | /* Has the extremity of the task stack ever been written over? */ \ 112 | if( memcmp( ( void * ) pcEndOfStack, ( void * ) ucExpectedStackBytes, sizeof( ucExpectedStackBytes ) ) != 0 ) \ 113 | { \ 114 | vApplicationStackOverflowHook( ( TaskHandle_t ) pxCurrentTCB, pxCurrentTCB->pcTaskName ); \ 115 | } \ 116 | } 117 | 118 | #endif /* #if( configCHECK_FOR_STACK_OVERFLOW > 1 ) */ 119 | /*-----------------------------------------------------------*/ 120 | 121 | /* Remove stack overflow macro if not being used. */ 122 | #ifndef taskCHECK_FOR_STACK_OVERFLOW 123 | #define taskCHECK_FOR_STACK_OVERFLOW() 124 | #endif 125 | 126 | 127 | 128 | #endif /* STACK_MACROS_H */ 129 | 130 | -------------------------------------------------------------------------------- /reference_stm32cube_project/STM32H723ZGTX_FLASH.ld: -------------------------------------------------------------------------------- 1 | /* 2 | ****************************************************************************** 3 | ** 4 | ** File : LinkerScript.ld 5 | ** 6 | ** Author : STM32CubeIDE 7 | ** 8 | ** Abstract : Linker script for STM32H7 series 9 | ** 1024Kbytes FLASH and 192Kbytes RAM 10 | ** 11 | ** Set heap size, stack size and stack location according 12 | ** to application requirements. 13 | ** 14 | ** Set memory bank area and size if external memory is used. 15 | ** 16 | ** Target : STMicroelectronics STM32 17 | ** 18 | ** Distribution: The file is distributed as is, without any warranty 19 | ** of any kind. 20 | ** 21 | ***************************************************************************** 22 | ** @attention 23 | ** 24 | ** Copyright (c) 2020 STMicroelectronics. 25 | ** All rights reserved. 26 | ** 27 | ** This software component is licensed by ST under BSD 3-Clause license, 28 | ** the "License"; You may not use this file except in compliance with the 29 | ** License. You may obtain a copy of the License at: 30 | ** opensource.org/licenses/BSD-3-Clause 31 | ** 32 | **************************************************************************** 33 | */ 34 | 35 | /* Entry Point */ 36 | ENTRY(Reset_Handler) 37 | 38 | /* Highest address of the user mode stack */ 39 | _estack = 0x20020000; /* end of RAM */ 40 | /* Generate a link error if heap and stack don't fit into RAM */ 41 | _Min_Heap_Size = 0x200 ; /* required amount of heap */ 42 | _Min_Stack_Size = 0x400 ; /* required amount of stack */ 43 | 44 | /* Specify the memory areas */ 45 | MEMORY 46 | { 47 | ITCMRAM (xrw) : ORIGIN = 0x00000000, LENGTH = 64K 48 | RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 128K 49 | FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 1024K 50 | RAM_D1 (xrw) : ORIGIN = 0x24000000, LENGTH = 320K 51 | RAM_D2 (xrw) : ORIGIN = 0x30000000, LENGTH = 32K 52 | RAM_D3 (xrw) : ORIGIN = 0x38000000, LENGTH = 16K 53 | } 54 | 55 | /* Define output sections */ 56 | SECTIONS 57 | { 58 | /* The startup code goes first into FLASH */ 59 | .isr_vector : 60 | { 61 | . = ALIGN(4); 62 | KEEP(*(.isr_vector)) /* Startup code */ 63 | . = ALIGN(4); 64 | } >FLASH 65 | 66 | /* The program code and other data goes into FLASH */ 67 | .text : 68 | { 69 | . = ALIGN(4); 70 | *(.text) /* .text sections (code) */ 71 | *(.text*) /* .text* sections (code) */ 72 | *(.glue_7) /* glue arm to thumb code */ 73 | *(.glue_7t) /* glue thumb to arm code */ 74 | *(.eh_frame) 75 | 76 | KEEP (*(.init)) 77 | KEEP (*(.fini)) 78 | 79 | . = ALIGN(4); 80 | _etext = .; /* define a global symbols at end of code */ 81 | } >FLASH 82 | 83 | /* Constant data goes into FLASH */ 84 | .rodata : 85 | { 86 | . = ALIGN(4); 87 | *(.rodata) /* .rodata sections (constants, strings, etc.) */ 88 | *(.rodata*) /* .rodata* sections (constants, strings, etc.) */ 89 | . = ALIGN(4); 90 | } >FLASH 91 | 92 | .ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) } >FLASH 93 | .ARM : { 94 | __exidx_start = .; 95 | *(.ARM.exidx*) 96 | __exidx_end = .; 97 | } >FLASH 98 | 99 | .preinit_array : 100 | { 101 | PROVIDE_HIDDEN (__preinit_array_start = .); 102 | KEEP (*(.preinit_array*)) 103 | PROVIDE_HIDDEN (__preinit_array_end = .); 104 | } >FLASH 105 | .init_array : 106 | { 107 | PROVIDE_HIDDEN (__init_array_start = .); 108 | KEEP (*(SORT(.init_array.*))) 109 | KEEP (*(.init_array*)) 110 | PROVIDE_HIDDEN (__init_array_end = .); 111 | } >FLASH 112 | .fini_array : 113 | { 114 | PROVIDE_HIDDEN (__fini_array_start = .); 115 | KEEP (*(SORT(.fini_array.*))) 116 | KEEP (*(.fini_array*)) 117 | PROVIDE_HIDDEN (__fini_array_end = .); 118 | } >FLASH 119 | 120 | /* used by the startup to initialize data */ 121 | _sidata = LOADADDR(.data); 122 | 123 | /* Initialized data sections goes into RAM, load LMA copy after code */ 124 | .data : 125 | { 126 | . = ALIGN(4); 127 | _sdata = .; /* create a global symbol at data start */ 128 | *(.data) /* .data sections */ 129 | *(.data*) /* .data* sections */ 130 | *(.RamFunc) /* .RamFunc sections */ 131 | *(.RamFunc*) /* .RamFunc* sections */ 132 | 133 | . = ALIGN(4); 134 | _edata = .; /* define a global symbol at data end */ 135 | } >RAM AT> FLASH 136 | 137 | /* Uninitialized data section */ 138 | . = ALIGN(4); 139 | .bss : 140 | { 141 | /* This is used by the startup in order to initialize the .bss secion */ 142 | _sbss = .; /* define a global symbol at bss start */ 143 | __bss_start__ = _sbss; 144 | *(.bss) 145 | *(.bss*) 146 | *(COMMON) 147 | 148 | . = ALIGN(4); 149 | _ebss = .; /* define a global symbol at bss end */ 150 | __bss_end__ = _ebss; 151 | } >RAM 152 | 153 | /* User_heap_stack section, used to check that there is enough RAM left */ 154 | ._user_heap_stack : 155 | { 156 | . = ALIGN(8); 157 | PROVIDE ( end = . ); 158 | PROVIDE ( _end = . ); 159 | . = . + _Min_Heap_Size; 160 | . = . + _Min_Stack_Size; 161 | . = ALIGN(8); 162 | } >RAM 163 | 164 | /* Remove information from the standard libraries */ 165 | /DISCARD/ : 166 | { 167 | libc.a ( * ) 168 | libm.a ( * ) 169 | libgcc.a ( * ) 170 | } 171 | 172 | .ARM.attributes 0 : { *(.ARM.attributes) } 173 | } 174 | -------------------------------------------------------------------------------- /reference_stm32cube_project/STM32H723ZGTX_RAM.ld: -------------------------------------------------------------------------------- 1 | /* 2 | ****************************************************************************** 3 | ** 4 | ** File : LinkerScript.ld 5 | ** 6 | ** Author : STM32CubeIDE 7 | ** 8 | ** Abstract : Linker script for STM32H7 series 9 | ** 320Kbytes RAM_EXEC and 192Kbytes RAM 10 | ** 11 | ** Set heap size, stack size and stack location according 12 | ** to application requirements. 13 | ** 14 | ** Set memory bank area and size if external memory is used. 15 | ** 16 | ** Target : STMicroelectronics STM32 17 | ** 18 | ** Distribution: The file is distributed as is, without any warranty 19 | ** of any kind. 20 | ** 21 | ***************************************************************************** 22 | ** @attention 23 | ** 24 | ** Copyright (c) 2020 STMicroelectronics. 25 | ** All rights reserved. 26 | ** 27 | ** This software component is licensed by ST under BSD 3-Clause license, 28 | ** the "License"; You may not use this file except in compliance with the 29 | ** License. You may obtain a copy of the License at: 30 | ** opensource.org/licenses/BSD-3-Clause 31 | ** 32 | **************************************************************************** 33 | */ 34 | 35 | /* Entry Point */ 36 | ENTRY(Reset_Handler) 37 | 38 | /* Highest address of the user mode stack */ 39 | _estack = 0x20020000; /* end of RAM */ 40 | /* Generate a link error if heap and stack don't fit into RAM */ 41 | _Min_Heap_Size = 0x200 ; /* required amount of heap */ 42 | _Min_Stack_Size = 0x400 ; /* required amount of stack */ 43 | 44 | /* Specify the memory areas */ 45 | MEMORY 46 | { 47 | RAM_EXEC (xrw) : ORIGIN = 0x24000000, LENGTH = 320K 48 | RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 128K 49 | ITCMRAM (xrw) : ORIGIN = 0x00000000, LENGTH = 64K 50 | RAM_D2 (xrw) : ORIGIN = 0x30000000, LENGTH = 32K 51 | RAM_D3 (xrw) : ORIGIN = 0x38000000, LENGTH = 16K 52 | } 53 | 54 | /* Define output sections */ 55 | SECTIONS 56 | { 57 | /* The startup code goes first into RAM_EXEC */ 58 | .isr_vector : 59 | { 60 | . = ALIGN(4); 61 | KEEP(*(.isr_vector)) /* Startup code */ 62 | . = ALIGN(4); 63 | } >RAM_EXEC 64 | 65 | /* The program code and other data goes into RAM_EXEC */ 66 | .text : 67 | { 68 | . = ALIGN(4); 69 | *(.text) /* .text sections (code) */ 70 | *(.text*) /* .text* sections (code) */ 71 | *(.glue_7) /* glue arm to thumb code */ 72 | *(.glue_7t) /* glue thumb to arm code */ 73 | *(.eh_frame) 74 | *(.RamFunc) /* .RamFunc sections */ 75 | *(.RamFunc*) /* .RamFunc* sections */ 76 | 77 | KEEP (*(.init)) 78 | KEEP (*(.fini)) 79 | 80 | . = ALIGN(4); 81 | _etext = .; /* define a global symbols at end of code */ 82 | } >RAM_EXEC 83 | 84 | /* Constant data goes into RAM_EXEC */ 85 | .rodata : 86 | { 87 | . = ALIGN(4); 88 | *(.rodata) /* .rodata sections (constants, strings, etc.) */ 89 | *(.rodata*) /* .rodata* sections (constants, strings, etc.) */ 90 | . = ALIGN(4); 91 | } >RAM_EXEC 92 | 93 | .ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) } >RAM_EXEC 94 | .ARM : { 95 | __exidx_start = .; 96 | *(.ARM.exidx*) 97 | __exidx_end = .; 98 | } >RAM_EXEC 99 | 100 | .preinit_array : 101 | { 102 | PROVIDE_HIDDEN (__preinit_array_start = .); 103 | KEEP (*(.preinit_array*)) 104 | PROVIDE_HIDDEN (__preinit_array_end = .); 105 | } >RAM_EXEC 106 | .init_array : 107 | { 108 | PROVIDE_HIDDEN (__init_array_start = .); 109 | KEEP (*(SORT(.init_array.*))) 110 | KEEP (*(.init_array*)) 111 | PROVIDE_HIDDEN (__init_array_end = .); 112 | } >RAM_EXEC 113 | .fini_array : 114 | { 115 | PROVIDE_HIDDEN (__fini_array_start = .); 116 | KEEP (*(SORT(.fini_array.*))) 117 | KEEP (*(.fini_array*)) 118 | PROVIDE_HIDDEN (__fini_array_end = .); 119 | } >RAM_EXEC 120 | 121 | /* used by the startup to initialize data */ 122 | _sidata = LOADADDR(.data); 123 | 124 | /* Initialized data sections goes into RAM, load LMA copy after code */ 125 | .data : 126 | { 127 | . = ALIGN(4); 128 | _sdata = .; /* create a global symbol at data start */ 129 | *(.data) /* .data sections */ 130 | *(.data*) /* .data* sections */ 131 | 132 | . = ALIGN(4); 133 | _edata = .; /* define a global symbol at data end */ 134 | } >RAM AT> RAM_EXEC 135 | 136 | /* Uninitialized data section */ 137 | . = ALIGN(4); 138 | .bss : 139 | { 140 | /* This is used by the startup in order to initialize the .bss secion */ 141 | _sbss = .; /* define a global symbol at bss start */ 142 | __bss_start__ = _sbss; 143 | *(.bss) 144 | *(.bss*) 145 | *(COMMON) 146 | 147 | . = ALIGN(4); 148 | _ebss = .; /* define a global symbol at bss end */ 149 | __bss_end__ = _ebss; 150 | } >RAM 151 | 152 | /* User_heap_stack section, used to check that there is enough RAM left */ 153 | ._user_heap_stack : 154 | { 155 | . = ALIGN(8); 156 | PROVIDE ( end = . ); 157 | PROVIDE ( _end = . ); 158 | . = . + _Min_Heap_Size; 159 | . = . + _Min_Stack_Size; 160 | . = ALIGN(8); 161 | } >RAM 162 | 163 | /* Remove information from the standard libraries */ 164 | /DISCARD/ : 165 | { 166 | libc.a ( * ) 167 | libm.a ( * ) 168 | libgcc.a ( * ) 169 | } 170 | 171 | .ARM.attributes 0 : { *(.ARM.attributes) } 172 | } 173 | -------------------------------------------------------------------------------- /src/freertos.c: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * File Name : freertos.c 5 | * Description : Code for freertos applications 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | *

© Copyright (c) 2021 STMicroelectronics. 10 | * All rights reserved.

11 | * 12 | * This software component is licensed by ST under Ultimate Liberty license 13 | * SLA0044, the "License"; You may not use this file except in compliance with 14 | * the License. You may obtain a copy of the License at: 15 | * www.st.com/SLA0044 16 | * 17 | ****************************************************************************** 18 | */ 19 | /* USER CODE END Header */ 20 | 21 | /* Includes ------------------------------------------------------------------*/ 22 | #include "FreeRTOS.h" 23 | #include "task.h" 24 | #include "main.h" 25 | 26 | /* Private includes ----------------------------------------------------------*/ 27 | /* USER CODE BEGIN Includes */ 28 | 29 | /* USER CODE END Includes */ 30 | 31 | /* Private typedef -----------------------------------------------------------*/ 32 | /* USER CODE BEGIN PTD */ 33 | 34 | /* USER CODE END PTD */ 35 | 36 | /* Private define ------------------------------------------------------------*/ 37 | /* USER CODE BEGIN PD */ 38 | 39 | /* USER CODE END PD */ 40 | 41 | /* Private macro -------------------------------------------------------------*/ 42 | /* USER CODE BEGIN PM */ 43 | 44 | /* USER CODE END PM */ 45 | 46 | /* Private variables ---------------------------------------------------------*/ 47 | /* USER CODE BEGIN Variables */ 48 | 49 | /* USER CODE END Variables */ 50 | 51 | /* Private function prototypes -----------------------------------------------*/ 52 | /* USER CODE BEGIN FunctionPrototypes */ 53 | 54 | /* USER CODE END FunctionPrototypes */ 55 | 56 | /* Private application code --------------------------------------------------*/ 57 | /* USER CODE BEGIN Application */ 58 | 59 | /* USER CODE END Application */ 60 | 61 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 62 | -------------------------------------------------------------------------------- /src/stm32h7xx_hal_msp.c: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file stm32h7xx_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) 2021 STMicroelectronics. 11 | * All rights reserved.

12 | * 13 | * This software component is licensed by ST under Ultimate Liberty license 14 | * SLA0044, the "License"; You may not use this file except in compliance with 15 | * the License. You may obtain a copy of the License at: 16 | * www.st.com/SLA0044 17 | * 18 | ****************************************************************************** 19 | */ 20 | /* USER CODE END Header */ 21 | 22 | /* Includes ------------------------------------------------------------------*/ 23 | #include "main.h" 24 | /* USER CODE BEGIN Includes */ 25 | 26 | /* USER CODE END Includes */ 27 | 28 | /* Private typedef -----------------------------------------------------------*/ 29 | /* USER CODE BEGIN TD */ 30 | 31 | /* USER CODE END TD */ 32 | 33 | /* Private define ------------------------------------------------------------*/ 34 | /* USER CODE BEGIN Define */ 35 | 36 | /* USER CODE END Define */ 37 | 38 | /* Private macro -------------------------------------------------------------*/ 39 | /* USER CODE BEGIN Macro */ 40 | 41 | /* USER CODE END Macro */ 42 | 43 | /* Private variables ---------------------------------------------------------*/ 44 | /* USER CODE BEGIN PV */ 45 | 46 | /* USER CODE END PV */ 47 | 48 | /* Private function prototypes -----------------------------------------------*/ 49 | /* USER CODE BEGIN PFP */ 50 | 51 | /* USER CODE END PFP */ 52 | 53 | /* External functions --------------------------------------------------------*/ 54 | /* USER CODE BEGIN ExternalFunctions */ 55 | 56 | /* USER CODE END ExternalFunctions */ 57 | 58 | /* USER CODE BEGIN 0 */ 59 | 60 | /* USER CODE END 0 */ 61 | /** 62 | * Initializes the Global MSP. 63 | */ 64 | void HAL_MspInit(void) 65 | { 66 | /* USER CODE BEGIN MspInit 0 */ 67 | 68 | /* USER CODE END MspInit 0 */ 69 | 70 | __HAL_RCC_SYSCFG_CLK_ENABLE(); 71 | 72 | /* System interrupt init*/ 73 | /* PendSV_IRQn interrupt configuration */ 74 | HAL_NVIC_SetPriority(PendSV_IRQn, 15, 0); 75 | 76 | /* USER CODE BEGIN MspInit 1 */ 77 | 78 | /* USER CODE END MspInit 1 */ 79 | } 80 | 81 | /** 82 | * @brief ETH MSP Initialization 83 | * This function configures the hardware resources used in this example 84 | * @param heth: ETH handle pointer 85 | * @retval None 86 | */ 87 | void HAL_ETH_MspInit(ETH_HandleTypeDef* heth) 88 | { 89 | GPIO_InitTypeDef GPIO_InitStruct = {0}; 90 | if(heth->Instance==ETH) 91 | { 92 | /* USER CODE BEGIN ETH_MspInit 0 */ 93 | 94 | /* USER CODE END ETH_MspInit 0 */ 95 | /* Peripheral clock enable */ 96 | __HAL_RCC_ETH1MAC_CLK_ENABLE(); 97 | __HAL_RCC_ETH1TX_CLK_ENABLE(); 98 | __HAL_RCC_ETH1RX_CLK_ENABLE(); 99 | 100 | __HAL_RCC_GPIOC_CLK_ENABLE(); 101 | __HAL_RCC_GPIOA_CLK_ENABLE(); 102 | __HAL_RCC_GPIOB_CLK_ENABLE(); 103 | __HAL_RCC_GPIOG_CLK_ENABLE(); 104 | /**ETH GPIO Configuration 105 | PC1 ------> ETH_MDC 106 | PA1 ------> ETH_REF_CLK 107 | PA2 ------> ETH_MDIO 108 | PA7 ------> ETH_CRS_DV 109 | PC4 ------> ETH_RXD0 110 | PC5 ------> ETH_RXD1 111 | PB13 ------> ETH_TXD1 112 | PG11 ------> ETH_TX_EN 113 | PG13 ------> ETH_TXD0 114 | */ 115 | GPIO_InitStruct.Pin = RMII_MDC_Pin|RMII_RXD0_Pin|RMII_RXD1_Pin; 116 | GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; 117 | GPIO_InitStruct.Pull = GPIO_NOPULL; 118 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; 119 | GPIO_InitStruct.Alternate = GPIO_AF11_ETH; 120 | HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); 121 | 122 | GPIO_InitStruct.Pin = RMII_REF_CLK_Pin|RMII_MDIO_Pin|RMII_CRS_DV_Pin; 123 | GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; 124 | GPIO_InitStruct.Pull = GPIO_NOPULL; 125 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; 126 | GPIO_InitStruct.Alternate = GPIO_AF11_ETH; 127 | HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); 128 | 129 | GPIO_InitStruct.Pin = RMII_TXD1_Pin; 130 | GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; 131 | GPIO_InitStruct.Pull = GPIO_NOPULL; 132 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; 133 | GPIO_InitStruct.Alternate = GPIO_AF11_ETH; 134 | HAL_GPIO_Init(RMII_TXD1_GPIO_Port, &GPIO_InitStruct); 135 | 136 | GPIO_InitStruct.Pin = RMII_TX_EN_Pin|RMII_TXD0_Pin; 137 | GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; 138 | GPIO_InitStruct.Pull = GPIO_NOPULL; 139 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; 140 | GPIO_InitStruct.Alternate = GPIO_AF11_ETH; 141 | HAL_GPIO_Init(GPIOG, &GPIO_InitStruct); 142 | 143 | /* USER CODE BEGIN ETH_MspInit 1 */ 144 | 145 | /* USER CODE END ETH_MspInit 1 */ 146 | } 147 | 148 | } 149 | 150 | /** 151 | * @brief ETH MSP De-Initialization 152 | * This function freeze the hardware resources used in this example 153 | * @param heth: ETH handle pointer 154 | * @retval None 155 | */ 156 | void HAL_ETH_MspDeInit(ETH_HandleTypeDef* heth) 157 | { 158 | if(heth->Instance==ETH) 159 | { 160 | /* USER CODE BEGIN ETH_MspDeInit 0 */ 161 | 162 | /* USER CODE END ETH_MspDeInit 0 */ 163 | /* Peripheral clock disable */ 164 | __HAL_RCC_ETH1MAC_CLK_DISABLE(); 165 | __HAL_RCC_ETH1TX_CLK_DISABLE(); 166 | __HAL_RCC_ETH1RX_CLK_DISABLE(); 167 | 168 | /**ETH GPIO Configuration 169 | PC1 ------> ETH_MDC 170 | PA1 ------> ETH_REF_CLK 171 | PA2 ------> ETH_MDIO 172 | PA7 ------> ETH_CRS_DV 173 | PC4 ------> ETH_RXD0 174 | PC5 ------> ETH_RXD1 175 | PB13 ------> ETH_TXD1 176 | PG11 ------> ETH_TX_EN 177 | PG13 ------> ETH_TXD0 178 | */ 179 | HAL_GPIO_DeInit(GPIOC, RMII_MDC_Pin|RMII_RXD0_Pin|RMII_RXD1_Pin); 180 | 181 | HAL_GPIO_DeInit(GPIOA, RMII_REF_CLK_Pin|RMII_MDIO_Pin|RMII_CRS_DV_Pin); 182 | 183 | HAL_GPIO_DeInit(RMII_TXD1_GPIO_Port, RMII_TXD1_Pin); 184 | 185 | HAL_GPIO_DeInit(GPIOG, RMII_TX_EN_Pin|RMII_TXD0_Pin); 186 | 187 | /* USER CODE BEGIN ETH_MspDeInit 1 */ 188 | 189 | /* USER CODE END ETH_MspDeInit 1 */ 190 | } 191 | 192 | } 193 | 194 | /** 195 | * @brief UART MSP Initialization 196 | * This function configures the hardware resources used in this example 197 | * @param huart: UART handle pointer 198 | * @retval None 199 | */ 200 | void HAL_UART_MspInit(UART_HandleTypeDef* huart) 201 | { 202 | GPIO_InitTypeDef GPIO_InitStruct = {0}; 203 | RCC_PeriphCLKInitTypeDef PeriphClkInitStruct = {0}; 204 | if(huart->Instance==USART3) 205 | { 206 | /* USER CODE BEGIN USART3_MspInit 0 */ 207 | 208 | /* USER CODE END USART3_MspInit 0 */ 209 | /** Initializes the peripherals clock 210 | */ 211 | PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_USART3; 212 | PeriphClkInitStruct.Usart234578ClockSelection = RCC_USART234578CLKSOURCE_D2PCLK1; 213 | if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK) 214 | { 215 | Error_Handler(); 216 | } 217 | 218 | /* Peripheral clock enable */ 219 | __HAL_RCC_USART3_CLK_ENABLE(); 220 | 221 | __HAL_RCC_GPIOD_CLK_ENABLE(); 222 | /**USART3 GPIO Configuration 223 | PD8 ------> USART3_TX 224 | PD9 ------> USART3_RX 225 | */ 226 | GPIO_InitStruct.Pin = STLK_VCP_RX_Pin|STLK_VCP_TX_Pin; 227 | GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; 228 | GPIO_InitStruct.Pull = GPIO_NOPULL; 229 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; 230 | GPIO_InitStruct.Alternate = GPIO_AF7_USART3; 231 | HAL_GPIO_Init(GPIOD, &GPIO_InitStruct); 232 | 233 | /* USER CODE BEGIN USART3_MspInit 1 */ 234 | 235 | /* USER CODE END USART3_MspInit 1 */ 236 | } 237 | 238 | } 239 | 240 | /** 241 | * @brief UART MSP De-Initialization 242 | * This function freeze the hardware resources used in this example 243 | * @param huart: UART handle pointer 244 | * @retval None 245 | */ 246 | void HAL_UART_MspDeInit(UART_HandleTypeDef* huart) 247 | { 248 | if(huart->Instance==USART3) 249 | { 250 | /* USER CODE BEGIN USART3_MspDeInit 0 */ 251 | 252 | /* USER CODE END USART3_MspDeInit 0 */ 253 | /* Peripheral clock disable */ 254 | __HAL_RCC_USART3_CLK_DISABLE(); 255 | 256 | /**USART3 GPIO Configuration 257 | PD8 ------> USART3_TX 258 | PD9 ------> USART3_RX 259 | */ 260 | HAL_GPIO_DeInit(GPIOD, STLK_VCP_RX_Pin|STLK_VCP_TX_Pin); 261 | 262 | /* USER CODE BEGIN USART3_MspDeInit 1 */ 263 | 264 | /* USER CODE END USART3_MspDeInit 1 */ 265 | } 266 | 267 | } 268 | 269 | /* USER CODE BEGIN 1 */ 270 | 271 | /* USER CODE END 1 */ 272 | 273 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 274 | -------------------------------------------------------------------------------- /src/stm32h7xx_hal_timebase_tim.c: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file stm32h7xx_hal_timebase_TIM.c 5 | * @brief HAL time base based on the hardware TIM. 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | *

© Copyright (c) 2021 STMicroelectronics. 10 | * All rights reserved.

11 | * 12 | * This software component is licensed by ST under Ultimate Liberty license 13 | * SLA0044, the "License"; You may not use this file except in compliance with 14 | * the License. You may obtain a copy of the License at: 15 | * www.st.com/SLA0044 16 | * 17 | ****************************************************************************** 18 | */ 19 | /* USER CODE END Header */ 20 | 21 | /* Includes ------------------------------------------------------------------*/ 22 | #include "stm32h7xx_hal.h" 23 | #include "stm32h7xx_hal_tim.h" 24 | 25 | /* Private typedef -----------------------------------------------------------*/ 26 | /* Private define ------------------------------------------------------------*/ 27 | /* Private macro -------------------------------------------------------------*/ 28 | /* Private variables ---------------------------------------------------------*/ 29 | TIM_HandleTypeDef htim2; 30 | /* Private function prototypes -----------------------------------------------*/ 31 | /* Private functions ---------------------------------------------------------*/ 32 | 33 | /** 34 | * @brief This function configures the TIM2 as a time base source. 35 | * The time source is configured to have 1ms time base with a dedicated 36 | * Tick interrupt priority. 37 | * @note This function is called automatically at the beginning of program after 38 | * reset by HAL_Init() or at any time when clock is configured, by HAL_RCC_ClockConfig(). 39 | * @param TickPriority: Tick interrupt priority. 40 | * @retval HAL status 41 | */ 42 | HAL_StatusTypeDef HAL_InitTick(uint32_t TickPriority) 43 | { 44 | RCC_ClkInitTypeDef clkconfig; 45 | uint32_t uwTimclock, uwAPB1Prescaler; 46 | 47 | uint32_t uwPrescalerValue; 48 | uint32_t pFLatency; 49 | /*Configure the TIM2 IRQ priority */ 50 | if (TickPriority < (1UL << __NVIC_PRIO_BITS)) 51 | { 52 | HAL_NVIC_SetPriority(TIM2_IRQn, TickPriority ,0U); 53 | 54 | /* Enable the TIM2 global Interrupt */ 55 | HAL_NVIC_EnableIRQ(TIM2_IRQn); 56 | uwTickPrio = TickPriority; 57 | } 58 | else 59 | { 60 | return HAL_ERROR; 61 | } 62 | /* Enable TIM2 clock */ 63 | __HAL_RCC_TIM2_CLK_ENABLE(); 64 | 65 | /* Get clock configuration */ 66 | HAL_RCC_GetClockConfig(&clkconfig, &pFLatency); 67 | 68 | /* Get APB1 prescaler */ 69 | uwAPB1Prescaler = clkconfig.APB1CLKDivider; 70 | /* Compute TIM2 clock */ 71 | if (uwAPB1Prescaler == RCC_HCLK_DIV1) 72 | { 73 | uwTimclock = HAL_RCC_GetPCLK1Freq(); 74 | } 75 | else 76 | { 77 | uwTimclock = 2UL * HAL_RCC_GetPCLK1Freq(); 78 | } 79 | 80 | /* Compute the prescaler value to have TIM2 counter clock equal to 1MHz */ 81 | uwPrescalerValue = (uint32_t) ((uwTimclock / 1000000U) - 1U); 82 | 83 | /* Initialize TIM2 */ 84 | htim2.Instance = TIM2; 85 | 86 | /* Initialize TIMx peripheral as follow: 87 | + Period = [(TIM2CLK/1000) - 1]. to have a (1/1000) s time base. 88 | + Prescaler = (uwTimclock/1000000 - 1) to have a 1MHz counter clock. 89 | + ClockDivision = 0 90 | + Counter direction = Up 91 | */ 92 | htim2.Init.Period = (1000000U / 1000U) - 1U; 93 | htim2.Init.Prescaler = uwPrescalerValue; 94 | htim2.Init.ClockDivision = 0; 95 | htim2.Init.CounterMode = TIM_COUNTERMODE_UP; 96 | if(HAL_TIM_Base_Init(&htim2) == HAL_OK) 97 | { 98 | /* Start the TIM time Base generation in interrupt mode */ 99 | return HAL_TIM_Base_Start_IT(&htim2); 100 | } 101 | 102 | /* Return function status */ 103 | return HAL_ERROR; 104 | } 105 | 106 | /** 107 | * @brief Suspend Tick increment. 108 | * @note Disable the tick increment by disabling TIM2 update interrupt. 109 | * @param None 110 | * @retval None 111 | */ 112 | void HAL_SuspendTick(void) 113 | { 114 | /* Disable TIM2 update Interrupt */ 115 | __HAL_TIM_DISABLE_IT(&htim2, TIM_IT_UPDATE); 116 | } 117 | 118 | /** 119 | * @brief Resume Tick increment. 120 | * @note Enable the tick increment by Enabling TIM2 update interrupt. 121 | * @param None 122 | * @retval None 123 | */ 124 | void HAL_ResumeTick(void) 125 | { 126 | /* Enable TIM2 Update interrupt */ 127 | __HAL_TIM_ENABLE_IT(&htim2, TIM_IT_UPDATE); 128 | } 129 | 130 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 131 | -------------------------------------------------------------------------------- /src/stm32h7xx_it.c: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file stm32h7xx_it.c 5 | * @brief Interrupt Service Routines. 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | *

© Copyright (c) 2021 STMicroelectronics. 10 | * All rights reserved.

11 | * 12 | * This software component is licensed by ST under Ultimate Liberty license 13 | * SLA0044, the "License"; You may not use this file except in compliance with 14 | * the License. You may obtain a copy of the License at: 15 | * www.st.com/SLA0044 16 | * 17 | ****************************************************************************** 18 | */ 19 | /* USER CODE END Header */ 20 | 21 | /* Includes ------------------------------------------------------------------*/ 22 | #include "main.h" 23 | #include "stm32h7xx_it.h" 24 | /* Private includes ----------------------------------------------------------*/ 25 | /* USER CODE BEGIN Includes */ 26 | /* USER CODE END Includes */ 27 | 28 | /* Private typedef -----------------------------------------------------------*/ 29 | /* USER CODE BEGIN TD */ 30 | 31 | /* USER CODE END TD */ 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 | /* USER CODE BEGIN PV */ 45 | 46 | /* USER CODE END PV */ 47 | 48 | /* Private function prototypes -----------------------------------------------*/ 49 | /* USER CODE BEGIN PFP */ 50 | 51 | /* USER CODE END PFP */ 52 | 53 | /* Private user code ---------------------------------------------------------*/ 54 | /* USER CODE BEGIN 0 */ 55 | 56 | /* USER CODE END 0 */ 57 | 58 | /* External variables --------------------------------------------------------*/ 59 | extern TIM_HandleTypeDef htim2; 60 | 61 | /* USER CODE BEGIN EV */ 62 | 63 | /* USER CODE END EV */ 64 | 65 | /******************************************************************************/ 66 | /* Cortex Processor Interruption and Exception Handlers */ 67 | /******************************************************************************/ 68 | /** 69 | * @brief This function handles Non maskable interrupt. 70 | */ 71 | void NMI_Handler(void) 72 | { 73 | /* USER CODE BEGIN NonMaskableInt_IRQn 0 */ 74 | 75 | /* USER CODE END NonMaskableInt_IRQn 0 */ 76 | /* USER CODE BEGIN NonMaskableInt_IRQn 1 */ 77 | while (1) 78 | { 79 | } 80 | /* USER CODE END NonMaskableInt_IRQn 1 */ 81 | } 82 | 83 | /** 84 | * @brief This function handles Hard fault interrupt. 85 | */ 86 | void HardFault_Handler(void) 87 | { 88 | /* USER CODE BEGIN HardFault_IRQn 0 */ 89 | 90 | /* USER CODE END HardFault_IRQn 0 */ 91 | while (1) 92 | { 93 | /* USER CODE BEGIN W1_HardFault_IRQn 0 */ 94 | /* USER CODE END W1_HardFault_IRQn 0 */ 95 | } 96 | } 97 | 98 | /** 99 | * @brief This function handles Memory management fault. 100 | */ 101 | void MemManage_Handler(void) 102 | { 103 | /* USER CODE BEGIN MemoryManagement_IRQn 0 */ 104 | 105 | /* USER CODE END MemoryManagement_IRQn 0 */ 106 | while (1) 107 | { 108 | /* USER CODE BEGIN W1_MemoryManagement_IRQn 0 */ 109 | /* USER CODE END W1_MemoryManagement_IRQn 0 */ 110 | } 111 | } 112 | 113 | /** 114 | * @brief This function handles Pre-fetch fault, memory access fault. 115 | */ 116 | void BusFault_Handler(void) 117 | { 118 | /* USER CODE BEGIN BusFault_IRQn 0 */ 119 | 120 | /* USER CODE END BusFault_IRQn 0 */ 121 | while (1) 122 | { 123 | /* USER CODE BEGIN W1_BusFault_IRQn 0 */ 124 | /* USER CODE END W1_BusFault_IRQn 0 */ 125 | } 126 | } 127 | 128 | /** 129 | * @brief This function handles Undefined instruction or illegal state. 130 | */ 131 | void UsageFault_Handler(void) 132 | { 133 | /* USER CODE BEGIN UsageFault_IRQn 0 */ 134 | 135 | /* USER CODE END UsageFault_IRQn 0 */ 136 | while (1) 137 | { 138 | /* USER CODE BEGIN W1_UsageFault_IRQn 0 */ 139 | /* USER CODE END W1_UsageFault_IRQn 0 */ 140 | } 141 | } 142 | 143 | /** 144 | * @brief This function handles Debug monitor. 145 | */ 146 | void DebugMon_Handler(void) 147 | { 148 | /* USER CODE BEGIN DebugMonitor_IRQn 0 */ 149 | 150 | /* USER CODE END DebugMonitor_IRQn 0 */ 151 | /* USER CODE BEGIN DebugMonitor_IRQn 1 */ 152 | 153 | /* USER CODE END DebugMonitor_IRQn 1 */ 154 | } 155 | 156 | /******************************************************************************/ 157 | /* STM32H7xx Peripheral Interrupt Handlers */ 158 | /* Add here the Interrupt Handlers for the used peripherals. */ 159 | /* For the available peripheral interrupt handler names, */ 160 | /* please refer to the startup file (startup_stm32h7xx.s). */ 161 | /******************************************************************************/ 162 | 163 | /** 164 | * @brief This function handles TIM2 global interrupt. 165 | */ 166 | void TIM2_IRQHandler(void) 167 | { 168 | /* USER CODE BEGIN TIM2_IRQn 0 */ 169 | 170 | /* USER CODE END TIM2_IRQn 0 */ 171 | HAL_TIM_IRQHandler(&htim2); 172 | /* USER CODE BEGIN TIM2_IRQn 1 */ 173 | 174 | /* USER CODE END TIM2_IRQn 1 */ 175 | } 176 | 177 | /* USER CODE BEGIN 1 */ 178 | 179 | /* USER CODE END 1 */ 180 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 181 | -------------------------------------------------------------------------------- /src/syscalls.c: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file syscalls.c 4 | * @author Auto-generated by STM32CubeIDE 5 | * @brief STM32CubeIDE 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 STMicroelectronics. 14 | * All rights reserved.

15 | * 16 | * This software component is licensed by ST under BSD 3-Clause license, 17 | * the "License"; You may not use this file except in compliance with the 18 | * License. You may obtain a copy of the License at: 19 | * opensource.org/licenses/BSD-3-Clause 20 | * 21 | ****************************************************************************** 22 | */ 23 | 24 | /* Includes */ 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | 34 | 35 | /* Variables */ 36 | extern int __io_putchar(int ch) __attribute__((weak)); 37 | extern int __io_getchar(void) __attribute__((weak)); 38 | 39 | 40 | char *__env[1] = { 0 }; 41 | char **environ = __env; 42 | 43 | 44 | /* Functions */ 45 | void initialise_monitor_handles() 46 | { 47 | } 48 | 49 | int _getpid(void) 50 | { 51 | return 1; 52 | } 53 | 54 | int _kill(int pid, int sig) 55 | { 56 | errno = EINVAL; 57 | return -1; 58 | } 59 | 60 | void _exit (int status) 61 | { 62 | _kill(status, -1); 63 | while (1) {} /* Make sure we hang here */ 64 | } 65 | 66 | __attribute__((weak)) int _read(int file, char *ptr, int len) 67 | { 68 | int DataIdx; 69 | 70 | for (DataIdx = 0; DataIdx < len; DataIdx++) 71 | { 72 | *ptr++ = __io_getchar(); 73 | } 74 | 75 | return len; 76 | } 77 | 78 | __attribute__((weak)) int _write(int file, char *ptr, int len) 79 | { 80 | int DataIdx; 81 | 82 | for (DataIdx = 0; DataIdx < len; DataIdx++) 83 | { 84 | __io_putchar(*ptr++); 85 | } 86 | return len; 87 | } 88 | 89 | int _close(int file) 90 | { 91 | return -1; 92 | } 93 | 94 | 95 | int _fstat(int file, struct stat *st) 96 | { 97 | st->st_mode = S_IFCHR; 98 | return 0; 99 | } 100 | 101 | int _isatty(int file) 102 | { 103 | return 1; 104 | } 105 | 106 | int _lseek(int file, int ptr, int dir) 107 | { 108 | return 0; 109 | } 110 | 111 | int _open(char *path, int flags, ...) 112 | { 113 | /* Pretend like we always fail */ 114 | return -1; 115 | } 116 | 117 | int _wait(int *status) 118 | { 119 | errno = ECHILD; 120 | return -1; 121 | } 122 | 123 | int _unlink(char *name) 124 | { 125 | errno = ENOENT; 126 | return -1; 127 | } 128 | 129 | int _times(struct tms *buf) 130 | { 131 | return -1; 132 | } 133 | 134 | int _stat(char *file, struct stat *st) 135 | { 136 | st->st_mode = S_IFCHR; 137 | return 0; 138 | } 139 | 140 | int _link(char *old, char *new) 141 | { 142 | errno = EMLINK; 143 | return -1; 144 | } 145 | 146 | int _fork(void) 147 | { 148 | errno = EAGAIN; 149 | return -1; 150 | } 151 | 152 | int _execve(char *name, char **argv, char **env) 153 | { 154 | errno = ENOMEM; 155 | return -1; 156 | } 157 | -------------------------------------------------------------------------------- /src/sysmem.c: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file sysmem.c 4 | * @author Generated by STM32CubeIDE 5 | * @brief STM32CubeIDE 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) 2020 STMicroelectronics. 14 | * All rights reserved.

15 | * 16 | * This software component is licensed by ST under BSD 3-Clause license, 17 | * the "License"; You may not use this file except in compliance with the 18 | * License. You may obtain a copy of the License at: 19 | * opensource.org/licenses/BSD-3-Clause 20 | * 21 | ****************************************************************************** 22 | */ 23 | 24 | /* Includes */ 25 | #include 26 | #include 27 | 28 | /** 29 | * Pointer to the current high watermark of the heap usage 30 | */ 31 | static uint8_t *__sbrk_heap_end = NULL; 32 | 33 | /** 34 | * @brief _sbrk() allocates memory to the newlib heap and is used by malloc 35 | * and others from the C library 36 | * 37 | * @verbatim 38 | * ############################################################################ 39 | * # .data # .bss # newlib heap # MSP stack # 40 | * # # # # Reserved by _Min_Stack_Size # 41 | * ############################################################################ 42 | * ^-- RAM start ^-- _end _estack, RAM end --^ 43 | * @endverbatim 44 | * 45 | * This implementation starts allocating at the '_end' linker symbol 46 | * The '_Min_Stack_Size' linker symbol reserves a memory for the MSP stack 47 | * The implementation considers '_estack' linker symbol to be RAM end 48 | * NOTE: If the MSP stack, at any point during execution, grows larger than the 49 | * reserved size, please increase the '_Min_Stack_Size'. 50 | * 51 | * @param incr Memory size 52 | * @return Pointer to allocated memory 53 | */ 54 | void *_sbrk(ptrdiff_t incr) 55 | { 56 | extern uint8_t _end; /* Symbol defined in the linker script */ 57 | extern uint8_t _estack; /* Symbol defined in the linker script */ 58 | extern uint32_t _Min_Stack_Size; /* Symbol defined in the linker script */ 59 | const uint32_t stack_limit = (uint32_t)&_estack - (uint32_t)&_Min_Stack_Size; 60 | const uint8_t *max_heap = (uint8_t *)stack_limit; 61 | uint8_t *prev_heap_end; 62 | 63 | /* Initialize heap end at first call */ 64 | if (NULL == __sbrk_heap_end) 65 | { 66 | __sbrk_heap_end = &_end; 67 | } 68 | 69 | /* Protect heap from growing into the reserved MSP stack */ 70 | if (__sbrk_heap_end + incr > max_heap) 71 | { 72 | errno = ENOMEM; 73 | return (void *)-1; 74 | } 75 | 76 | prev_heap_end = __sbrk_heap_end; 77 | __sbrk_heap_end += incr; 78 | 79 | return (void *)prev_heap_end; 80 | } 81 | -------------------------------------------------------------------------------- /test/README: -------------------------------------------------------------------------------- 1 | 2 | This directory is intended for PlatformIO Unit Testing and project tests. 3 | 4 | Unit Testing is a software testing method by which individual units of 5 | source code, sets of one or more MCU program modules together with associated 6 | control data, usage procedures, and operating procedures, are tested to 7 | determine whether they are fit for use. Unit testing finds problems early 8 | in the development cycle. 9 | 10 | More information about PlatformIO Unit Testing: 11 | - https://docs.platformio.org/page/plus/unit-testing.html 12 | --------------------------------------------------------------------------------