├── cdh-tsat-stm32project-board ├── App │ ├── Src │ │ ├── bdot_algorithm.c │ │ ├── telemetry_handling.c │ │ ├── deployment_tasks.c │ │ ├── unit_tests.c │ │ ├── command_handling.c │ │ ├── rtc.c │ │ └── task_control.c │ └── Inc │ │ ├── telemetry_handling.h │ │ ├── bdot_algorithm.h │ │ ├── unit_tests.h │ │ ├── deployment_tasks.h │ │ ├── rtc.h │ │ ├── task_control.h │ │ └── command_handling.h ├── Drivers │ ├── CMSIS │ │ ├── Device │ │ │ └── ST │ │ │ │ └── STM32L4xx │ │ │ │ ├── LICENSE.txt │ │ │ │ └── Include │ │ │ │ └── system_stm32l4xx.h │ │ └── Include │ │ │ ├── cmsis_version.h │ │ │ └── tz_context.h │ ├── STM32L4xx_HAL_Driver │ │ ├── LICENSE.txt │ │ ├── Inc │ │ │ ├── stm32l4xx_hal_spi_ex.h │ │ │ ├── stm32l4xx_hal_flash_ramfunc.h │ │ │ ├── stm32l4xx_hal_flash_ex.h │ │ │ └── stm32l4xx_hal_crc_ex.h │ │ └── Src │ │ │ └── stm32l4xx_hal_spi_ex.c │ └── Hardware_Peripherals │ │ ├── Src │ │ ├── MAX6822_driver.c │ │ ├── LTC1154_driver.c │ │ └── LEDs_driver.c │ │ ├── Inc │ │ ├── LTC1154_driver.h │ │ ├── LEDs_driver.h │ │ └── MAX6822_driver.h │ │ └── Test │ │ └── Inc │ │ └── AS3001204_driver_test.h ├── Core │ ├── Src │ │ ├── telemetry.c │ │ ├── freertos.c │ │ ├── utils.c │ │ ├── sysmem.c │ │ ├── syscalls.c │ │ ├── stm32l4xx_hal_timebase_tim.c │ │ └── stm32l4xx_it.c │ └── Inc │ │ ├── telemetry.h │ │ ├── stm32l4xx_it.h │ │ ├── utils.h │ │ └── main.h ├── Middlewares │ └── Third_Party │ │ └── FreeRTOS │ │ └── Source │ │ ├── LICENSE │ │ ├── CMSIS_RTOS_V2 │ │ └── freertos_mpool.h │ │ └── include │ │ ├── projdefs.h │ │ ├── stack_macros.h │ │ └── StackMacros.h ├── .project ├── STM32L496RGTX_RAM.ld └── STM32L496RGTX_FLASH.ld ├── .gitmodules ├── cdh-tsat-stm32project-nucleo ├── Drivers │ ├── CMSIS │ │ ├── Device │ │ │ └── ST │ │ │ │ └── STM32L4xx │ │ │ │ ├── LICENSE.txt │ │ │ │ └── Include │ │ │ │ └── system_stm32l4xx.h │ │ └── Include │ │ │ ├── cmsis_version.h │ │ │ └── tz_context.h │ ├── STM32L4xx_HAL_Driver │ │ ├── LICENSE.txt │ │ ├── Inc │ │ │ ├── stm32l4xx_hal_spi_ex.h │ │ │ ├── stm32l4xx_hal_flash_ramfunc.h │ │ │ └── stm32l4xx_hal_flash_ex.h │ │ └── Src │ │ │ └── stm32l4xx_hal_spi_ex.c │ └── Hardware_Peripherals │ │ ├── Src │ │ ├── MAX6822_driver.c │ │ ├── LTC1154_driver.c │ │ └── LEDs_driver.c │ │ ├── Inc │ │ ├── LTC1154_driver.h │ │ ├── LEDs_driver.h │ │ └── MAX6822_driver.h │ │ └── Test │ │ └── Inc │ │ └── AS3001204_driver_test.h ├── Middlewares │ └── Third_Party │ │ └── FreeRTOS │ │ └── Source │ │ ├── LICENSE │ │ ├── CMSIS_RTOS_V2 │ │ └── freertos_mpool.h │ │ └── include │ │ ├── projdefs.h │ │ ├── stack_macros.h │ │ └── StackMacros.h ├── .project ├── Core │ ├── Src │ │ ├── freertos.c │ │ ├── sysmem.c │ │ ├── syscalls.c │ │ └── stm32l4xx_hal_timebase_tim.c │ └── Inc │ │ ├── stm32l4xx_it.h │ │ └── main.h ├── STM32L452RETX_RAM.ld └── STM32L452RETX_FLASH.ld ├── .gitignore ├── LICENSE └── README.md /cdh-tsat-stm32project-board/App/Src/bdot_algorithm.c: -------------------------------------------------------------------------------- 1 | /* 2 | * bdot_algorithm.c 3 | * 4 | * Created on: Feb 15, 2025 5 | * Author: drive 6 | */ 7 | #include "bdot_algorithm.h" 8 | 9 | void StartBDot(void *argument){ 10 | 11 | for(;;){ 12 | //B Dot Algorithm Code 13 | } 14 | osThreadExit(); 15 | } 16 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "cdh-tsat-stm32project-board/External/tsat-utilities-kit"] 2 | path = cdh-tsat-stm32project-board/External/tsat-utilities-kit 3 | url = https://github.com/UMSATS/tsat-utilities-kit 4 | [submodule "cdh-tsat-stm32project-nucleo/External/tsat-utilities-kit"] 5 | path = cdh-tsat-stm32project-nucleo/External/tsat-utilities-kit 6 | url = https://github.com/UMSATS/tsat-utilities-kit 7 | -------------------------------------------------------------------------------- /cdh-tsat-stm32project-board/Drivers/CMSIS/Device/ST/STM32L4xx/LICENSE.txt: -------------------------------------------------------------------------------- 1 | This software component is provided to you as part of a software package and 2 | applicable license terms are in the Package_license file. If you received this 3 | software component outside of a package or without applicable license terms, 4 | the terms of the Apache-2.0 license shall apply. 5 | You may obtain a copy of the Apache-2.0 at: 6 | https://opensource.org/licenses/Apache-2.0 7 | -------------------------------------------------------------------------------- /cdh-tsat-stm32project-board/Drivers/STM32L4xx_HAL_Driver/LICENSE.txt: -------------------------------------------------------------------------------- 1 | This software component is provided to you as part of a software package and 2 | applicable license terms are in the Package_license file. If you received this 3 | software component outside of a package or without applicable license terms, 4 | the terms of the BSD-3-Clause license shall apply. 5 | You may obtain a copy of the BSD-3-Clause at: 6 | https://opensource.org/licenses/BSD-3-Clause 7 | -------------------------------------------------------------------------------- /cdh-tsat-stm32project-nucleo/Drivers/CMSIS/Device/ST/STM32L4xx/LICENSE.txt: -------------------------------------------------------------------------------- 1 | This software component is provided to you as part of a software package and 2 | applicable license terms are in the Package_license file. If you received this 3 | software component outside of a package or without applicable license terms, 4 | the terms of the Apache-2.0 license shall apply. 5 | You may obtain a copy of the Apache-2.0 at: 6 | https://opensource.org/licenses/Apache-2.0 7 | -------------------------------------------------------------------------------- /cdh-tsat-stm32project-nucleo/Drivers/STM32L4xx_HAL_Driver/LICENSE.txt: -------------------------------------------------------------------------------- 1 | This software component is provided to you as part of a software package and 2 | applicable license terms are in the Package_license file. If you received this 3 | software component outside of a package or without applicable license terms, 4 | the terms of the BSD-3-Clause license shall apply. 5 | You may obtain a copy of the BSD-3-Clause at: 6 | https://opensource.org/licenses/BSD-3-Clause 7 | -------------------------------------------------------------------------------- /cdh-tsat-stm32project-board/App/Src/telemetry_handling.c: -------------------------------------------------------------------------------- 1 | /* 2 | * telemetry_handling.c 3 | * 4 | * Created on: Feb 15, 2025 5 | * Author: drive 6 | */ 7 | 8 | #include "telemetry_handling.h" 9 | 10 | void StartTelemHandler(void *argument) 11 | { 12 | TelemetryMessage_t telemetry_message; 13 | /* Infinite loop */ 14 | for(;;) 15 | { 16 | osMessageQueueGet(telemQueueHandle, &telemetry_message, NULL, osWaitForever); 17 | switch(telemetry_message.id) 18 | { 19 | //TODO: Implement telemetry handling 20 | } 21 | } 22 | osThreadExit(); 23 | } 24 | -------------------------------------------------------------------------------- /cdh-tsat-stm32project-board/App/Inc/telemetry_handling.h: -------------------------------------------------------------------------------- 1 | /* 2 | * telemetry_handling.h 3 | * 4 | * Created on: Feb 15, 2025 5 | * Author: drive 6 | */ 7 | 8 | #ifndef INC_TELEMETRY_HANDLING_H_ 9 | #define INC_TELEMETRY_HANDLING_H_ 10 | 11 | #include "stm32l4xx_hal.h" 12 | #include "cmsis_os.h" 13 | #include "telemetry.h" 14 | 15 | extern osMessageQueueId_t telemQueueHandle; 16 | 17 | 18 | /** 19 | * @brief Function implementing the telemHandler thread. 20 | * @param argument: Not used 21 | * @retval None 22 | */ 23 | void StartTelemHandler(void *argument); 24 | 25 | #endif /* INC_TELEMETRY_HANDLING_H_ */ 26 | -------------------------------------------------------------------------------- /cdh-tsat-stm32project-board/App/Inc/bdot_algorithm.h: -------------------------------------------------------------------------------- 1 | /* 2 | * bdot_algorithm.h 3 | * 4 | * Created on: Feb 15, 2025 5 | * Author: drive 6 | */ 7 | 8 | #ifndef INC_BDOT_ALGORITHM_H_ 9 | #define INC_BDOT_ALGORITHM_H_ 10 | 11 | #include 12 | #include 13 | 14 | #include "stm32l4xx_hal.h" 15 | #include "cmsis_os.h" 16 | 17 | 18 | extern osThreadId_t calculateBDotHandle; 19 | 20 | 21 | /* USER CODE BEGIN StartBDot */ 22 | /** 23 | * @brief Function implementing the StartBDot thread. 24 | * @param argument: Not used 25 | * @retval None 26 | */ 27 | void StartBDot(void *argument); 28 | 29 | 30 | #endif /* INC_BDOT_ALGORITHM_H_ */ 31 | -------------------------------------------------------------------------------- /cdh-tsat-stm32project-board/Core/Src/telemetry.c: -------------------------------------------------------------------------------- 1 | /* 2 | * FILENAME: telemetry.c 3 | * 4 | * DESCRIPTION: Telemetry data application code source file. 5 | * 6 | * AUTHORS: 7 | * - Daigh Burgess (daigh.burgess@umsats.ca) 8 | * 9 | * CREATED ON: Nov. 5, 2023 10 | */ 11 | 12 | //############################################################################################### 13 | //Include Directives 14 | //############################################################################################### 15 | #include 16 | 17 | #include "stm32l4xx_hal.h" 18 | #include "telemetry.h" 19 | 20 | 21 | //TODO: Implement telemetry data processing/handling functions 22 | -------------------------------------------------------------------------------- /cdh-tsat-stm32project-board/App/Inc/unit_tests.h: -------------------------------------------------------------------------------- 1 | /* 2 | * unit_tests.h 3 | * 4 | * Created on: Feb 15, 2025 5 | * Author: drive 6 | */ 7 | 8 | #ifndef INC_UNIT_TESTS_H_ 9 | #define INC_UNIT_TESTS_H_ 10 | 11 | #include "stm32l4xx_hal.h" 12 | #include "cmsis_os.h" 13 | #include "W25N_driver.h" 14 | #include "W25N_driver_test.h" 15 | #include "AS3001204_driver.h" 16 | #include "AS3001204_driver_test.h" 17 | 18 | /** 19 | * @brief Function implementing the flashUnitTest thread. 20 | * @param argument: Not used 21 | * @retval None 22 | */ 23 | void StartFlashUnitTest(void *argument); 24 | 25 | 26 | /** 27 | * @brief Function implementing the mramUnitTest thread. 28 | * @param argument: Not used 29 | * @retval None 30 | */ 31 | void StartMramUnitTest(void *argument); 32 | 33 | #endif /* INC_UNIT_TESTS_H_ */ 34 | -------------------------------------------------------------------------------- /cdh-tsat-stm32project-board/App/Inc/deployment_tasks.h: -------------------------------------------------------------------------------- 1 | /* 2 | * deployment_tasks.h 3 | * 4 | * Created on: Feb 15, 2025 5 | * Author: drive 6 | */ 7 | 8 | #ifndef INC_DEPLOYMENT_TASKS_H_ 9 | #define INC_DEPLOYMENT_TASKS_H_ 10 | 11 | #include "stm32l4xx_hal.h" 12 | #include "LTC1154_driver.h" 13 | #include "cmsis_os.h" 14 | 15 | 16 | /* USER CODE BEGIN Header_StartDeployA */ 17 | /** 18 | * @brief Function implementing the deployA thread. 19 | * @param argument: Not used 20 | * @retval None 21 | */ 22 | void StartDeployA(void *argument); 23 | 24 | 25 | /* USER CODE BEGIN Header_StartDeployB */ 26 | /** 27 | * @brief Function implementing the deployB thread. 28 | * @param argument: Not used 29 | * @retval None 30 | */ 31 | void StartDeployB(void *argument); 32 | 33 | 34 | #endif /* INC_DEPLOYMENT_TASKS_H_ */ 35 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ################################################## 2 | # Eclipse 3 | ################################################## 4 | # IDE Settings 5 | .metadata/ 6 | .settings/ 7 | 8 | # Launch Configurations 9 | *.launch 10 | 11 | ################################################## 12 | # STM32CubeIDE 13 | ################################################## 14 | # Build Directories 15 | Debug/ 16 | Release/ 17 | 18 | # Keep These Files 19 | #.cproject # Contains include paths and build settings. 20 | #.project # Contains project metadata. 21 | #.mxproject # Contains include paths for HAL. 22 | 23 | ################################################## 24 | # Other 25 | ################################################## 26 | 27 | # Vim 28 | *.swp 29 | 30 | # VSCode 31 | .vscode/ 32 | 33 | # Visual Studio 34 | .vs/ 35 | 36 | # Build Directories 37 | build/ 38 | bin/ -------------------------------------------------------------------------------- /cdh-tsat-stm32project-board/App/Inc/rtc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * rtc.h 3 | * 4 | * Created on: Feb 15, 2025 5 | * Author: drive 6 | */ 7 | 8 | #ifndef INC_RTC_H_ 9 | #define INC_RTC_H_ 10 | 11 | #include 12 | #include 13 | 14 | #include "MAX6822_driver.h" 15 | #include "stm32l4xx_hal.h" 16 | #include "cmsis_os.h" 17 | #include "utils.h" 18 | 19 | extern osMessageQueueId_t setRTCQueueHandle;; 20 | extern RTC_HandleTypeDef hrtc; 21 | 22 | 23 | /* USER CODE BEGIN StartSetRTC */ 24 | /** 25 | * @brief Function implementing the StartSetRTC thread. 26 | * @param argument: Not used 27 | * @retval None 28 | */ 29 | void StartSetRTC(void *argument); 30 | 31 | 32 | /* USER CODE BEGIN StartGetRTC */ 33 | /** 34 | * @brief Function implementing the StartGetRTC thread. 35 | * @param argument: Not used 36 | * @retval None 37 | */ 38 | void StartGetRTC(void *argument); 39 | 40 | 41 | #endif /* INC_RTC_H_ */ 42 | -------------------------------------------------------------------------------- /cdh-tsat-stm32project-board/App/Src/deployment_tasks.c: -------------------------------------------------------------------------------- 1 | /* 2 | * deployment_tasks.c 3 | * 4 | * Created on: Feb 15, 2025 5 | * Author: drive 6 | */ 7 | 8 | #include "deployment_tasks.h" 9 | 10 | void StartDeployA(void *argument) 11 | { 12 | /* USER CODE BEGIN StartDeployA */ 13 | /* Infinite loop */ 14 | for(;;) 15 | { 16 | //block until thread resumed from command handler 17 | osThreadFlagsWait(0x0001, osFlagsWaitAny, osWaitForever); 18 | 19 | LTC1154_Enable(); 20 | } 21 | osThreadExit(); 22 | /* USER CODE END StartDeployA */ 23 | } 24 | 25 | 26 | void StartDeployB(void *argument) 27 | { 28 | /* USER CODE BEGIN StartDeployB */ 29 | /* Infinite loop */ 30 | for(;;) 31 | { 32 | //block until thread resumed from command handler 33 | osThreadFlagsWait(0x0001, osFlagsWaitAny, osWaitForever); 34 | 35 | LTC1154_On(); 36 | } 37 | osThreadExit(); 38 | /* USER CODE END StartDeployB */ 39 | } 40 | -------------------------------------------------------------------------------- /cdh-tsat-stm32project-board/App/Src/unit_tests.c: -------------------------------------------------------------------------------- 1 | /* 2 | * unit_tests.c 3 | * 4 | * Created on: Feb 15, 2025 5 | * Author: drive 6 | */ 7 | 8 | #include "unit_tests.h" 9 | 10 | void StartFlashUnitTest(void *argument) 11 | { 12 | /* Infinite loop */ 13 | for(;;) 14 | { 15 | //block until thread resumed from command handler 16 | osThreadFlagsWait(0x0001, osFlagsWaitAny, osWaitForever); 17 | 18 | W25N_StatusTypeDef test_result = Test_W25N(); 19 | 20 | //TODO: Add CAN message transmit 21 | } 22 | osThreadExit(); 23 | } 24 | 25 | 26 | void StartMramUnitTest(void *argument) 27 | { 28 | /* Infinite loop */ 29 | for(;;) 30 | { 31 | //block until thread resumed from command handler 32 | osThreadFlagsWait(0x0001, osFlagsWaitAny, osWaitForever); 33 | 34 | HAL_StatusTypeDef test_result = AS3001204_Test_MRAM_Driver(); 35 | 36 | //TODO: Add CAN message transmit 37 | } 38 | osThreadExit(); 39 | } 40 | -------------------------------------------------------------------------------- /cdh-tsat-stm32project-board/App/Inc/task_control.h: -------------------------------------------------------------------------------- 1 | /* 2 | * time_tagged_task.h 3 | * 4 | * Created on: Feb 15, 2025 5 | * Author: drive 6 | */ 7 | 8 | #ifndef INC_TASK_CONTROL_H_ 9 | #define INC_TASK_CONTROL_H_ 10 | 11 | #include "stm32l4xx_hal.h" 12 | #include "cmsis_os.h" 13 | #include "utils.h" 14 | 15 | extern osMessageQueueId_t timeTagTaskInitQueueHandle; 16 | extern RTC_HandleTypeDef hrtc; 17 | 18 | 19 | /** 20 | * @brief Function implementing the timeTagTaskInit thread. 21 | * @param argument: Not used 22 | * @retval None 23 | */ 24 | void StartTimeTagTaskInit(void *argument); 25 | 26 | 27 | /** 28 | * @brief Function implementing the getTasksNum thread. 29 | * @param argument: Not used 30 | * @retval None 31 | */ 32 | void StartGetTasksNum(void *argument); 33 | 34 | 35 | /** 36 | * @brief Function implementing the timeTagTask thread. 37 | * @param argument: Not used 38 | * @retval None 39 | */ 40 | void StartTimeTagTask(void *argument); 41 | 42 | #endif /* INC_TASK_CONTROL_H_ */ 43 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2024 UMSATS 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, 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, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /cdh-tsat-stm32project-board/Core/Inc/telemetry.h: -------------------------------------------------------------------------------- 1 | /* 2 | * FILENAME: telemetry.h 3 | * 4 | * DESCRIPTION: Telemetry data application code header file. 5 | * 6 | * AUTHORS: 7 | * - Daigh Burgess (daigh.burgess@umsats.ca) 8 | * 9 | * CREATED ON: Nov. 5, 2023 10 | */ 11 | 12 | #ifndef INC_TELEMETRY_H_ 13 | #define INC_TELEMETRY_H_ 14 | //############################################################################################### 15 | // Include Directives 16 | //############################################################################################### 17 | #include 18 | #include "stm32l4xx_hal.h" 19 | 20 | //############################################################################################### 21 | // Structs 22 | //############################################################################################### 23 | typedef struct{ 24 | uint8_t id; // Telemetry data id 25 | uint8_t sequence_number; // Sequence number 26 | uint8_t timestamp[5]; // Bytes 4->0: Month, Day, Hours, Minutes, Seconds 27 | uint8_t data[6]; // Telemetry data 28 | } TelemetryMessage_t; 29 | 30 | #endif /* INC_TELEMETRY_H_ */ 31 | -------------------------------------------------------------------------------- /cdh-tsat-stm32project-board/App/Inc/command_handling.h: -------------------------------------------------------------------------------- 1 | /* 2 | * command_handling.h 3 | * 4 | * Created on: Feb 15, 2025 5 | * Author: drive 6 | */ 7 | 8 | #ifndef INC_COMMAND_HANDLING_H_ 9 | #define INC_COMMAND_HANDLING_H_ 10 | 11 | #include "tuk/tuk.h" 12 | 13 | #include "stm32l4xx_hal.h" 14 | #include "cmsis_os.h" 15 | 16 | extern osMessageQueueId_t canQueueHandle; 17 | extern osThreadId_t stm32ResetHandle; 18 | extern osThreadId_t flashUnitTestHandle; 19 | extern osThreadId_t mramUnitTestHandle; 20 | extern osThreadId_t deployAHandle; 21 | extern osThreadId_t deployBHandle; 22 | extern osThreadId_t getTasksNumHandle; 23 | extern osThreadId_t timeTagTaskInitQueueHandle; 24 | extern osThreadId_t setRTCQueueHandle; 25 | extern osThreadId_t getRTCHandle; 26 | 27 | /** 28 | * Handles incoming messages from the CAN bus. Called by CAN Wrapper Module. 29 | * 30 | * @param hcan Handle for the source CAN peripheral. 31 | * @param msg The received message. 32 | */ 33 | void On_CAN_Message_Ready(const CAN_HandleTypeDef *hcan, const CANMessage *msg); 34 | 35 | void On_CAN_Error(const CANWrapper_ErrorInfo *error); 36 | 37 | #endif /* INC_COMMAND_HANDLING_H_ */ 38 | -------------------------------------------------------------------------------- /cdh-tsat-stm32project-board/Drivers/Hardware_Peripherals/Src/MAX6822_driver.c: -------------------------------------------------------------------------------- 1 | /* 2 | * FILENAME: MAX6822_driver.c 3 | * 4 | * DESCRIPTION: STM32L4 driver source file for the MAX6822RUK+T watchdog / voltage supervisor. 5 | * 6 | * AUTHORS: 7 | * - Daigh Burgess (daigh.burgess@umsats.ca) 8 | * 9 | * CREATED ON: Mar. 18, 2023 10 | */ 11 | 12 | //############################################################################################### 13 | //Include Directives 14 | //############################################################################################### 15 | #include "stm32l4xx_hal.h" 16 | #include "MAX6822_driver.h" 17 | 18 | //############################################################################################### 19 | //Public Driver Functions 20 | //############################################################################################### 21 | void MAX6822_Init() 22 | { 23 | HAL_GPIO_WritePin(M_nReset_GPIO, M_nReset_PIN, GPIO_PIN_SET); 24 | } 25 | 26 | void MAX6822_Manual_Reset() 27 | { 28 | HAL_GPIO_WritePin(M_nReset_GPIO, M_nReset_PIN, GPIO_PIN_RESET); 29 | } 30 | 31 | void MAX6822_WDI_Toggle() 32 | { 33 | HAL_GPIO_TogglePin(WDI_GPIO, WDI_PIN); 34 | } 35 | -------------------------------------------------------------------------------- /cdh-tsat-stm32project-nucleo/Drivers/Hardware_Peripherals/Src/MAX6822_driver.c: -------------------------------------------------------------------------------- 1 | /* 2 | * FILENAME: MAX6822_driver.c 3 | * 4 | * DESCRIPTION: STM32L4 driver source file for the MAX6822RUK+T watchdog / voltage supervisor. 5 | * 6 | * AUTHORS: 7 | * - Daigh Burgess (daigh.burgess@umsats.ca) 8 | * 9 | * CREATED ON: Mar. 18, 2023 10 | */ 11 | 12 | //############################################################################################### 13 | //Include Directives 14 | //############################################################################################### 15 | #include "stm32l4xx_hal.h" 16 | #include "MAX6822_driver.h" 17 | 18 | //############################################################################################### 19 | //Public Driver Functions 20 | //############################################################################################### 21 | void MAX6822_Init() 22 | { 23 | HAL_GPIO_WritePin(M_nReset_GPIO, M_nReset_PIN, GPIO_PIN_SET); 24 | } 25 | 26 | void MAX6822_Manual_Reset() 27 | { 28 | HAL_GPIO_WritePin(M_nReset_GPIO, M_nReset_PIN, GPIO_PIN_RESET); 29 | } 30 | 31 | void MAX6822_WDI_Toggle() 32 | { 33 | HAL_GPIO_TogglePin(WDI_GPIO, WDI_PIN); 34 | } 35 | -------------------------------------------------------------------------------- /cdh-tsat-stm32project-board/Middlewares/Third_Party/FreeRTOS/Source/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | Permission is hereby granted, free of charge, to any person obtaining a copy of 3 | this software and associated documentation files (the "Software"), to deal in 4 | the Software without restriction, including without limitation the rights to 5 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 6 | the Software, and to permit persons to whom the Software is furnished to do so, 7 | subject to the following conditions: 8 | 9 | The above copyright notice and this permission notice shall be included in all 10 | copies or substantial portions of the Software. 11 | 12 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 13 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 14 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 15 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 16 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 17 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 18 | 19 | -------------------------------------------------------------------------------- /cdh-tsat-stm32project-nucleo/Middlewares/Third_Party/FreeRTOS/Source/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | Permission is hereby granted, free of charge, to any person obtaining a copy of 3 | this software and associated documentation files (the "Software"), to deal in 4 | the Software without restriction, including without limitation the rights to 5 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 6 | the Software, and to permit persons to whom the Software is furnished to do so, 7 | subject to the following conditions: 8 | 9 | The above copyright notice and this permission notice shall be included in all 10 | copies or substantial portions of the Software. 11 | 12 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 13 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 14 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 15 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 16 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 17 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 18 | 19 | -------------------------------------------------------------------------------- /cdh-tsat-stm32project-board/App/Src/command_handling.c: -------------------------------------------------------------------------------- 1 | /* 2 | * command_handling.c 3 | */ 4 | 5 | #include "command_handling.h" 6 | #include "tuk/tuk.h" 7 | 8 | void On_CAN_Message_Ready(const CAN_HandleTypeDef *hcan, const CANMessage *msg) 9 | { 10 | // TODO: These command ID's are OLD and must be updated. Refer to command reference. 11 | switch (msg->cmd) 12 | { 13 | case 0x40: 14 | osThreadFlagsSet(stm32ResetHandle, 0x0001); 15 | break; 16 | case 0x41: 17 | osThreadFlagsSet(flashUnitTestHandle, 0x0001); 18 | break; 19 | case 0x42: 20 | osThreadFlagsSet(mramUnitTestHandle, 0x0001); 21 | break; 22 | case 0x43: 23 | osThreadFlagsSet(deployAHandle, 0x0001); 24 | break; 25 | case 0x44: 26 | osThreadFlagsSet(deployBHandle, 0x0001); 27 | break; 28 | case 0x47: 29 | osThreadFlagsSet(getTasksNumHandle, 0x0001); 30 | break; 31 | case 0x48: 32 | osMessageQueuePut(timeTagTaskInitQueueHandle, msg, 0, 0); 33 | break; 34 | case 0x49: 35 | osMessageQueuePut(setRTCQueueHandle, msg, 0, 0); 36 | break; 37 | case 0x4A: 38 | osThreadFlagsSet(getRTCHandle, 0x0001); 39 | break; 40 | default: 41 | break; 42 | } 43 | } 44 | 45 | void On_CAN_Error(const CANWrapper_ErrorInfo *error) 46 | { 47 | // TODO: Handle CAN errors. 48 | } 49 | 50 | -------------------------------------------------------------------------------- /cdh-tsat-stm32project-board/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | cdh-tsat-stm32project-board 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 | com.st.stm32cube.ide.mcu.MCUCubeProjectNature 24 | org.eclipse.cdt.core.cnature 25 | com.st.stm32cube.ide.mcu.MCUCubeIdeServicesRevAev2ProjectNature 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 | -------------------------------------------------------------------------------- /cdh-tsat-stm32project-nucleo/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | cdh-tsat-stm32project-nucleo 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 | com.st.stm32cube.ide.mcu.MCUCubeProjectNature 24 | org.eclipse.cdt.core.cnature 25 | com.st.stm32cube.ide.mcu.MCUCubeIdeServicesRevAev2ProjectNature 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 | -------------------------------------------------------------------------------- /cdh-tsat-stm32project-board/Drivers/Hardware_Peripherals/Src/LTC1154_driver.c: -------------------------------------------------------------------------------- 1 | /* 2 | * FILENAME: LTC1154_driver.c 3 | * 4 | * DESCRIPTION: STM32L4 driver source file for the LTC1154 high side micropower MOSFET driver. 5 | * 6 | * AUTHORS: 7 | * - Daigh Burgess (daigh.burgess@umsats.ca) 8 | * 9 | * CREATED ON: Apr. 2, 2023 10 | */ 11 | 12 | //############################################################################################### 13 | //Include Directives 14 | //############################################################################################### 15 | #include "stm32l4xx_hal.h" 16 | #include "LTC1154_driver.h" 17 | 18 | //############################################################################################### 19 | //Public Driver Functions 20 | //############################################################################################### 21 | void LTC1154_Init() 22 | { 23 | HAL_GPIO_WritePin(LTC1154_IN_GPIO, LTC1154_IN_PIN, GPIO_PIN_RESET); 24 | HAL_GPIO_WritePin(LTC1154_nEN_GPIO, LTC1154_nEN_PIN, GPIO_PIN_SET); 25 | } 26 | 27 | void LTC1154_On() 28 | { 29 | HAL_GPIO_WritePin(LTC1154_IN_GPIO, LTC1154_IN_PIN, GPIO_PIN_SET); 30 | } 31 | 32 | void LTC1154_Off() 33 | { 34 | HAL_GPIO_WritePin(LTC1154_IN_GPIO, LTC1154_IN_PIN, GPIO_PIN_RESET); 35 | } 36 | 37 | void LTC1154_Enable() 38 | { 39 | HAL_GPIO_WritePin(LTC1154_nEN_GPIO, LTC1154_nEN_PIN, GPIO_PIN_RESET); 40 | } 41 | 42 | void LTC1154_Disable() 43 | { 44 | HAL_GPIO_WritePin(LTC1154_nEN_GPIO, LTC1154_nEN_PIN, GPIO_PIN_SET); 45 | } 46 | -------------------------------------------------------------------------------- /cdh-tsat-stm32project-nucleo/Drivers/Hardware_Peripherals/Src/LTC1154_driver.c: -------------------------------------------------------------------------------- 1 | /* 2 | * FILENAME: LTC1154_driver.c 3 | * 4 | * DESCRIPTION: STM32L4 driver source file for the LTC1154 high side micropower MOSFET driver. 5 | * 6 | * AUTHORS: 7 | * - Daigh Burgess (daigh.burgess@umsats.ca) 8 | * 9 | * CREATED ON: Apr. 2, 2023 10 | */ 11 | 12 | //############################################################################################### 13 | //Include Directives 14 | //############################################################################################### 15 | #include "stm32l4xx_hal.h" 16 | #include "LTC1154_driver.h" 17 | 18 | //############################################################################################### 19 | //Public Driver Functions 20 | //############################################################################################### 21 | void LTC1154_Init() 22 | { 23 | HAL_GPIO_WritePin(LTC1154_IN_GPIO, LTC1154_IN_PIN, GPIO_PIN_RESET); 24 | HAL_GPIO_WritePin(LTC1154_nEN_GPIO, LTC1154_nEN_PIN, GPIO_PIN_SET); 25 | } 26 | 27 | void LTC1154_On() 28 | { 29 | HAL_GPIO_WritePin(LTC1154_IN_GPIO, LTC1154_IN_PIN, GPIO_PIN_SET); 30 | } 31 | 32 | void LTC1154_Off() 33 | { 34 | HAL_GPIO_WritePin(LTC1154_IN_GPIO, LTC1154_IN_PIN, GPIO_PIN_RESET); 35 | } 36 | 37 | void LTC1154_Enable() 38 | { 39 | HAL_GPIO_WritePin(LTC1154_nEN_GPIO, LTC1154_nEN_PIN, GPIO_PIN_RESET); 40 | } 41 | 42 | void LTC1154_Disable() 43 | { 44 | HAL_GPIO_WritePin(LTC1154_nEN_GPIO, LTC1154_nEN_PIN, GPIO_PIN_SET); 45 | } 46 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # cdh-tsat6 2 | Contains software for the TSAT6 (2020-2023) Command and Data Handling (CDH) board, which uses an STM32 microcontroller. 3 | 4 | ## Project Directories 5 | **cdh-tsat6-stm32project-nucleo** : STM32 Project used to test code on the Nucleo development board 6 | 7 | **cdh-tsat6-stm32project-boardV1** : STM32 Project for the first version of the CDH custom PCB 8 | 9 | ## Software Development Process 10 | -1. Write your code within the Nucleo development board project (**cdh-tsat6-stm32project-nucleo**). 11 | 12 | -2. Test your code using the Nucleo development board. If you can not test the code using only the Nucleo development board and require the CDH custom PCB, just ensure the code builds with no errors. For example, this may be the case if you need to test a driver file for a peripheral not on the Nucleo development board. 13 | 14 | -3. Once your code works as expected, copy and paste the files you have written, or any changes you have made into the CDH custom PCB project (**cdh-tsat6-stm32project-boardV1**). You generally won't need to modify the main code since both projects use an L4-series STM32 microcontroller. However, you may need to modify some configuration values. For example, you may need to change the CAN baud rate configuration value if the baud rate used on the Nucleo development board is different than the baud rate used on the CDH custom PCB. Furthermore, you will likely need to change the pin configurations, since the pins are configured differently for each project. 15 | 16 | -4. Submit a pull request. 17 | 18 | -5. We will test your new code at an in-person worksession using the CDH custom PCB. 19 | 20 | ## About UMSATS 21 | UMSATS is a student driven group that works to build 3U nanosatellites to compete in the Canadian Satellite Design Challenge (CSDC). 22 | 23 | Our website can be found here: http://www.umsats.ca/ 24 | -------------------------------------------------------------------------------- /cdh-tsat-stm32project-board/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 | -------------------------------------------------------------------------------- /cdh-tsat-stm32project-nucleo/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 | -------------------------------------------------------------------------------- /cdh-tsat-stm32project-board/Drivers/Hardware_Peripherals/Src/LEDs_driver.c: -------------------------------------------------------------------------------- 1 | /* 2 | * FILENAME: LEDs_driver.c 3 | * 4 | * DESCRIPTION: STM32L4 driver source file for the 3 LEDs. 5 | * 6 | * AUTHORS: 7 | * - Daigh Burgess (daigh.burgess@umsats.ca) 8 | * 9 | * CREATED ON: Mar. 18, 2023 10 | */ 11 | 12 | //############################################################################################### 13 | //Include Directives 14 | //############################################################################################### 15 | #include "stm32l4xx_hal.h" 16 | #include "LEDs_driver.h" 17 | 18 | //############################################################################################### 19 | //Public Driver Functions 20 | //############################################################################################### 21 | void LEDs_Init() 22 | { 23 | HAL_GPIO_WritePin(LED1_GPIO, LED1_PIN, GPIO_PIN_RESET); 24 | HAL_GPIO_WritePin(LED2_GPIO, LED2_PIN, GPIO_PIN_RESET); 25 | HAL_GPIO_WritePin(LED3_GPIO, LED3_PIN, GPIO_PIN_RESET); 26 | } 27 | 28 | void LED1_On() 29 | { 30 | HAL_GPIO_WritePin(LED1_GPIO, LED1_PIN, GPIO_PIN_SET); 31 | } 32 | 33 | void LED2_On() 34 | { 35 | HAL_GPIO_WritePin(LED2_GPIO, LED2_PIN, GPIO_PIN_SET); 36 | } 37 | 38 | void LED3_On() 39 | { 40 | HAL_GPIO_WritePin(LED3_GPIO, LED3_PIN, GPIO_PIN_SET); 41 | } 42 | 43 | void LED1_Off() 44 | { 45 | HAL_GPIO_WritePin(LED1_GPIO, LED1_PIN, GPIO_PIN_RESET); 46 | } 47 | 48 | void LED2_Off() 49 | { 50 | HAL_GPIO_WritePin(LED2_GPIO, LED2_PIN, GPIO_PIN_RESET); 51 | } 52 | 53 | void LED3_Off() 54 | { 55 | HAL_GPIO_WritePin(LED3_GPIO, LED3_PIN, GPIO_PIN_RESET); 56 | } 57 | 58 | void LED1_Toggle() 59 | { 60 | HAL_GPIO_TogglePin(LED1_GPIO, LED1_PIN); 61 | } 62 | 63 | void LED2_Toggle() 64 | { 65 | HAL_GPIO_TogglePin(LED2_GPIO, LED2_PIN); 66 | } 67 | 68 | void LED3_Toggle() 69 | { 70 | HAL_GPIO_TogglePin(LED3_GPIO, LED3_PIN); 71 | } 72 | -------------------------------------------------------------------------------- /cdh-tsat-stm32project-nucleo/Drivers/Hardware_Peripherals/Src/LEDs_driver.c: -------------------------------------------------------------------------------- 1 | /* 2 | * FILENAME: LEDs_driver.c 3 | * 4 | * DESCRIPTION: STM32L4 driver source file for the 3 LEDs. 5 | * 6 | * AUTHORS: 7 | * - Daigh Burgess (daigh.burgess@umsats.ca) 8 | * 9 | * CREATED ON: Mar. 18, 2023 10 | */ 11 | 12 | //############################################################################################### 13 | //Include Directives 14 | //############################################################################################### 15 | #include "stm32l4xx_hal.h" 16 | #include "LEDs_driver.h" 17 | 18 | //############################################################################################### 19 | //Public Driver Functions 20 | //############################################################################################### 21 | void LEDs_Init() 22 | { 23 | HAL_GPIO_WritePin(LED1_GPIO, LED1_PIN, GPIO_PIN_RESET); 24 | HAL_GPIO_WritePin(LED2_GPIO, LED2_PIN, GPIO_PIN_RESET); 25 | HAL_GPIO_WritePin(LED3_GPIO, LED3_PIN, GPIO_PIN_RESET); 26 | } 27 | 28 | void LED1_On() 29 | { 30 | HAL_GPIO_WritePin(LED1_GPIO, LED1_PIN, GPIO_PIN_SET); 31 | } 32 | 33 | void LED2_On() 34 | { 35 | HAL_GPIO_WritePin(LED2_GPIO, LED2_PIN, GPIO_PIN_SET); 36 | } 37 | 38 | void LED3_On() 39 | { 40 | HAL_GPIO_WritePin(LED3_GPIO, LED3_PIN, GPIO_PIN_SET); 41 | } 42 | 43 | void LED1_Off() 44 | { 45 | HAL_GPIO_WritePin(LED1_GPIO, LED1_PIN, GPIO_PIN_RESET); 46 | } 47 | 48 | void LED2_Off() 49 | { 50 | HAL_GPIO_WritePin(LED2_GPIO, LED2_PIN, GPIO_PIN_RESET); 51 | } 52 | 53 | void LED3_Off() 54 | { 55 | HAL_GPIO_WritePin(LED3_GPIO, LED3_PIN, GPIO_PIN_RESET); 56 | } 57 | 58 | void LED1_Toggle() 59 | { 60 | HAL_GPIO_TogglePin(LED1_GPIO, LED1_PIN); 61 | } 62 | 63 | void LED2_Toggle() 64 | { 65 | HAL_GPIO_TogglePin(LED2_GPIO, LED2_PIN); 66 | } 67 | 68 | void LED3_Toggle() 69 | { 70 | HAL_GPIO_TogglePin(LED3_GPIO, LED3_PIN); 71 | } 72 | -------------------------------------------------------------------------------- /cdh-tsat-stm32project-board/App/Src/rtc.c: -------------------------------------------------------------------------------- 1 | /* 2 | * rtc.c 3 | */ 4 | #include "rtc.h" 5 | 6 | #include "tuk/tuk.h" 7 | 8 | void StartSetRTC(void *argument) 9 | { 10 | CANMessage msg; 11 | 12 | /* Infinite loop */ 13 | for(;;) 14 | { 15 | //block until thread resumed from command handler 16 | osMessageQueueGet(setRTCQueueHandle, &msg, NULL, osWaitForever); 17 | 18 | HAL_StatusTypeDef operation_status; 19 | uint32_t unix_timestamp = four_byte_array_to_uint32(msg.body); 20 | RTC_TimeTypeDef rtc_time = unix_timestamp_to_rtc_time(unix_timestamp); 21 | RTC_DateTypeDef rtc_date = unix_timestamp_to_rtc_date(unix_timestamp); 22 | 23 | operation_status = HAL_RTC_SetTime(&hrtc, &rtc_time, RTC_FORMAT_BIN); 24 | if (operation_status != HAL_OK) goto error; 25 | operation_status = HAL_RTC_SetDate(&hrtc, &rtc_date, RTC_FORMAT_BIN); 26 | 27 | error: 28 | if (operation_status != HAL_OK) 29 | { 30 | //TODO: Implement error handling for StartSetRTC 31 | } 32 | } 33 | osThreadExit(); 34 | } 35 | 36 | 37 | void StartGetRTC(void *argument) 38 | { 39 | /* Infinite loop */ 40 | for(;;) 41 | { 42 | //block until thread resumed from command handler 43 | osThreadFlagsWait(0x0001, osFlagsWaitAny, osWaitForever); 44 | 45 | HAL_StatusTypeDef operation_status; 46 | RTC_TimeTypeDef rtc_time; 47 | RTC_DateTypeDef rtc_date; 48 | uint32_t unix_timestamp; 49 | uint8_t response_data[6] = {0,0,0,0,0,0}; 50 | 51 | operation_status = HAL_RTC_GetTime(&hrtc, &rtc_time, RTC_FORMAT_BIN); 52 | if (operation_status != HAL_OK) goto error; 53 | operation_status = HAL_RTC_GetDate(&hrtc, &rtc_date, RTC_FORMAT_BIN); 54 | if (operation_status != HAL_OK) goto error; 55 | 56 | unix_timestamp = rtc_to_unix_timestamp(rtc_time, rtc_date); 57 | uint32_to_four_byte_array(unix_timestamp, response_data); 58 | 59 | //TODO: Add CAN message transmit 60 | 61 | error: 62 | if (operation_status != HAL_OK) 63 | { 64 | //TODO: Implement error handling for StartGetRTC 65 | } 66 | } 67 | osThreadExit(); 68 | } 69 | -------------------------------------------------------------------------------- /cdh-tsat-stm32project-board/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) 2024 STMicroelectronics. 10 | * All rights reserved. 11 | * 12 | * This software is licensed under terms that can be found in the LICENSE file 13 | * in the root directory of this software component. 14 | * If no LICENSE file comes with this software, it is provided AS-IS. 15 | * 16 | ****************************************************************************** 17 | */ 18 | /* USER CODE END Header */ 19 | 20 | /* Includes ------------------------------------------------------------------*/ 21 | #include "FreeRTOS.h" 22 | #include "task.h" 23 | #include "main.h" 24 | 25 | /* Private includes ----------------------------------------------------------*/ 26 | /* USER CODE BEGIN Includes */ 27 | 28 | /* USER CODE END Includes */ 29 | 30 | /* Private typedef -----------------------------------------------------------*/ 31 | /* USER CODE BEGIN PTD */ 32 | 33 | /* USER CODE END PTD */ 34 | 35 | /* Private define ------------------------------------------------------------*/ 36 | /* USER CODE BEGIN PD */ 37 | 38 | /* USER CODE END PD */ 39 | 40 | /* Private macro -------------------------------------------------------------*/ 41 | /* USER CODE BEGIN PM */ 42 | 43 | /* USER CODE END PM */ 44 | 45 | /* Private variables ---------------------------------------------------------*/ 46 | /* USER CODE BEGIN Variables */ 47 | 48 | /* USER CODE END Variables */ 49 | 50 | /* Private function prototypes -----------------------------------------------*/ 51 | /* USER CODE BEGIN FunctionPrototypes */ 52 | 53 | /* USER CODE END FunctionPrototypes */ 54 | 55 | /* Private application code --------------------------------------------------*/ 56 | /* USER CODE BEGIN Application */ 57 | 58 | /* USER CODE END Application */ 59 | 60 | -------------------------------------------------------------------------------- /cdh-tsat-stm32project-nucleo/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) 2025 STMicroelectronics. 10 | * All rights reserved. 11 | * 12 | * This software is licensed under terms that can be found in the LICENSE file 13 | * in the root directory of this software component. 14 | * If no LICENSE file comes with this software, it is provided AS-IS. 15 | * 16 | ****************************************************************************** 17 | */ 18 | /* USER CODE END Header */ 19 | 20 | /* Includes ------------------------------------------------------------------*/ 21 | #include "FreeRTOS.h" 22 | #include "task.h" 23 | #include "main.h" 24 | 25 | /* Private includes ----------------------------------------------------------*/ 26 | /* USER CODE BEGIN Includes */ 27 | 28 | /* USER CODE END Includes */ 29 | 30 | /* Private typedef -----------------------------------------------------------*/ 31 | /* USER CODE BEGIN PTD */ 32 | 33 | /* USER CODE END PTD */ 34 | 35 | /* Private define ------------------------------------------------------------*/ 36 | /* USER CODE BEGIN PD */ 37 | 38 | /* USER CODE END PD */ 39 | 40 | /* Private macro -------------------------------------------------------------*/ 41 | /* USER CODE BEGIN PM */ 42 | 43 | /* USER CODE END PM */ 44 | 45 | /* Private variables ---------------------------------------------------------*/ 46 | /* USER CODE BEGIN Variables */ 47 | 48 | /* USER CODE END Variables */ 49 | 50 | /* Private function prototypes -----------------------------------------------*/ 51 | /* USER CODE BEGIN FunctionPrototypes */ 52 | 53 | /* USER CODE END FunctionPrototypes */ 54 | 55 | /* Private application code --------------------------------------------------*/ 56 | /* USER CODE BEGIN Application */ 57 | 58 | /* USER CODE END Application */ 59 | 60 | -------------------------------------------------------------------------------- /cdh-tsat-stm32project-board/Core/Inc/stm32l4xx_it.h: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file stm32l4xx_it.h 5 | * @brief This file contains the headers of the interrupt handlers. 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | * Copyright (c) 2024 STMicroelectronics. 10 | * All rights reserved. 11 | * 12 | * This software is licensed under terms that can be found in the LICENSE file 13 | * in the root directory of this software component. 14 | * If no LICENSE file comes with this software, it is provided AS-IS. 15 | * 16 | ****************************************************************************** 17 | */ 18 | /* USER CODE END Header */ 19 | 20 | /* Define to prevent recursive inclusion -------------------------------------*/ 21 | #ifndef __STM32L4xx_IT_H 22 | #define __STM32L4xx_IT_H 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | /* Private includes ----------------------------------------------------------*/ 29 | /* USER CODE BEGIN Includes */ 30 | 31 | /* USER CODE END Includes */ 32 | 33 | /* Exported types ------------------------------------------------------------*/ 34 | /* USER CODE BEGIN ET */ 35 | 36 | /* USER CODE END ET */ 37 | 38 | /* Exported constants --------------------------------------------------------*/ 39 | /* USER CODE BEGIN EC */ 40 | 41 | /* USER CODE END EC */ 42 | 43 | /* Exported macro ------------------------------------------------------------*/ 44 | /* USER CODE BEGIN EM */ 45 | 46 | /* USER CODE END EM */ 47 | 48 | /* Exported functions prototypes ---------------------------------------------*/ 49 | void NMI_Handler(void); 50 | void HardFault_Handler(void); 51 | void MemManage_Handler(void); 52 | void BusFault_Handler(void); 53 | void UsageFault_Handler(void); 54 | void DebugMon_Handler(void); 55 | void CAN1_RX0_IRQHandler(void); 56 | void RTC_Alarm_IRQHandler(void); 57 | void TIM6_DAC_IRQHandler(void); 58 | /* USER CODE BEGIN EFP */ 59 | 60 | /* USER CODE END EFP */ 61 | 62 | #ifdef __cplusplus 63 | } 64 | #endif 65 | 66 | #endif /* __STM32L4xx_IT_H */ 67 | -------------------------------------------------------------------------------- /cdh-tsat-stm32project-board/Drivers/Hardware_Peripherals/Inc/LTC1154_driver.h: -------------------------------------------------------------------------------- 1 | /* 2 | * FILENAME: LTC1154_driver.h 3 | * 4 | * DESCRIPTION: STM32L4 driver header file for the LTC1154 high side micropower MOSFET driver. 5 | * 6 | * AUTHORS: 7 | * - Daigh Burgess (daigh.burgess@umsats.ca) 8 | * 9 | * CREATED ON: Apr. 2, 2023 10 | */ 11 | 12 | #ifndef HARDWARE_PERIPHERALS_INC_LTC1154_DRIVER_H_ 13 | #define HARDWARE_PERIPHERALS_INC_LTC1154_DRIVER_H_ 14 | //############################################################################################### 15 | //Include Directives 16 | //############################################################################################### 17 | #include "stm32l4xx_hal.h" 18 | 19 | //############################################################################################### 20 | //Public Define Directives 21 | //############################################################################################### 22 | #define LTC1154_IN_GPIO GPIOA 23 | #define LTC1154_IN_PIN GPIO_PIN_2 24 | 25 | #define LTC1154_nEN_GPIO GPIOA 26 | #define LTC1154_nEN_PIN GPIO_PIN_1 27 | 28 | //############################################################################################### 29 | //Public Driver Function Prototypes 30 | //############################################################################################### 31 | /* 32 | * FUNCTION: LTC1154_Init 33 | * 34 | * DESCRIPTION: Turn off & disable the LTC1154 operation. 35 | */ 36 | void LTC1154_Init(); 37 | 38 | /* 39 | * FUNCTION: LTC1154_On 40 | * 41 | * DESCRIPTION: Turn the LTC1154 on. 42 | * 43 | * NOTES: 44 | * - This function will only activate the LTC1154 operation when the device is enabled. 45 | */ 46 | void LTC1154_On(); 47 | 48 | /* 49 | * FUNCTION: LTC1154_Off 50 | * 51 | * DESCRIPTION: Turn the LTC1154 off. 52 | */ 53 | void LTC1154_Off(); 54 | 55 | /* 56 | * FUNCTION: LTC1154_Enable 57 | * 58 | * DESCRIPTION: Enable the LTC1154 operations. 59 | */ 60 | void LTC1154_Enable(); 61 | 62 | /* 63 | * FUNCTION: LTC1154_Disable 64 | * 65 | * DESCRIPTION: Disable the LTC1154 operations. 66 | */ 67 | void LTC1154_Disable(); 68 | 69 | 70 | #endif /* HARDWARE_PERIPHERALS_INC_LTC1154_DRIVER_H_ */ 71 | -------------------------------------------------------------------------------- /cdh-tsat-stm32project-nucleo/Drivers/Hardware_Peripherals/Inc/LTC1154_driver.h: -------------------------------------------------------------------------------- 1 | /* 2 | * FILENAME: LTC1154_driver.h 3 | * 4 | * DESCRIPTION: STM32L4 driver header file for the LTC1154 high side micropower MOSFET driver. 5 | * 6 | * AUTHORS: 7 | * - Daigh Burgess (daigh.burgess@umsats.ca) 8 | * 9 | * CREATED ON: Apr. 2, 2023 10 | */ 11 | 12 | #ifndef HARDWARE_PERIPHERALS_INC_LTC1154_DRIVER_H_ 13 | #define HARDWARE_PERIPHERALS_INC_LTC1154_DRIVER_H_ 14 | //############################################################################################### 15 | //Include Directives 16 | //############################################################################################### 17 | #include "stm32l4xx_hal.h" 18 | 19 | //############################################################################################### 20 | //Public Define Directives 21 | //############################################################################################### 22 | #define LTC1154_IN_GPIO GPIOC 23 | #define LTC1154_IN_PIN GPIO_PIN_5 24 | 25 | #define LTC1154_nEN_GPIO GPIOB 26 | #define LTC1154_nEN_PIN GPIO_PIN_0 27 | 28 | //############################################################################################### 29 | //Public Driver Function Prototypes 30 | //############################################################################################### 31 | /* 32 | * FUNCTION: LTC1154_Init 33 | * 34 | * DESCRIPTION: Turn off & disable the LTC1154 operation. 35 | */ 36 | void LTC1154_Init(); 37 | 38 | /* 39 | * FUNCTION: LTC1154_On 40 | * 41 | * DESCRIPTION: Turn the LTC1154 on. 42 | * 43 | * NOTES: 44 | * - This function will only activate the LTC1154 operation when the device is enabled. 45 | */ 46 | void LTC1154_On(); 47 | 48 | /* 49 | * FUNCTION: LTC1154_Off 50 | * 51 | * DESCRIPTION: Turn the LTC1154 off. 52 | */ 53 | void LTC1154_Off(); 54 | 55 | /* 56 | * FUNCTION: LTC1154_Enable 57 | * 58 | * DESCRIPTION: Enable the LTC1154 operations. 59 | */ 60 | void LTC1154_Enable(); 61 | 62 | /* 63 | * FUNCTION: LTC1154_Disable 64 | * 65 | * DESCRIPTION: Disable the LTC1154 operations. 66 | */ 67 | void LTC1154_Disable(); 68 | 69 | 70 | #endif /* HARDWARE_PERIPHERALS_INC_LTC1154_DRIVER_H_ */ 71 | -------------------------------------------------------------------------------- /cdh-tsat-stm32project-nucleo/Core/Inc/stm32l4xx_it.h: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file stm32l4xx_it.h 5 | * @brief This file contains the headers of the interrupt handlers. 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | * Copyright (c) 2024 STMicroelectronics. 10 | * All rights reserved. 11 | * 12 | * This software is licensed under terms that can be found in the LICENSE file 13 | * in the root directory of this software component. 14 | * If no LICENSE file comes with this software, it is provided AS-IS. 15 | * 16 | ****************************************************************************** 17 | */ 18 | /* USER CODE END Header */ 19 | 20 | /* Define to prevent recursive inclusion -------------------------------------*/ 21 | #ifndef __STM32L4xx_IT_H 22 | #define __STM32L4xx_IT_H 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | /* Private includes ----------------------------------------------------------*/ 29 | /* USER CODE BEGIN Includes */ 30 | 31 | /* USER CODE END Includes */ 32 | 33 | /* Exported types ------------------------------------------------------------*/ 34 | /* USER CODE BEGIN ET */ 35 | 36 | /* USER CODE END ET */ 37 | 38 | /* Exported constants --------------------------------------------------------*/ 39 | /* USER CODE BEGIN EC */ 40 | 41 | /* USER CODE END EC */ 42 | 43 | /* Exported macro ------------------------------------------------------------*/ 44 | /* USER CODE BEGIN EM */ 45 | 46 | /* USER CODE END EM */ 47 | 48 | /* Exported functions prototypes ---------------------------------------------*/ 49 | void NMI_Handler(void); 50 | void HardFault_Handler(void); 51 | void MemManage_Handler(void); 52 | void BusFault_Handler(void); 53 | void UsageFault_Handler(void); 54 | void DebugMon_Handler(void); 55 | void CAN1_RX0_IRQHandler(void); 56 | void UART4_IRQHandler(void); 57 | void TIM6_DAC_IRQHandler(void); 58 | void DMA2_Channel5_IRQHandler(void); 59 | /* USER CODE BEGIN EFP */ 60 | 61 | /* USER CODE END EFP */ 62 | 63 | #ifdef __cplusplus 64 | } 65 | #endif 66 | 67 | #endif /* __STM32L4xx_IT_H */ 68 | -------------------------------------------------------------------------------- /cdh-tsat-stm32project-board/Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_hal_spi_ex.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32l4xx_hal_spi_ex.h 4 | * @author MCD Application Team 5 | * @brief Header file of SPI HAL Extended module. 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | * Copyright (c) 2017 STMicroelectronics. 10 | * All rights reserved. 11 | * 12 | * This software is licensed under terms that can be found in the LICENSE file 13 | * in the root directory of this software component. 14 | * If no LICENSE file comes with this software, it is provided AS-IS. 15 | * 16 | ****************************************************************************** 17 | */ 18 | 19 | /* Define to prevent recursive inclusion -------------------------------------*/ 20 | #ifndef STM32L4xx_HAL_SPI_EX_H 21 | #define STM32L4xx_HAL_SPI_EX_H 22 | 23 | #ifdef __cplusplus 24 | extern "C" { 25 | #endif 26 | 27 | /* Includes ------------------------------------------------------------------*/ 28 | #include "stm32l4xx_hal_def.h" 29 | 30 | /** @addtogroup STM32L4xx_HAL_Driver 31 | * @{ 32 | */ 33 | 34 | /** @addtogroup SPIEx 35 | * @{ 36 | */ 37 | 38 | /* Exported types ------------------------------------------------------------*/ 39 | /* Exported constants --------------------------------------------------------*/ 40 | /* Exported macros -----------------------------------------------------------*/ 41 | /* Exported functions --------------------------------------------------------*/ 42 | /** @addtogroup SPIEx_Exported_Functions 43 | * @{ 44 | */ 45 | 46 | /* Initialization and de-initialization functions ****************************/ 47 | /* IO operation functions *****************************************************/ 48 | /** @addtogroup SPIEx_Exported_Functions_Group1 49 | * @{ 50 | */ 51 | HAL_StatusTypeDef HAL_SPIEx_FlushRxFifo(SPI_HandleTypeDef *hspi); 52 | /** 53 | * @} 54 | */ 55 | 56 | /** 57 | * @} 58 | */ 59 | 60 | /** 61 | * @} 62 | */ 63 | 64 | /** 65 | * @} 66 | */ 67 | 68 | #ifdef __cplusplus 69 | } 70 | #endif 71 | 72 | #endif /* STM32L4xx_HAL_SPI_EX_H */ 73 | 74 | -------------------------------------------------------------------------------- /cdh-tsat-stm32project-nucleo/Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_hal_spi_ex.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32l4xx_hal_spi_ex.h 4 | * @author MCD Application Team 5 | * @brief Header file of SPI HAL Extended module. 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | * Copyright (c) 2017 STMicroelectronics. 10 | * All rights reserved. 11 | * 12 | * This software is licensed under terms that can be found in the LICENSE file 13 | * in the root directory of this software component. 14 | * If no LICENSE file comes with this software, it is provided AS-IS. 15 | * 16 | ****************************************************************************** 17 | */ 18 | 19 | /* Define to prevent recursive inclusion -------------------------------------*/ 20 | #ifndef STM32L4xx_HAL_SPI_EX_H 21 | #define STM32L4xx_HAL_SPI_EX_H 22 | 23 | #ifdef __cplusplus 24 | extern "C" { 25 | #endif 26 | 27 | /* Includes ------------------------------------------------------------------*/ 28 | #include "stm32l4xx_hal_def.h" 29 | 30 | /** @addtogroup STM32L4xx_HAL_Driver 31 | * @{ 32 | */ 33 | 34 | /** @addtogroup SPIEx 35 | * @{ 36 | */ 37 | 38 | /* Exported types ------------------------------------------------------------*/ 39 | /* Exported constants --------------------------------------------------------*/ 40 | /* Exported macros -----------------------------------------------------------*/ 41 | /* Exported functions --------------------------------------------------------*/ 42 | /** @addtogroup SPIEx_Exported_Functions 43 | * @{ 44 | */ 45 | 46 | /* Initialization and de-initialization functions ****************************/ 47 | /* IO operation functions *****************************************************/ 48 | /** @addtogroup SPIEx_Exported_Functions_Group1 49 | * @{ 50 | */ 51 | HAL_StatusTypeDef HAL_SPIEx_FlushRxFifo(SPI_HandleTypeDef *hspi); 52 | /** 53 | * @} 54 | */ 55 | 56 | /** 57 | * @} 58 | */ 59 | 60 | /** 61 | * @} 62 | */ 63 | 64 | /** 65 | * @} 66 | */ 67 | 68 | #ifdef __cplusplus 69 | } 70 | #endif 71 | 72 | #endif /* STM32L4xx_HAL_SPI_EX_H */ 73 | 74 | -------------------------------------------------------------------------------- /cdh-tsat-stm32project-board/Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_hal_flash_ramfunc.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32l4xx_hal_flash_ramfunc.h 4 | * @author MCD Application Team 5 | * @brief Header file of FLASH RAMFUNC driver. 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | * Copyright (c) 2017 STMicroelectronics. 10 | * All rights reserved. 11 | * 12 | * This software is licensed under terms that can be found in the LICENSE file in 13 | * the root directory of this software component. 14 | * If no LICENSE file comes with this software, it is provided AS-IS. 15 | ****************************************************************************** 16 | */ 17 | 18 | /* Define to prevent recursive inclusion -------------------------------------*/ 19 | #ifndef STM32L4xx_FLASH_RAMFUNC_H 20 | #define STM32L4xx_FLASH_RAMFUNC_H 21 | 22 | #ifdef __cplusplus 23 | extern "C" { 24 | #endif 25 | 26 | /* Includes ------------------------------------------------------------------*/ 27 | #include "stm32l4xx_hal_def.h" 28 | 29 | /** @addtogroup STM32L4xx_HAL_Driver 30 | * @{ 31 | */ 32 | 33 | /** @addtogroup FLASH_RAMFUNC 34 | * @{ 35 | */ 36 | 37 | /* Exported types ------------------------------------------------------------*/ 38 | /* Exported macro ------------------------------------------------------------*/ 39 | /* Exported functions --------------------------------------------------------*/ 40 | /** @addtogroup FLASH_RAMFUNC_Exported_Functions 41 | * @{ 42 | */ 43 | 44 | /** @addtogroup FLASH_RAMFUNC_Exported_Functions_Group1 45 | * @{ 46 | */ 47 | /* Peripheral Control functions ************************************************/ 48 | __RAM_FUNC HAL_StatusTypeDef HAL_FLASHEx_EnableRunPowerDown(void); 49 | __RAM_FUNC HAL_StatusTypeDef HAL_FLASHEx_DisableRunPowerDown(void); 50 | #if defined (STM32L4P5xx) || defined (STM32L4Q5xx) || defined (STM32L4R5xx) || defined (STM32L4R7xx) || defined (STM32L4R9xx) || defined (STM32L4S5xx) || defined (STM32L4S7xx) || defined (STM32L4S9xx) 51 | __RAM_FUNC HAL_StatusTypeDef HAL_FLASHEx_OB_DBankConfig(uint32_t DBankConfig); 52 | #endif 53 | /** 54 | * @} 55 | */ 56 | 57 | /** 58 | * @} 59 | */ 60 | 61 | /** 62 | * @} 63 | */ 64 | 65 | /** 66 | * @} 67 | */ 68 | 69 | #ifdef __cplusplus 70 | } 71 | #endif 72 | 73 | #endif /* STM32L4xx_FLASH_RAMFUNC_H */ 74 | 75 | -------------------------------------------------------------------------------- /cdh-tsat-stm32project-nucleo/Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_hal_flash_ramfunc.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32l4xx_hal_flash_ramfunc.h 4 | * @author MCD Application Team 5 | * @brief Header file of FLASH RAMFUNC driver. 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | * Copyright (c) 2017 STMicroelectronics. 10 | * All rights reserved. 11 | * 12 | * This software is licensed under terms that can be found in the LICENSE file in 13 | * the root directory of this software component. 14 | * If no LICENSE file comes with this software, it is provided AS-IS. 15 | ****************************************************************************** 16 | */ 17 | 18 | /* Define to prevent recursive inclusion -------------------------------------*/ 19 | #ifndef STM32L4xx_FLASH_RAMFUNC_H 20 | #define STM32L4xx_FLASH_RAMFUNC_H 21 | 22 | #ifdef __cplusplus 23 | extern "C" { 24 | #endif 25 | 26 | /* Includes ------------------------------------------------------------------*/ 27 | #include "stm32l4xx_hal_def.h" 28 | 29 | /** @addtogroup STM32L4xx_HAL_Driver 30 | * @{ 31 | */ 32 | 33 | /** @addtogroup FLASH_RAMFUNC 34 | * @{ 35 | */ 36 | 37 | /* Exported types ------------------------------------------------------------*/ 38 | /* Exported macro ------------------------------------------------------------*/ 39 | /* Exported functions --------------------------------------------------------*/ 40 | /** @addtogroup FLASH_RAMFUNC_Exported_Functions 41 | * @{ 42 | */ 43 | 44 | /** @addtogroup FLASH_RAMFUNC_Exported_Functions_Group1 45 | * @{ 46 | */ 47 | /* Peripheral Control functions ************************************************/ 48 | __RAM_FUNC HAL_StatusTypeDef HAL_FLASHEx_EnableRunPowerDown(void); 49 | __RAM_FUNC HAL_StatusTypeDef HAL_FLASHEx_DisableRunPowerDown(void); 50 | #if defined (STM32L4P5xx) || defined (STM32L4Q5xx) || defined (STM32L4R5xx) || defined (STM32L4R7xx) || defined (STM32L4R9xx) || defined (STM32L4S5xx) || defined (STM32L4S7xx) || defined (STM32L4S9xx) 51 | __RAM_FUNC HAL_StatusTypeDef HAL_FLASHEx_OB_DBankConfig(uint32_t DBankConfig); 52 | #endif 53 | /** 54 | * @} 55 | */ 56 | 57 | /** 58 | * @} 59 | */ 60 | 61 | /** 62 | * @} 63 | */ 64 | 65 | /** 66 | * @} 67 | */ 68 | 69 | #ifdef __cplusplus 70 | } 71 | #endif 72 | 73 | #endif /* STM32L4xx_FLASH_RAMFUNC_H */ 74 | 75 | -------------------------------------------------------------------------------- /cdh-tsat-stm32project-board/Drivers/Hardware_Peripherals/Inc/LEDs_driver.h: -------------------------------------------------------------------------------- 1 | /* 2 | * FILENAME: LEDs_driver.h 3 | * 4 | * DESCRIPTION: STM32L4 driver header file for the 3 LEDs. 5 | * 6 | * AUTHORS: 7 | * - Daigh Burgess (daigh.burgess@umsats.ca) 8 | * 9 | * CREATED ON: Mar. 18, 2023 10 | */ 11 | 12 | #ifndef HARDWARE_PERIPHERALS_INC_LEDS_DRIVER_H_ 13 | #define HARDWARE_PERIPHERALS_INC_LEDS_DRIVER_H_ 14 | 15 | //############################################################################################### 16 | //Include Directives 17 | //############################################################################################### 18 | #include "stm32l4xx_hal.h" 19 | 20 | //############################################################################################### 21 | //Public Define Directives 22 | //############################################################################################### 23 | #define LED1_GPIO GPIOB 24 | #define LED1_PIN GPIO_PIN_2 25 | 26 | #define LED2_GPIO GPIOB 27 | #define LED2_PIN GPIO_PIN_10 28 | 29 | #define LED3_GPIO GPIOB 30 | #define LED3_PIN GPIO_PIN_11 31 | 32 | //############################################################################################### 33 | //Public Driver Function Prototypes 34 | //############################################################################################### 35 | /* 36 | * FUNCTION: LEDs_Init 37 | * 38 | * DESCRIPTION: Turn all 3 LEDs off. 39 | */ 40 | void LEDs_Init(); 41 | 42 | /* 43 | * FUNCTION: LED1_On 44 | * 45 | * DESCRIPTION: Turn LED1 on. 46 | */ 47 | void LED1_On(); 48 | 49 | /* 50 | * FUNCTION: LED2_On 51 | * 52 | * DESCRIPTION: Turn LED2 on. 53 | */ 54 | void LED2_On(); 55 | 56 | /* 57 | * FUNCTION: LED3_On 58 | * 59 | * DESCRIPTION: Turn LED3 on. 60 | */ 61 | void LED3_On(); 62 | 63 | /* 64 | * FUNCTION: LED1_Off 65 | * 66 | * DESCRIPTION: Turn LED1 off. 67 | */ 68 | void LED1_Off(); 69 | 70 | /* 71 | * FUNCTION: LED2_Off 72 | * 73 | * DESCRIPTION: Turn LED2 off. 74 | */ 75 | void LED2_Off(); 76 | 77 | /* 78 | * FUNCTION: LED3_Off 79 | * 80 | * DESCRIPTION: Turn LED3 off. 81 | */ 82 | void LED3_Off(); 83 | 84 | /* 85 | * FUNCTION: LED1_Toggle 86 | * 87 | * DESCRIPTION: Toggle LED1. 88 | */ 89 | void LED1_Toggle(); 90 | 91 | /* 92 | * FUNCTION: LED2_Toggle 93 | * 94 | * DESCRIPTION: Toggle LED2. 95 | */ 96 | void LED2_Toggle(); 97 | 98 | /* 99 | * FUNCTION: LED3_Toggle 100 | * 101 | * DESCRIPTION: Toggle LED3. 102 | */ 103 | void LED3_Toggle(); 104 | 105 | #endif /* HARDWARE_PERIPHERALS_INC_LEDS_DRIVER_H_ */ 106 | -------------------------------------------------------------------------------- /cdh-tsat-stm32project-nucleo/Drivers/Hardware_Peripherals/Inc/LEDs_driver.h: -------------------------------------------------------------------------------- 1 | /* 2 | * FILENAME: LEDs_driver.h 3 | * 4 | * DESCRIPTION: STM32L4 driver header file for the 3 LEDs. 5 | * 6 | * AUTHORS: 7 | * - Daigh Burgess (daigh.burgess@umsats.ca) 8 | * 9 | * CREATED ON: Mar. 18, 2023 10 | */ 11 | 12 | #ifndef HARDWARE_PERIPHERALS_INC_LEDS_DRIVER_H_ 13 | #define HARDWARE_PERIPHERALS_INC_LEDS_DRIVER_H_ 14 | 15 | //############################################################################################### 16 | //Include Directives 17 | //############################################################################################### 18 | #include "stm32l4xx_hal.h" 19 | 20 | //############################################################################################### 21 | //Public Define Directives 22 | //############################################################################################### 23 | #define LED1_GPIO GPIOB 24 | #define LED1_PIN GPIO_PIN_7 25 | 26 | #define LED2_GPIO GPIOB 27 | #define LED2_PIN GPIO_PIN_6 28 | 29 | #define LED3_GPIO GPIOB 30 | #define LED3_PIN GPIO_PIN_5 31 | 32 | //############################################################################################### 33 | //Public Driver Function Prototypes 34 | //############################################################################################### 35 | /* 36 | * FUNCTION: LEDs_Init 37 | * 38 | * DESCRIPTION: Turn all 3 LEDs off. 39 | */ 40 | void LEDs_Init(); 41 | 42 | /* 43 | * FUNCTION: LED1_On 44 | * 45 | * DESCRIPTION: Turn LED1 on. 46 | */ 47 | void LED1_On(); 48 | 49 | /* 50 | * FUNCTION: LED2_On 51 | * 52 | * DESCRIPTION: Turn LED2 on. 53 | */ 54 | void LED2_On(); 55 | 56 | /* 57 | * FUNCTION: LED3_On 58 | * 59 | * DESCRIPTION: Turn LED3 on. 60 | */ 61 | void LED3_On(); 62 | 63 | /* 64 | * FUNCTION: LED1_Off 65 | * 66 | * DESCRIPTION: Turn LED1 off. 67 | */ 68 | void LED1_Off(); 69 | 70 | /* 71 | * FUNCTION: LED2_Off 72 | * 73 | * DESCRIPTION: Turn LED2 off. 74 | */ 75 | void LED2_Off(); 76 | 77 | /* 78 | * FUNCTION: LED3_Off 79 | * 80 | * DESCRIPTION: Turn LED3 off. 81 | */ 82 | void LED3_Off(); 83 | 84 | /* 85 | * FUNCTION: LED1_Toggle 86 | * 87 | * DESCRIPTION: Toggle LED1. 88 | */ 89 | void LED1_Toggle(); 90 | 91 | /* 92 | * FUNCTION: LED2_Toggle 93 | * 94 | * DESCRIPTION: Toggle LED2. 95 | */ 96 | void LED2_Toggle(); 97 | 98 | /* 99 | * FUNCTION: LED3_Toggle 100 | * 101 | * DESCRIPTION: Toggle LED3. 102 | */ 103 | void LED3_Toggle(); 104 | 105 | #endif /* HARDWARE_PERIPHERALS_INC_LEDS_DRIVER_H_ */ 106 | -------------------------------------------------------------------------------- /cdh-tsat-stm32project-board/Core/Inc/utils.h: -------------------------------------------------------------------------------- 1 | /* 2 | * FILENAME: utils.h 3 | * 4 | * DESCRIPTION: Util functions for use with CDH application code. 5 | * 6 | * AUTHORS: 7 | * - Daigh Burgess (daigh.burgess@umsats.ca) 8 | * 9 | * CREATED ON: Nov. 6, 2023 10 | */ 11 | 12 | #ifndef INC_UTILS_H_ 13 | #define INC_UTILS_H_ 14 | //############################################################################################### 15 | // Include Directives 16 | //############################################################################################### 17 | #include 18 | #include "stm32l4xx_hal.h" 19 | 20 | //############################################################################################### 21 | // Public Function Prototypes 22 | //############################################################################################### 23 | /* 24 | * FUNCTION: four_byte_array_to_uint32 25 | * 26 | * DESCRIPTION: Returns the uint32 representation of the given 4-byte array. The 4-byte array is 27 | * interpreted as element 3 being the MSB & element 0 being the LSB. 28 | * 29 | * PARAMETERS: 30 | * p_buffer: Pointer to element 0 of the 4-byte array. 31 | */ 32 | uint32_t four_byte_array_to_uint32(uint8_t *p_buffer); 33 | 34 | /* 35 | * FUNCTION: uint32_to_four_byte_array 36 | * 37 | * DESCRIPTION: Fills the given 4-byte array with the given 32-bit value. The 4-byte array is 38 | * interpreted as element 3 being the MSB & element 0 being the LSB. 39 | * 40 | * PARAMETERS: 41 | * value32: The 32-bit value. 42 | * p_buffer: Pointer to element 0 of the 4-byte array. 43 | */ 44 | void uint32_to_four_byte_array(uint32_t value32, uint8_t *p_buffer); 45 | 46 | /* 47 | * FUNCTION: rtc_to_unix_timestamp 48 | * 49 | * DESCRIPTION: Returns the Unix timestamp representation of the given RTC value. 50 | * 51 | * PARAMETERS: 52 | * rtc_time: The current RTC time value. 53 | * rtc_date: The current RTC date value. 54 | */ 55 | uint32_t rtc_to_unix_timestamp(RTC_TimeTypeDef rtc_time, RTC_DateTypeDef rtc_date); 56 | 57 | /* 58 | * FUNCTION: unix_timestamp_to_rtc_time 59 | * 60 | * DESCRIPTION: Returns the RTC time value representation of the given Unix timestamp. 61 | * 62 | * PARAMETERS: 63 | * unix_timestamp: The current Unix timestamp. 64 | */ 65 | RTC_TimeTypeDef unix_timestamp_to_rtc_time(uint32_t unix_timestamp); 66 | 67 | /* 68 | * FUNCTION: unix_timestamp_to_rtc_date 69 | * 70 | * DESCRIPTION: Returns the RTC date value representation of the given Unix timestamp. 71 | * 72 | * PARAMETERS: 73 | * unix_timestamp: The current Unix timestamp. 74 | */ 75 | RTC_DateTypeDef unix_timestamp_to_rtc_date(uint32_t unix_timestamp); 76 | 77 | #endif /* INC_UTILS_H_ */ 78 | -------------------------------------------------------------------------------- /cdh-tsat-stm32project-board/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 | -------------------------------------------------------------------------------- /cdh-tsat-stm32project-nucleo/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 | -------------------------------------------------------------------------------- /cdh-tsat-stm32project-board/Core/Src/utils.c: -------------------------------------------------------------------------------- 1 | /* 2 | * FILENAME: utils.c 3 | * 4 | * DESCRIPTION: Util functions for use with CDH application code. 5 | * 6 | * AUTHORS: 7 | * - Daigh Burgess (daigh.burgess@umsats.ca) 8 | * - Arnav Gupta (arnav.gupta@umsats.ca) 9 | * 10 | * CREATED ON: Nov. 6, 2023 11 | */ 12 | 13 | //############################################################################################### 14 | //Include Directives 15 | //############################################################################################### 16 | #include 17 | #include 18 | #include "stm32l4xx_hal.h" 19 | #include "utils.h" 20 | 21 | //############################################################################################### 22 | //Public Functions 23 | //############################################################################################### 24 | uint32_t four_byte_array_to_uint32(uint8_t *p_buffer) 25 | { 26 | return (uint32_t)((*(p_buffer) << 24) | (*(p_buffer + 1) << 16) | (*(p_buffer + 2) << 8) | *(p_buffer + 3)); 27 | } 28 | 29 | void uint32_to_four_byte_array(uint32_t value32, uint8_t *p_buffer) 30 | { 31 | *(p_buffer) = (uint8_t)(value32 >> 24); 32 | *(p_buffer + 1) = (uint8_t)(value32 >> 16); 33 | *(p_buffer + 2) = (uint8_t)(value32 >> 8); 34 | *(p_buffer + 3) = (uint8_t)(value32); 35 | } 36 | 37 | uint32_t rtc_to_unix_timestamp(RTC_TimeTypeDef rtc_time, RTC_DateTypeDef rtc_date) 38 | { 39 | struct tm date_and_time = { 40 | .tm_sec = rtc_time.Seconds 41 | ,.tm_min = rtc_time.Minutes 42 | ,.tm_hour = rtc_time.Hours 43 | 44 | ,.tm_mday = rtc_date.Date 45 | ,.tm_mon = rtc_date.Month - 1 46 | ,.tm_year = rtc_date.Year + 70 47 | 48 | ,.tm_isdst = 0 49 | }; 50 | 51 | // Resolve RTC_MONTH BCD inconsistencies 52 | if (date_and_time.tm_mon >= 10) { date_and_time.tm_mon -= 6; } 53 | 54 | return (uint32_t) mktime(&date_and_time); 55 | } 56 | 57 | RTC_TimeTypeDef unix_timestamp_to_rtc_time(uint32_t unix_timestamp) 58 | { 59 | time_t unixFormatted = (time_t)unix_timestamp; 60 | 61 | struct tm date_and_time = *gmtime(&unixFormatted); 62 | 63 | RTC_TimeTypeDef rtc_time = { 64 | .Hours = date_and_time.tm_hour 65 | ,.Minutes = date_and_time.tm_min 66 | ,.Seconds = date_and_time.tm_sec 67 | }; 68 | 69 | return rtc_time; 70 | } 71 | 72 | RTC_DateTypeDef unix_timestamp_to_rtc_date(uint32_t unix_timestamp) 73 | { 74 | time_t unixFormatted = (time_t)unix_timestamp; 75 | 76 | struct tm date_and_time = *gmtime(&unixFormatted); 77 | 78 | RTC_DateTypeDef rtc_date = { 79 | .Date = date_and_time.tm_mday 80 | ,.Month = date_and_time.tm_mon + 1 81 | ,.Year = date_and_time.tm_year - 70 82 | ,.WeekDay = date_and_time.tm_wday 83 | }; 84 | 85 | // Resolve RTC_MONTH BCD inconsistencies 86 | if (rtc_date.Month >= 10) { rtc_date.Month += 6; } 87 | 88 | // Resolve RTC_WEEKDAY inconsistency 89 | if (rtc_date.WeekDay == 0) { rtc_date.WeekDay = 7; } 90 | 91 | return rtc_date; 92 | } 93 | -------------------------------------------------------------------------------- /cdh-tsat-stm32project-board/App/Src/task_control.c: -------------------------------------------------------------------------------- 1 | /* 2 | * time_tagged_task.c 3 | * 4 | * Created on: Feb 15, 2025 5 | * Author: drive 6 | */ 7 | #include 8 | 9 | #include "tuk/tuk.h" 10 | 11 | void StartTimeTagTaskInit(void *argument) 12 | { 13 | CANMessage msg; 14 | 15 | /* Infinite loop */ 16 | for(;;) 17 | { 18 | //block until thread resumed from command handler 19 | osMessageQueueGet(timeTagTaskInitQueueHandle, &msg, NULL, osWaitForever); 20 | 21 | HAL_StatusTypeDef operation_status; 22 | RTC_AlarmTypeDef rtc_alarm; 23 | uint32_t unix_timestamp = four_byte_array_to_uint32(msg.body); 24 | RTC_TimeTypeDef rtc_time = unix_timestamp_to_rtc_time(unix_timestamp); 25 | RTC_DateTypeDef rtc_date = unix_timestamp_to_rtc_date(unix_timestamp); 26 | 27 | rtc_alarm.AlarmTime = rtc_time; 28 | rtc_alarm.AlarmMask = RTC_ALARMMASK_NONE; 29 | rtc_alarm.SubSeconds = 0; 30 | rtc_alarm.AlarmSubSecondMask = RTC_ALARMSUBSECONDMASK_ALL; 31 | rtc_alarm.AlarmDateWeekDaySel = RTC_ALARMDATEWEEKDAYSEL_DATE; 32 | rtc_alarm.AlarmDateWeekDay = rtc_date.Date; 33 | rtc_alarm.Alarm = RTC_ALARM_A; 34 | 35 | operation_status = HAL_RTC_SetAlarm_IT(&hrtc, &rtc_alarm, RTC_FORMAT_BIN); 36 | 37 | //TODO: Implement error handling for StartTimeTagTaskInit 38 | } 39 | osThreadExit(); 40 | /* USER CODE END StartTimeTagTaskInit */ 41 | } 42 | 43 | 44 | void StartGetTasksNum(void *argument) 45 | { 46 | /* USER CODE BEGIN StartGetTasksNum */ 47 | /* Infinite loop */ 48 | for(;;) 49 | { 50 | //block until thread resumed from command handler 51 | osThreadFlagsWait(0x0001, osFlagsWaitAny, osWaitForever); 52 | 53 | uint8_t tasks_num = (uint8_t) osThreadGetCount(); 54 | 55 | //TODO: Add CAN message transmit 56 | } 57 | osThreadExit(); 58 | /* USER CODE END StartGetTasksNum */ 59 | } 60 | 61 | 62 | void StartTimeTagTask(void *argument) 63 | { 64 | /* Infinite loop */ 65 | for(;;) 66 | { 67 | // TODO: This entire task was commented out. It must be updated to work 68 | // with the new CAN Wrapper Module. Explicit ACK-ing should not be 69 | // necessary anymore. 70 | /* 71 | //block until thread resumed from RTC alarm ISR 72 | osThreadFlagsWait(0x0001, osFlagsWaitAny, osWaitForever); 73 | 74 | HAL_StatusTypeDef operation_status; 75 | CANMessage_t ack_message = 76 | { 77 | .priority = 0b0000111, 78 | .SenderID = 0x1, 79 | .DestinationID = 0x1, 80 | .command = 0x01, 81 | .data = {0x48, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00} 82 | }; 83 | 84 | operation_status = CAN_Transmit_Message(ack_message); 85 | if (operation_status != HAL_OK) goto error; 86 | operation_status = HAL_RTC_DeactivateAlarm(&hrtc, RTC_ALARM_A); 87 | 88 | error: 89 | if (operation_status != HAL_OK) 90 | { 91 | //TODO: Implement error handling for StartTimeTagTask 92 | }*/ 93 | } 94 | osThreadExit(); 95 | } 96 | 97 | -------------------------------------------------------------------------------- /cdh-tsat-stm32project-board/Drivers/CMSIS/Device/ST/STM32L4xx/Include/system_stm32l4xx.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file system_stm32l4xx.h 4 | * @author MCD Application Team 5 | * @brief CMSIS Cortex-M4 Device System Source File for STM32L4xx devices. 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | * Copyright (c) 2017 STMicroelectronics. 10 | * All rights reserved. 11 | * 12 | * This software is licensed under terms that can be found in the LICENSE file 13 | * in the root directory of this software component. 14 | * If no LICENSE file comes with this software, it is provided AS-IS. 15 | * 16 | ****************************************************************************** 17 | */ 18 | 19 | /** @addtogroup CMSIS 20 | * @{ 21 | */ 22 | 23 | /** @addtogroup stm32l4xx_system 24 | * @{ 25 | */ 26 | 27 | /** 28 | * @brief Define to prevent recursive inclusion 29 | */ 30 | #ifndef __SYSTEM_STM32L4XX_H 31 | #define __SYSTEM_STM32L4XX_H 32 | 33 | #ifdef __cplusplus 34 | extern "C" { 35 | #endif 36 | 37 | /** @addtogroup STM32L4xx_System_Includes 38 | * @{ 39 | */ 40 | 41 | /** 42 | * @} 43 | */ 44 | 45 | 46 | /** @addtogroup STM32L4xx_System_Exported_Variables 47 | * @{ 48 | */ 49 | /* The SystemCoreClock variable is updated in three ways: 50 | 1) by calling CMSIS function SystemCoreClockUpdate() 51 | 2) by calling HAL API function HAL_RCC_GetSysClockFreq() 52 | 3) each time HAL_RCC_ClockConfig() is called to configure the system clock frequency 53 | Note: If you use this function to configure the system clock; then there 54 | is no need to call the 2 first functions listed above, since SystemCoreClock 55 | variable is updated automatically. 56 | */ 57 | extern uint32_t SystemCoreClock; /*!< System Clock Frequency (Core Clock) */ 58 | 59 | extern const uint8_t AHBPrescTable[16]; /*!< AHB prescalers table values */ 60 | extern const uint8_t APBPrescTable[8]; /*!< APB prescalers table values */ 61 | extern const uint32_t MSIRangeTable[12]; /*!< MSI ranges table values */ 62 | 63 | /** 64 | * @} 65 | */ 66 | 67 | /** @addtogroup STM32L4xx_System_Exported_Constants 68 | * @{ 69 | */ 70 | 71 | /** 72 | * @} 73 | */ 74 | 75 | /** @addtogroup STM32L4xx_System_Exported_Macros 76 | * @{ 77 | */ 78 | 79 | /** 80 | * @} 81 | */ 82 | 83 | /** @addtogroup STM32L4xx_System_Exported_Functions 84 | * @{ 85 | */ 86 | 87 | extern void SystemInit(void); 88 | extern void SystemCoreClockUpdate(void); 89 | /** 90 | * @} 91 | */ 92 | 93 | #ifdef __cplusplus 94 | } 95 | #endif 96 | 97 | #endif /*__SYSTEM_STM32L4XX_H */ 98 | 99 | /** 100 | * @} 101 | */ 102 | 103 | /** 104 | * @} 105 | */ 106 | 107 | -------------------------------------------------------------------------------- /cdh-tsat-stm32project-nucleo/Drivers/CMSIS/Device/ST/STM32L4xx/Include/system_stm32l4xx.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file system_stm32l4xx.h 4 | * @author MCD Application Team 5 | * @brief CMSIS Cortex-M4 Device System Source File for STM32L4xx devices. 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | * Copyright (c) 2017 STMicroelectronics. 10 | * All rights reserved. 11 | * 12 | * This software is licensed under terms that can be found in the LICENSE file 13 | * in the root directory of this software component. 14 | * If no LICENSE file comes with this software, it is provided AS-IS. 15 | * 16 | ****************************************************************************** 17 | */ 18 | 19 | /** @addtogroup CMSIS 20 | * @{ 21 | */ 22 | 23 | /** @addtogroup stm32l4xx_system 24 | * @{ 25 | */ 26 | 27 | /** 28 | * @brief Define to prevent recursive inclusion 29 | */ 30 | #ifndef __SYSTEM_STM32L4XX_H 31 | #define __SYSTEM_STM32L4XX_H 32 | 33 | #ifdef __cplusplus 34 | extern "C" { 35 | #endif 36 | 37 | /** @addtogroup STM32L4xx_System_Includes 38 | * @{ 39 | */ 40 | 41 | /** 42 | * @} 43 | */ 44 | 45 | 46 | /** @addtogroup STM32L4xx_System_Exported_Variables 47 | * @{ 48 | */ 49 | /* The SystemCoreClock variable is updated in three ways: 50 | 1) by calling CMSIS function SystemCoreClockUpdate() 51 | 2) by calling HAL API function HAL_RCC_GetSysClockFreq() 52 | 3) each time HAL_RCC_ClockConfig() is called to configure the system clock frequency 53 | Note: If you use this function to configure the system clock; then there 54 | is no need to call the 2 first functions listed above, since SystemCoreClock 55 | variable is updated automatically. 56 | */ 57 | extern uint32_t SystemCoreClock; /*!< System Clock Frequency (Core Clock) */ 58 | 59 | extern const uint8_t AHBPrescTable[16]; /*!< AHB prescalers table values */ 60 | extern const uint8_t APBPrescTable[8]; /*!< APB prescalers table values */ 61 | extern const uint32_t MSIRangeTable[12]; /*!< MSI ranges table values */ 62 | 63 | /** 64 | * @} 65 | */ 66 | 67 | /** @addtogroup STM32L4xx_System_Exported_Constants 68 | * @{ 69 | */ 70 | 71 | /** 72 | * @} 73 | */ 74 | 75 | /** @addtogroup STM32L4xx_System_Exported_Macros 76 | * @{ 77 | */ 78 | 79 | /** 80 | * @} 81 | */ 82 | 83 | /** @addtogroup STM32L4xx_System_Exported_Functions 84 | * @{ 85 | */ 86 | 87 | extern void SystemInit(void); 88 | extern void SystemCoreClockUpdate(void); 89 | /** 90 | * @} 91 | */ 92 | 93 | #ifdef __cplusplus 94 | } 95 | #endif 96 | 97 | #endif /*__SYSTEM_STM32L4XX_H */ 98 | 99 | /** 100 | * @} 101 | */ 102 | 103 | /** 104 | * @} 105 | */ 106 | 107 | -------------------------------------------------------------------------------- /cdh-tsat-stm32project-board/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 | -------------------------------------------------------------------------------- /cdh-tsat-stm32project-nucleo/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 | -------------------------------------------------------------------------------- /cdh-tsat-stm32project-board/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) 2023 STMicroelectronics. 14 | * All rights reserved. 15 | * 16 | * This software is licensed under terms that can be found in the LICENSE file 17 | * in the root directory of this software component. 18 | * If no LICENSE file comes with this software, it is provided AS-IS. 19 | * 20 | ****************************************************************************** 21 | */ 22 | 23 | /* Includes */ 24 | #include 25 | #include 26 | 27 | /** 28 | * Pointer to the current high watermark of the heap usage 29 | */ 30 | static uint8_t *__sbrk_heap_end = NULL; 31 | 32 | /** 33 | * @brief _sbrk() allocates memory to the newlib heap and is used by malloc 34 | * and others from the C library 35 | * 36 | * @verbatim 37 | * ############################################################################ 38 | * # .data # .bss # newlib heap # MSP stack # 39 | * # # # # Reserved by _Min_Stack_Size # 40 | * ############################################################################ 41 | * ^-- RAM start ^-- _end _estack, RAM end --^ 42 | * @endverbatim 43 | * 44 | * This implementation starts allocating at the '_end' linker symbol 45 | * The '_Min_Stack_Size' linker symbol reserves a memory for the MSP stack 46 | * The implementation considers '_estack' linker symbol to be RAM end 47 | * NOTE: If the MSP stack, at any point during execution, grows larger than the 48 | * reserved size, please increase the '_Min_Stack_Size'. 49 | * 50 | * @param incr Memory size 51 | * @return Pointer to allocated memory 52 | */ 53 | void *_sbrk(ptrdiff_t incr) 54 | { 55 | extern uint8_t _end; /* Symbol defined in the linker script */ 56 | extern uint8_t _estack; /* Symbol defined in the linker script */ 57 | extern uint32_t _Min_Stack_Size; /* Symbol defined in the linker script */ 58 | const uint32_t stack_limit = (uint32_t)&_estack - (uint32_t)&_Min_Stack_Size; 59 | const uint8_t *max_heap = (uint8_t *)stack_limit; 60 | uint8_t *prev_heap_end; 61 | 62 | /* Initialize heap end at first call */ 63 | if (NULL == __sbrk_heap_end) 64 | { 65 | __sbrk_heap_end = &_end; 66 | } 67 | 68 | /* Protect heap from growing into the reserved MSP stack */ 69 | if (__sbrk_heap_end + incr > max_heap) 70 | { 71 | errno = ENOMEM; 72 | return (void *)-1; 73 | } 74 | 75 | prev_heap_end = __sbrk_heap_end; 76 | __sbrk_heap_end += incr; 77 | 78 | return (void *)prev_heap_end; 79 | } 80 | -------------------------------------------------------------------------------- /cdh-tsat-stm32project-nucleo/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) 2023 STMicroelectronics. 14 | * All rights reserved. 15 | * 16 | * This software is licensed under terms that can be found in the LICENSE file 17 | * in the root directory of this software component. 18 | * If no LICENSE file comes with this software, it is provided AS-IS. 19 | * 20 | ****************************************************************************** 21 | */ 22 | 23 | /* Includes */ 24 | #include 25 | #include 26 | 27 | /** 28 | * Pointer to the current high watermark of the heap usage 29 | */ 30 | static uint8_t *__sbrk_heap_end = NULL; 31 | 32 | /** 33 | * @brief _sbrk() allocates memory to the newlib heap and is used by malloc 34 | * and others from the C library 35 | * 36 | * @verbatim 37 | * ############################################################################ 38 | * # .data # .bss # newlib heap # MSP stack # 39 | * # # # # Reserved by _Min_Stack_Size # 40 | * ############################################################################ 41 | * ^-- RAM start ^-- _end _estack, RAM end --^ 42 | * @endverbatim 43 | * 44 | * This implementation starts allocating at the '_end' linker symbol 45 | * The '_Min_Stack_Size' linker symbol reserves a memory for the MSP stack 46 | * The implementation considers '_estack' linker symbol to be RAM end 47 | * NOTE: If the MSP stack, at any point during execution, grows larger than the 48 | * reserved size, please increase the '_Min_Stack_Size'. 49 | * 50 | * @param incr Memory size 51 | * @return Pointer to allocated memory 52 | */ 53 | void *_sbrk(ptrdiff_t incr) 54 | { 55 | extern uint8_t _end; /* Symbol defined in the linker script */ 56 | extern uint8_t _estack; /* Symbol defined in the linker script */ 57 | extern uint32_t _Min_Stack_Size; /* Symbol defined in the linker script */ 58 | const uint32_t stack_limit = (uint32_t)&_estack - (uint32_t)&_Min_Stack_Size; 59 | const uint8_t *max_heap = (uint8_t *)stack_limit; 60 | uint8_t *prev_heap_end; 61 | 62 | /* Initialize heap end at first call */ 63 | if (NULL == __sbrk_heap_end) 64 | { 65 | __sbrk_heap_end = &_end; 66 | } 67 | 68 | /* Protect heap from growing into the reserved MSP stack */ 69 | if (__sbrk_heap_end + incr > max_heap) 70 | { 71 | errno = ENOMEM; 72 | return (void *)-1; 73 | } 74 | 75 | prev_heap_end = __sbrk_heap_end; 76 | __sbrk_heap_end += incr; 77 | 78 | return (void *)prev_heap_end; 79 | } 80 | -------------------------------------------------------------------------------- /cdh-tsat-stm32project-board/Drivers/Hardware_Peripherals/Inc/MAX6822_driver.h: -------------------------------------------------------------------------------- 1 | /* 2 | * FILENAME: MAX6822_driver.h 3 | * 4 | * DESCRIPTION: STM32L4 driver header file for the MAX6822RUK+T watchdog / voltage supervisor. 5 | * 6 | * AUTHORS: 7 | * - Daigh Burgess (daigh.burgess@umsats.ca) 8 | * 9 | * CREATED ON: Mar. 18, 2023 10 | */ 11 | 12 | #ifndef HARDWARE_PERIPHERALS_INC_MAX6822_DRIVER_H_ 13 | #define HARDWARE_PERIPHERALS_INC_MAX6822_DRIVER_H_ 14 | 15 | //############################################################################################### 16 | //Include Directives 17 | //############################################################################################### 18 | #include "stm32l4xx_hal.h" 19 | 20 | //############################################################################################### 21 | //Public Define Directives 22 | //############################################################################################### 23 | #define WDI_GPIO GPIOB 24 | #define WDI_PIN GPIO_PIN_6 25 | 26 | #define M_nReset_GPIO GPIOB 27 | #define M_nReset_PIN GPIO_PIN_7 28 | 29 | //############################################################################################### 30 | //Public Driver Function Prototypes 31 | //############################################################################################### 32 | /* 33 | * FUNCTION: MAX6822_Init 34 | * 35 | * DESCRIPTION: Set the M_nReset pin HIGH. 36 | * 37 | * NOTES: 38 | * - Keeping the M_nReset pin HIGH will keep the MAX6822 output reset pin HIGH, allowing the 39 | * STM32 to continue running. 40 | */ 41 | void MAX6822_Init(); 42 | 43 | /* 44 | * FUNCTION: MAX6822_Manual_Reset 45 | * 46 | * DESCRIPTION: Set the M_nReset pin LOW. 47 | * 48 | * NOTES: 49 | * - Setting the M_nReset pin LOW will trigger the MAX6822 to set its output reset pin LOW, 50 | * resetting the STM32. 51 | * - The MAX6822 output reset pin is held LOW while M_nReset is held LOW, and for the timeout 52 | * period of ~200ms after M_nReset returns HIGH. 53 | * - The MAX6822 contains an internal 50k pullup resistor for the M_nReset input, which means 54 | * the M_nReset line will be pulled HIGH once the STM32 enters a reset state. 55 | */ 56 | void MAX6822_Manual_Reset(); 57 | 58 | /* 59 | * FUNCTION: MAX6822_WDI_Toggle 60 | * 61 | * DESCRIPTION: Toggle the WDI pin. 62 | * 63 | * NOTES: 64 | * - If the WDI pin is not toggled within a 1.6 second window, the MAX6822 will set its ouptut 65 | * reset pin LOW, resetting the STM32. 66 | * - The 1.6 second window is restarted after every successful WDI toggle, or after the MAX6822 67 | * returns its output reset pin HIGH following a reset assertion. 68 | * - Since the 1.6 second window is restarted following a reset assertion, the STM32 must 69 | * continue to call this function while performing initialization tasks, if performing all the 70 | * initialization tasks takes close to or greater than 1.6 seconds. 71 | */ 72 | void MAX6822_WDI_Toggle(); 73 | 74 | #endif /* HARDWARE_PERIPHERALS_INC_MAX6822_DRIVER_H_ */ 75 | -------------------------------------------------------------------------------- /cdh-tsat-stm32project-nucleo/Drivers/Hardware_Peripherals/Inc/MAX6822_driver.h: -------------------------------------------------------------------------------- 1 | /* 2 | * FILENAME: MAX6822_driver.h 3 | * 4 | * DESCRIPTION: STM32L4 driver header file for the MAX6822RUK+T watchdog / voltage supervisor. 5 | * 6 | * AUTHORS: 7 | * - Daigh Burgess (daigh.burgess@umsats.ca) 8 | * 9 | * CREATED ON: Mar. 18, 2023 10 | */ 11 | 12 | #ifndef HARDWARE_PERIPHERALS_INC_MAX6822_DRIVER_H_ 13 | #define HARDWARE_PERIPHERALS_INC_MAX6822_DRIVER_H_ 14 | 15 | //############################################################################################### 16 | //Include Directives 17 | //############################################################################################### 18 | #include "stm32l4xx_hal.h" 19 | 20 | //############################################################################################### 21 | //Public Define Directives 22 | //############################################################################################### 23 | #define WDI_GPIO GPIOA 24 | #define WDI_PIN GPIO_PIN_11 25 | 26 | #define M_nReset_GPIO GPIOA 27 | #define M_nReset_PIN GPIO_PIN_12 28 | 29 | //############################################################################################### 30 | //Public Driver Function Prototypes 31 | //############################################################################################### 32 | /* 33 | * FUNCTION: MAX6822_Init 34 | * 35 | * DESCRIPTION: Set the M_nReset pin HIGH. 36 | * 37 | * NOTES: 38 | * - Keeping the M_nReset pin HIGH will keep the MAX6822 output reset pin HIGH, allowing the 39 | * STM32 to continue running. 40 | */ 41 | void MAX6822_Init(); 42 | 43 | /* 44 | * FUNCTION: MAX6822_Manual_Reset 45 | * 46 | * DESCRIPTION: Set the M_nReset pin LOW. 47 | * 48 | * NOTES: 49 | * - Setting the M_nReset pin LOW will trigger the MAX6822 to set its output reset pin LOW, 50 | * resetting the STM32. 51 | * - The MAX6822 output reset pin is held LOW while M_nReset is held LOW, and for the timeout 52 | * period of ~200ms after M_nReset returns HIGH. 53 | * - The MAX6822 contains an internal 50k pullup resistor for the M_nReset input, which means 54 | * the M_nReset line will be pulled HIGH once the STM32 enters a reset state. 55 | */ 56 | void MAX6822_Manual_Reset(); 57 | 58 | /* 59 | * FUNCTION: MAX6822_WDI_Toggle 60 | * 61 | * DESCRIPTION: Toggle the WDI pin. 62 | * 63 | * NOTES: 64 | * - If the WDI pin is not toggled within a 1.6 second window, the MAX6822 will set its ouptut 65 | * reset pin LOW, resetting the STM32. 66 | * - The 1.6 second window is restarted after every successful WDI toggle, or after the MAX6822 67 | * returns its output reset pin HIGH following a reset assertion. 68 | * - Since the 1.6 second window is restarted following a reset assertion, the STM32 must 69 | * continue to call this function while performing initialization tasks, if performing all the 70 | * initialization tasks takes close to or greater than 1.6 seconds. 71 | */ 72 | void MAX6822_WDI_Toggle(); 73 | 74 | #endif /* HARDWARE_PERIPHERALS_INC_MAX6822_DRIVER_H_ */ 75 | -------------------------------------------------------------------------------- /cdh-tsat-stm32project-board/Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_spi_ex.c: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32l4xx_hal_spi_ex.c 4 | * @author MCD Application Team 5 | * @brief Extended SPI HAL module driver. 6 | * This file provides firmware functions to manage the following 7 | * SPI peripheral extended functionalities : 8 | * + IO operation functions 9 | * 10 | ****************************************************************************** 11 | * @attention 12 | * 13 | * Copyright (c) 2017 STMicroelectronics. 14 | * All rights reserved. 15 | * 16 | * This software is licensed under terms that can be found in the LICENSE file 17 | * in the root directory of this software component. 18 | * If no LICENSE file comes with this software, it is provided AS-IS. 19 | * 20 | ****************************************************************************** 21 | */ 22 | 23 | /* Includes ------------------------------------------------------------------*/ 24 | #include "stm32l4xx_hal.h" 25 | 26 | /** @addtogroup STM32L4xx_HAL_Driver 27 | * @{ 28 | */ 29 | 30 | /** @defgroup SPIEx SPIEx 31 | * @brief SPI Extended HAL module driver 32 | * @{ 33 | */ 34 | #ifdef HAL_SPI_MODULE_ENABLED 35 | 36 | /* Private typedef -----------------------------------------------------------*/ 37 | /* Private defines -----------------------------------------------------------*/ 38 | /** @defgroup SPIEx_Private_Constants SPIEx Private Constants 39 | * @{ 40 | */ 41 | #define SPI_FIFO_SIZE 4UL 42 | /** 43 | * @} 44 | */ 45 | 46 | /* Private macros ------------------------------------------------------------*/ 47 | /* Private variables ---------------------------------------------------------*/ 48 | /* Private function prototypes -----------------------------------------------*/ 49 | /* Exported functions --------------------------------------------------------*/ 50 | 51 | /** @defgroup SPIEx_Exported_Functions SPIEx Exported Functions 52 | * @{ 53 | */ 54 | 55 | /** @defgroup SPIEx_Exported_Functions_Group1 IO operation functions 56 | * @brief Data transfers functions 57 | * 58 | @verbatim 59 | ============================================================================== 60 | ##### IO operation functions ##### 61 | =============================================================================== 62 | [..] 63 | This subsection provides a set of extended functions to manage the SPI 64 | data transfers. 65 | 66 | (#) Rx data flush function: 67 | (++) HAL_SPIEx_FlushRxFifo() 68 | 69 | @endverbatim 70 | * @{ 71 | */ 72 | 73 | /** 74 | * @brief Flush the RX fifo. 75 | * @param hspi pointer to a SPI_HandleTypeDef structure that contains 76 | * the configuration information for the specified SPI module. 77 | * @retval HAL status 78 | */ 79 | HAL_StatusTypeDef HAL_SPIEx_FlushRxFifo(SPI_HandleTypeDef *hspi) 80 | { 81 | __IO uint32_t tmpreg; 82 | uint8_t count = 0U; 83 | while ((hspi->Instance->SR & SPI_FLAG_FRLVL) != SPI_FRLVL_EMPTY) 84 | { 85 | count++; 86 | tmpreg = hspi->Instance->DR; 87 | UNUSED(tmpreg); /* To avoid GCC warning */ 88 | if (count == SPI_FIFO_SIZE) 89 | { 90 | return HAL_TIMEOUT; 91 | } 92 | } 93 | return HAL_OK; 94 | } 95 | 96 | /** 97 | * @} 98 | */ 99 | 100 | /** 101 | * @} 102 | */ 103 | 104 | #endif /* HAL_SPI_MODULE_ENABLED */ 105 | 106 | /** 107 | * @} 108 | */ 109 | 110 | /** 111 | * @} 112 | */ 113 | -------------------------------------------------------------------------------- /cdh-tsat-stm32project-nucleo/Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_spi_ex.c: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32l4xx_hal_spi_ex.c 4 | * @author MCD Application Team 5 | * @brief Extended SPI HAL module driver. 6 | * This file provides firmware functions to manage the following 7 | * SPI peripheral extended functionalities : 8 | * + IO operation functions 9 | * 10 | ****************************************************************************** 11 | * @attention 12 | * 13 | * Copyright (c) 2017 STMicroelectronics. 14 | * All rights reserved. 15 | * 16 | * This software is licensed under terms that can be found in the LICENSE file 17 | * in the root directory of this software component. 18 | * If no LICENSE file comes with this software, it is provided AS-IS. 19 | * 20 | ****************************************************************************** 21 | */ 22 | 23 | /* Includes ------------------------------------------------------------------*/ 24 | #include "stm32l4xx_hal.h" 25 | 26 | /** @addtogroup STM32L4xx_HAL_Driver 27 | * @{ 28 | */ 29 | 30 | /** @defgroup SPIEx SPIEx 31 | * @brief SPI Extended HAL module driver 32 | * @{ 33 | */ 34 | #ifdef HAL_SPI_MODULE_ENABLED 35 | 36 | /* Private typedef -----------------------------------------------------------*/ 37 | /* Private defines -----------------------------------------------------------*/ 38 | /** @defgroup SPIEx_Private_Constants SPIEx Private Constants 39 | * @{ 40 | */ 41 | #define SPI_FIFO_SIZE 4UL 42 | /** 43 | * @} 44 | */ 45 | 46 | /* Private macros ------------------------------------------------------------*/ 47 | /* Private variables ---------------------------------------------------------*/ 48 | /* Private function prototypes -----------------------------------------------*/ 49 | /* Exported functions --------------------------------------------------------*/ 50 | 51 | /** @defgroup SPIEx_Exported_Functions SPIEx Exported Functions 52 | * @{ 53 | */ 54 | 55 | /** @defgroup SPIEx_Exported_Functions_Group1 IO operation functions 56 | * @brief Data transfers functions 57 | * 58 | @verbatim 59 | ============================================================================== 60 | ##### IO operation functions ##### 61 | =============================================================================== 62 | [..] 63 | This subsection provides a set of extended functions to manage the SPI 64 | data transfers. 65 | 66 | (#) Rx data flush function: 67 | (++) HAL_SPIEx_FlushRxFifo() 68 | 69 | @endverbatim 70 | * @{ 71 | */ 72 | 73 | /** 74 | * @brief Flush the RX fifo. 75 | * @param hspi pointer to a SPI_HandleTypeDef structure that contains 76 | * the configuration information for the specified SPI module. 77 | * @retval HAL status 78 | */ 79 | HAL_StatusTypeDef HAL_SPIEx_FlushRxFifo(SPI_HandleTypeDef *hspi) 80 | { 81 | __IO uint32_t tmpreg; 82 | uint8_t count = 0U; 83 | while ((hspi->Instance->SR & SPI_FLAG_FRLVL) != SPI_FRLVL_EMPTY) 84 | { 85 | count++; 86 | tmpreg = hspi->Instance->DR; 87 | UNUSED(tmpreg); /* To avoid GCC warning */ 88 | if (count == SPI_FIFO_SIZE) 89 | { 90 | return HAL_TIMEOUT; 91 | } 92 | } 93 | return HAL_OK; 94 | } 95 | 96 | /** 97 | * @} 98 | */ 99 | 100 | /** 101 | * @} 102 | */ 103 | 104 | #endif /* HAL_SPI_MODULE_ENABLED */ 105 | 106 | /** 107 | * @} 108 | */ 109 | 110 | /** 111 | * @} 112 | */ 113 | -------------------------------------------------------------------------------- /cdh-tsat-stm32project-board/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-2023 STMicroelectronics. 14 | * All rights reserved. 15 | * 16 | * This software is licensed under terms that can be found in the LICENSE file 17 | * in the root directory of this software component. 18 | * If no LICENSE file comes with this software, it is provided AS-IS. 19 | * 20 | ****************************************************************************** 21 | */ 22 | 23 | /* Includes */ 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | 33 | 34 | /* Variables */ 35 | extern int __io_putchar(int ch) __attribute__((weak)); 36 | extern int __io_getchar(void) __attribute__((weak)); 37 | 38 | 39 | char *__env[1] = { 0 }; 40 | char **environ = __env; 41 | 42 | 43 | /* Functions */ 44 | void initialise_monitor_handles() 45 | { 46 | } 47 | 48 | int _getpid(void) 49 | { 50 | return 1; 51 | } 52 | 53 | int _kill(int pid, int sig) 54 | { 55 | (void)pid; 56 | (void)sig; 57 | errno = EINVAL; 58 | return -1; 59 | } 60 | 61 | void _exit (int status) 62 | { 63 | _kill(status, -1); 64 | while (1) {} /* Make sure we hang here */ 65 | } 66 | 67 | __attribute__((weak)) int _read(int file, char *ptr, int len) 68 | { 69 | (void)file; 70 | int DataIdx; 71 | 72 | for (DataIdx = 0; DataIdx < len; DataIdx++) 73 | { 74 | *ptr++ = __io_getchar(); 75 | } 76 | 77 | return len; 78 | } 79 | 80 | __attribute__((weak)) int _write(int file, char *ptr, int len) 81 | { 82 | (void)file; 83 | int DataIdx; 84 | 85 | for (DataIdx = 0; DataIdx < len; DataIdx++) 86 | { 87 | __io_putchar(*ptr++); 88 | } 89 | return len; 90 | } 91 | 92 | int _close(int file) 93 | { 94 | (void)file; 95 | return -1; 96 | } 97 | 98 | 99 | int _fstat(int file, struct stat *st) 100 | { 101 | (void)file; 102 | st->st_mode = S_IFCHR; 103 | return 0; 104 | } 105 | 106 | int _isatty(int file) 107 | { 108 | (void)file; 109 | return 1; 110 | } 111 | 112 | int _lseek(int file, int ptr, int dir) 113 | { 114 | (void)file; 115 | (void)ptr; 116 | (void)dir; 117 | return 0; 118 | } 119 | 120 | int _open(char *path, int flags, ...) 121 | { 122 | (void)path; 123 | (void)flags; 124 | /* Pretend like we always fail */ 125 | return -1; 126 | } 127 | 128 | int _wait(int *status) 129 | { 130 | (void)status; 131 | errno = ECHILD; 132 | return -1; 133 | } 134 | 135 | int _unlink(char *name) 136 | { 137 | (void)name; 138 | errno = ENOENT; 139 | return -1; 140 | } 141 | 142 | int _times(struct tms *buf) 143 | { 144 | (void)buf; 145 | return -1; 146 | } 147 | 148 | int _stat(char *file, struct stat *st) 149 | { 150 | (void)file; 151 | st->st_mode = S_IFCHR; 152 | return 0; 153 | } 154 | 155 | int _link(char *old, char *new) 156 | { 157 | (void)old; 158 | (void)new; 159 | errno = EMLINK; 160 | return -1; 161 | } 162 | 163 | int _fork(void) 164 | { 165 | errno = EAGAIN; 166 | return -1; 167 | } 168 | 169 | int _execve(char *name, char **argv, char **env) 170 | { 171 | (void)name; 172 | (void)argv; 173 | (void)env; 174 | errno = ENOMEM; 175 | return -1; 176 | } 177 | -------------------------------------------------------------------------------- /cdh-tsat-stm32project-nucleo/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-2023 STMicroelectronics. 14 | * All rights reserved. 15 | * 16 | * This software is licensed under terms that can be found in the LICENSE file 17 | * in the root directory of this software component. 18 | * If no LICENSE file comes with this software, it is provided AS-IS. 19 | * 20 | ****************************************************************************** 21 | */ 22 | 23 | /* Includes */ 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | 33 | 34 | /* Variables */ 35 | extern int __io_putchar(int ch) __attribute__((weak)); 36 | extern int __io_getchar(void) __attribute__((weak)); 37 | 38 | 39 | char *__env[1] = { 0 }; 40 | char **environ = __env; 41 | 42 | 43 | /* Functions */ 44 | void initialise_monitor_handles() 45 | { 46 | } 47 | 48 | int _getpid(void) 49 | { 50 | return 1; 51 | } 52 | 53 | int _kill(int pid, int sig) 54 | { 55 | (void)pid; 56 | (void)sig; 57 | errno = EINVAL; 58 | return -1; 59 | } 60 | 61 | void _exit (int status) 62 | { 63 | _kill(status, -1); 64 | while (1) {} /* Make sure we hang here */ 65 | } 66 | 67 | __attribute__((weak)) int _read(int file, char *ptr, int len) 68 | { 69 | (void)file; 70 | int DataIdx; 71 | 72 | for (DataIdx = 0; DataIdx < len; DataIdx++) 73 | { 74 | *ptr++ = __io_getchar(); 75 | } 76 | 77 | return len; 78 | } 79 | 80 | __attribute__((weak)) int _write(int file, char *ptr, int len) 81 | { 82 | (void)file; 83 | int DataIdx; 84 | 85 | for (DataIdx = 0; DataIdx < len; DataIdx++) 86 | { 87 | __io_putchar(*ptr++); 88 | } 89 | return len; 90 | } 91 | 92 | int _close(int file) 93 | { 94 | (void)file; 95 | return -1; 96 | } 97 | 98 | 99 | int _fstat(int file, struct stat *st) 100 | { 101 | (void)file; 102 | st->st_mode = S_IFCHR; 103 | return 0; 104 | } 105 | 106 | int _isatty(int file) 107 | { 108 | (void)file; 109 | return 1; 110 | } 111 | 112 | int _lseek(int file, int ptr, int dir) 113 | { 114 | (void)file; 115 | (void)ptr; 116 | (void)dir; 117 | return 0; 118 | } 119 | 120 | int _open(char *path, int flags, ...) 121 | { 122 | (void)path; 123 | (void)flags; 124 | /* Pretend like we always fail */ 125 | return -1; 126 | } 127 | 128 | int _wait(int *status) 129 | { 130 | (void)status; 131 | errno = ECHILD; 132 | return -1; 133 | } 134 | 135 | int _unlink(char *name) 136 | { 137 | (void)name; 138 | errno = ENOENT; 139 | return -1; 140 | } 141 | 142 | int _times(struct tms *buf) 143 | { 144 | (void)buf; 145 | return -1; 146 | } 147 | 148 | int _stat(char *file, struct stat *st) 149 | { 150 | (void)file; 151 | st->st_mode = S_IFCHR; 152 | return 0; 153 | } 154 | 155 | int _link(char *old, char *new) 156 | { 157 | (void)old; 158 | (void)new; 159 | errno = EMLINK; 160 | return -1; 161 | } 162 | 163 | int _fork(void) 164 | { 165 | errno = EAGAIN; 166 | return -1; 167 | } 168 | 169 | int _execve(char *name, char **argv, char **env) 170 | { 171 | (void)name; 172 | (void)argv; 173 | (void)env; 174 | errno = ENOMEM; 175 | return -1; 176 | } 177 | -------------------------------------------------------------------------------- /cdh-tsat-stm32project-board/Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_hal_flash_ex.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32l4xx_hal_flash_ex.h 4 | * @author MCD Application Team 5 | * @brief Header file of FLASH HAL Extended module. 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | * Copyright (c) 2017 STMicroelectronics. 10 | * All rights reserved. 11 | * 12 | * This software is licensed under terms that can be found in the LICENSE file in 13 | * the root directory of this software component. 14 | * If no LICENSE file comes with this software, it is provided AS-IS. 15 | ****************************************************************************** 16 | */ 17 | 18 | /* Define to prevent recursive inclusion -------------------------------------*/ 19 | #ifndef STM32L4xx_HAL_FLASH_EX_H 20 | #define STM32L4xx_HAL_FLASH_EX_H 21 | 22 | #ifdef __cplusplus 23 | extern "C" { 24 | #endif 25 | 26 | /* Includes ------------------------------------------------------------------*/ 27 | #include "stm32l4xx_hal_def.h" 28 | 29 | /** @addtogroup STM32L4xx_HAL_Driver 30 | * @{ 31 | */ 32 | 33 | /** @addtogroup FLASHEx 34 | * @{ 35 | */ 36 | 37 | /* Exported types ------------------------------------------------------------*/ 38 | 39 | /* Exported constants --------------------------------------------------------*/ 40 | #if defined (FLASH_CFGR_LVEN) 41 | /** @addtogroup FLASHEx_Exported_Constants 42 | * @{ 43 | */ 44 | /** @defgroup FLASHEx_LVE_PIN_CFG FLASHEx LVE pin configuration 45 | * @{ 46 | */ 47 | #define FLASH_LVE_PIN_CTRL 0x00000000U /*!< LVE FLASH pin controlled by power controller */ 48 | #define FLASH_LVE_PIN_FORCED FLASH_CFGR_LVEN /*!< LVE FLASH pin enforced to low (external SMPS used) */ 49 | /** 50 | * @} 51 | */ 52 | 53 | /** 54 | * @} 55 | */ 56 | #endif /* FLASH_CFGR_LVEN */ 57 | 58 | /* Exported macro ------------------------------------------------------------*/ 59 | 60 | /* Exported functions --------------------------------------------------------*/ 61 | /** @addtogroup FLASHEx_Exported_Functions 62 | * @{ 63 | */ 64 | 65 | /* Extended Program operation functions *************************************/ 66 | /** @addtogroup FLASHEx_Exported_Functions_Group1 67 | * @{ 68 | */ 69 | HAL_StatusTypeDef HAL_FLASHEx_Erase(FLASH_EraseInitTypeDef *pEraseInit, uint32_t *PageError); 70 | HAL_StatusTypeDef HAL_FLASHEx_Erase_IT(FLASH_EraseInitTypeDef *pEraseInit); 71 | HAL_StatusTypeDef HAL_FLASHEx_OBProgram(FLASH_OBProgramInitTypeDef *pOBInit); 72 | void HAL_FLASHEx_OBGetConfig(FLASH_OBProgramInitTypeDef *pOBInit); 73 | /** 74 | * @} 75 | */ 76 | 77 | #if defined (FLASH_CFGR_LVEN) 78 | /** @addtogroup FLASHEx_Exported_Functions_Group2 79 | * @{ 80 | */ 81 | HAL_StatusTypeDef HAL_FLASHEx_ConfigLVEPin(uint32_t ConfigLVE); 82 | /** 83 | * @} 84 | */ 85 | #endif /* FLASH_CFGR_LVEN */ 86 | 87 | /** 88 | * @} 89 | */ 90 | 91 | /* Private function ----------------------------------------------------------*/ 92 | /** @addtogroup FLASHEx_Private_Functions FLASHEx Private Functions 93 | * @{ 94 | */ 95 | void FLASH_PageErase(uint32_t Page, uint32_t Banks); 96 | void FLASH_FlushCaches(void); 97 | /** 98 | * @} 99 | */ 100 | 101 | /* Private macros ------------------------------------------------------------*/ 102 | /** 103 | @cond 0 104 | */ 105 | #if defined (FLASH_CFGR_LVEN) 106 | #define IS_FLASH_LVE_PIN(CFG) (((CFG) == FLASH_LVE_PIN_CTRL) || ((CFG) == FLASH_LVE_PIN_FORCED)) 107 | #endif /* FLASH_CFGR_LVEN */ 108 | /** 109 | @endcond 110 | */ 111 | 112 | /** 113 | * @} 114 | */ 115 | 116 | /** 117 | * @} 118 | */ 119 | 120 | #ifdef __cplusplus 121 | } 122 | #endif 123 | 124 | #endif /* STM32L4xx_HAL_FLASH_EX_H */ 125 | 126 | -------------------------------------------------------------------------------- /cdh-tsat-stm32project-nucleo/Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_hal_flash_ex.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32l4xx_hal_flash_ex.h 4 | * @author MCD Application Team 5 | * @brief Header file of FLASH HAL Extended module. 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | * Copyright (c) 2017 STMicroelectronics. 10 | * All rights reserved. 11 | * 12 | * This software is licensed under terms that can be found in the LICENSE file in 13 | * the root directory of this software component. 14 | * If no LICENSE file comes with this software, it is provided AS-IS. 15 | ****************************************************************************** 16 | */ 17 | 18 | /* Define to prevent recursive inclusion -------------------------------------*/ 19 | #ifndef STM32L4xx_HAL_FLASH_EX_H 20 | #define STM32L4xx_HAL_FLASH_EX_H 21 | 22 | #ifdef __cplusplus 23 | extern "C" { 24 | #endif 25 | 26 | /* Includes ------------------------------------------------------------------*/ 27 | #include "stm32l4xx_hal_def.h" 28 | 29 | /** @addtogroup STM32L4xx_HAL_Driver 30 | * @{ 31 | */ 32 | 33 | /** @addtogroup FLASHEx 34 | * @{ 35 | */ 36 | 37 | /* Exported types ------------------------------------------------------------*/ 38 | 39 | /* Exported constants --------------------------------------------------------*/ 40 | #if defined (FLASH_CFGR_LVEN) 41 | /** @addtogroup FLASHEx_Exported_Constants 42 | * @{ 43 | */ 44 | /** @defgroup FLASHEx_LVE_PIN_CFG FLASHEx LVE pin configuration 45 | * @{ 46 | */ 47 | #define FLASH_LVE_PIN_CTRL 0x00000000U /*!< LVE FLASH pin controlled by power controller */ 48 | #define FLASH_LVE_PIN_FORCED FLASH_CFGR_LVEN /*!< LVE FLASH pin enforced to low (external SMPS used) */ 49 | /** 50 | * @} 51 | */ 52 | 53 | /** 54 | * @} 55 | */ 56 | #endif /* FLASH_CFGR_LVEN */ 57 | 58 | /* Exported macro ------------------------------------------------------------*/ 59 | 60 | /* Exported functions --------------------------------------------------------*/ 61 | /** @addtogroup FLASHEx_Exported_Functions 62 | * @{ 63 | */ 64 | 65 | /* Extended Program operation functions *************************************/ 66 | /** @addtogroup FLASHEx_Exported_Functions_Group1 67 | * @{ 68 | */ 69 | HAL_StatusTypeDef HAL_FLASHEx_Erase(FLASH_EraseInitTypeDef *pEraseInit, uint32_t *PageError); 70 | HAL_StatusTypeDef HAL_FLASHEx_Erase_IT(FLASH_EraseInitTypeDef *pEraseInit); 71 | HAL_StatusTypeDef HAL_FLASHEx_OBProgram(FLASH_OBProgramInitTypeDef *pOBInit); 72 | void HAL_FLASHEx_OBGetConfig(FLASH_OBProgramInitTypeDef *pOBInit); 73 | /** 74 | * @} 75 | */ 76 | 77 | #if defined (FLASH_CFGR_LVEN) 78 | /** @addtogroup FLASHEx_Exported_Functions_Group2 79 | * @{ 80 | */ 81 | HAL_StatusTypeDef HAL_FLASHEx_ConfigLVEPin(uint32_t ConfigLVE); 82 | /** 83 | * @} 84 | */ 85 | #endif /* FLASH_CFGR_LVEN */ 86 | 87 | /** 88 | * @} 89 | */ 90 | 91 | /* Private function ----------------------------------------------------------*/ 92 | /** @addtogroup FLASHEx_Private_Functions FLASHEx Private Functions 93 | * @{ 94 | */ 95 | void FLASH_PageErase(uint32_t Page, uint32_t Banks); 96 | void FLASH_FlushCaches(void); 97 | /** 98 | * @} 99 | */ 100 | 101 | /* Private macros ------------------------------------------------------------*/ 102 | /** 103 | @cond 0 104 | */ 105 | #if defined (FLASH_CFGR_LVEN) 106 | #define IS_FLASH_LVE_PIN(CFG) (((CFG) == FLASH_LVE_PIN_CTRL) || ((CFG) == FLASH_LVE_PIN_FORCED)) 107 | #endif /* FLASH_CFGR_LVEN */ 108 | /** 109 | @endcond 110 | */ 111 | 112 | /** 113 | * @} 114 | */ 115 | 116 | /** 117 | * @} 118 | */ 119 | 120 | #ifdef __cplusplus 121 | } 122 | #endif 123 | 124 | #endif /* STM32L4xx_HAL_FLASH_EX_H */ 125 | 126 | -------------------------------------------------------------------------------- /cdh-tsat-stm32project-board/Drivers/Hardware_Peripherals/Test/Inc/AS3001204_driver_test.h: -------------------------------------------------------------------------------- 1 | /* 2 | * FILENAME: AS3001204_driver_test.h 3 | * 4 | * DESCRIPTION: Unit test for the AS3001204-0054X0ISAY MRAM driver 5 | * (see AS3001204_driver.{c,h}) 6 | * 7 | * AUTHORS: 8 | * - Gabriel Young (gabriel.young@umsats.ca) 9 | * 10 | * Created on: Dec. 6, 2022 11 | */ 12 | 13 | #ifndef HARDWARE_PERIPHERALS_AS3001204_DRIVER_TEST_H_ 14 | #define HARDWARE_PERIPHERALS_AS3001204_DRIVER_TEST_H_ 15 | 16 | #include "stm32l4xx_hal.h" 17 | 18 | 19 | /* 20 | * Read ID registers test 21 | * 22 | * FUNCTIONS: AS3001204_Test_Read_ID_Registers 23 | * 24 | * DESCRIPTION: This function is a simple test that reads the (read-only) device ID and 25 | * unique ID registers of the AS3001204 MRAM unit, and compares their 26 | * contents to known values. 27 | * 28 | * RETURN: HAL_OK if successful; HAL_ERROR, HAL_BUSY, or HAL_TIMEOUT if not. 29 | */ 30 | HAL_StatusTypeDef AS3001204_Test_Read_ID_Registers(); 31 | 32 | /* 33 | * Read/write register tests 34 | * 35 | * FUNCTIONS: AS3001204_Test_RW_Status_Register, AS3001204_Test_RW_Config_Registers, 36 | * AS3001204_Test_RW_ASP_Register 37 | * 38 | * DESCRIPTION: These functions test the AS3001204 driver's ability to read and write to the 39 | * MRAM unit's status register, configuration registers, and augmented storage array 40 | * protection register, respectively. These functions only write valid data to the 41 | * registers - writing invalid bits to registers could cause undefined behaviour. 42 | * 43 | * RETURN: HAL_OK if successful; HAL_ERROR, HAL_BUSY, or HAL_TIMEOUT if not. 44 | */ 45 | HAL_StatusTypeDef AS3001204_Test_RW_Status_Register(); 46 | HAL_StatusTypeDef AS3001204_Test_RW_Config_Registers(); 47 | HAL_StatusTypeDef AS3001204_Test_RW_ASP_Register(); 48 | 49 | /* 50 | * Read/write memory tests 51 | * 52 | * FUNCTIONS: AS3001204_Test_RW_Memory, AS3001204_Test_RW_Augmented_Storage 53 | * 54 | * DESCRIPTION: These functions test the AS3001204 driver's ability to read and write the 55 | * main memory array, and the augmented storage section of memory. 56 | * 57 | * RETURN: HAL_OK if successful; HAL_ERROR, HAL_BUSY, or HAL_TIMEOUT if not. 58 | */ 59 | HAL_StatusTypeDef AS3001204_Test_RW_Memory(); 60 | HAL_StatusTypeDef AS3001204_Test_RW_Augmented_Storage(); 61 | 62 | /* 63 | * Write disable test 64 | * 65 | * FUNCTIONS: AS3001204_Test_Write_Disable 66 | * 67 | * DESCRIPTION: This function tests the write disable command by checking if data is 68 | * able to still be written to the AS3001204 after the write disable command 69 | * is sent. 70 | * 71 | * RETURN: HAL_OK if successful; HAL_ERROR, HAL_BUSY, or HAL_TIMEOUT if not. 72 | */ 73 | HAL_StatusTypeDef AS3001204_Test_Write_Disable(); 74 | 75 | /* 76 | * Enter/exit hibernate and deep power down tests 77 | * 78 | * FUNCTIONS: AS3001204_Test_Enter_Exit_Hibernate, AS3001204_Test_Enter_Exit_Deep_Power_Down 79 | * 80 | * DESCRIPTION: These functions test the AS3001204 driver's ability to enter and exit hibernate 81 | * and deep power down modes of operation. 82 | * 83 | * RETURN: HAL_OK if successful; HAL_ERROR, HAL_BUSY, or HAL_TIMEOUT if not. 84 | */ 85 | HAL_StatusTypeDef AS3001204_Test_Enter_Exit_Hibernate(); 86 | HAL_StatusTypeDef AS3001204_Test_Enter_Exit_Deep_Power_Down(); 87 | 88 | /* 89 | * Complete test suite 90 | * 91 | * FUNCTION: AS3001204_Test_MRAM_Driver 92 | * 93 | * DESCRIPTION: This function runs through the complete suite of unit tests available for 94 | * the MRAM driver. 95 | * 96 | * RETURN: HAL_OK if successful; HAL_ERROR, HAL_BUSY, or HAL_TIMEOUT if not. 97 | */ 98 | HAL_StatusTypeDef AS3001204_Test_MRAM_Driver(); 99 | 100 | 101 | #endif /* HARDWARE_PERIPHERALS_INC_AS3001204_DRIVER_TEST_H_ */ 102 | -------------------------------------------------------------------------------- /cdh-tsat-stm32project-nucleo/Drivers/Hardware_Peripherals/Test/Inc/AS3001204_driver_test.h: -------------------------------------------------------------------------------- 1 | /* 2 | * FILENAME: AS3001204_driver_test.h 3 | * 4 | * DESCRIPTION: Unit test for the AS3001204-0054X0ISAY MRAM driver 5 | * (see AS3001204_driver.{c,h}) 6 | * 7 | * AUTHORS: 8 | * - Gabriel Young (gabriel.young@umsats.ca) 9 | * 10 | * Created on: Dec. 6, 2022 11 | */ 12 | 13 | #ifndef HARDWARE_PERIPHERALS_AS3001204_DRIVER_TEST_H_ 14 | #define HARDWARE_PERIPHERALS_AS3001204_DRIVER_TEST_H_ 15 | 16 | #include "stm32l4xx_hal.h" 17 | 18 | 19 | /* 20 | * Read ID registers test 21 | * 22 | * FUNCTIONS: AS3001204_Test_Read_ID_Registers 23 | * 24 | * DESCRIPTION: This function is a simple test that reads the (read-only) device ID and 25 | * unique ID registers of the AS3001204 MRAM unit, and compares their 26 | * contents to known values. 27 | * 28 | * RETURN: HAL_OK if successful; HAL_ERROR, HAL_BUSY, or HAL_TIMEOUT if not. 29 | */ 30 | HAL_StatusTypeDef AS3001204_Test_Read_ID_Registers(); 31 | 32 | /* 33 | * Read/write register tests 34 | * 35 | * FUNCTIONS: AS3001204_Test_RW_Status_Register, AS3001204_Test_RW_Config_Registers, 36 | * AS3001204_Test_RW_ASP_Register 37 | * 38 | * DESCRIPTION: These functions test the AS3001204 driver's ability to read and write to the 39 | * MRAM unit's status register, configuration registers, and augmented storage array 40 | * protection register, respectively. These functions only write valid data to the 41 | * registers - writing invalid bits to registers could cause undefined behaviour. 42 | * 43 | * RETURN: HAL_OK if successful; HAL_ERROR, HAL_BUSY, or HAL_TIMEOUT if not. 44 | */ 45 | HAL_StatusTypeDef AS3001204_Test_RW_Status_Register(); 46 | HAL_StatusTypeDef AS3001204_Test_RW_Config_Registers(); 47 | HAL_StatusTypeDef AS3001204_Test_RW_ASP_Register(); 48 | 49 | /* 50 | * Read/write memory tests 51 | * 52 | * FUNCTIONS: AS3001204_Test_RW_Memory, AS3001204_Test_RW_Augmented_Storage 53 | * 54 | * DESCRIPTION: These functions test the AS3001204 driver's ability to read and write the 55 | * main memory array, and the augmented storage section of memory. 56 | * 57 | * RETURN: HAL_OK if successful; HAL_ERROR, HAL_BUSY, or HAL_TIMEOUT if not. 58 | */ 59 | HAL_StatusTypeDef AS3001204_Test_RW_Memory(); 60 | HAL_StatusTypeDef AS3001204_Test_RW_Augmented_Storage(); 61 | 62 | /* 63 | * Write disable test 64 | * 65 | * FUNCTIONS: AS3001204_Test_Write_Disable 66 | * 67 | * DESCRIPTION: This function tests the write disable command by checking if data is 68 | * able to still be written to the AS3001204 after the write disable command 69 | * is sent. 70 | * 71 | * RETURN: HAL_OK if successful; HAL_ERROR, HAL_BUSY, or HAL_TIMEOUT if not. 72 | */ 73 | HAL_StatusTypeDef AS3001204_Test_Write_Disable(); 74 | 75 | /* 76 | * Enter/exit hibernate and deep power down tests 77 | * 78 | * FUNCTIONS: AS3001204_Test_Enter_Exit_Hibernate, AS3001204_Test_Enter_Exit_Deep_Power_Down 79 | * 80 | * DESCRIPTION: These functions test the AS3001204 driver's ability to enter and exit hibernate 81 | * and deep power down modes of operation. 82 | * 83 | * RETURN: HAL_OK if successful; HAL_ERROR, HAL_BUSY, or HAL_TIMEOUT if not. 84 | */ 85 | HAL_StatusTypeDef AS3001204_Test_Enter_Exit_Hibernate(); 86 | HAL_StatusTypeDef AS3001204_Test_Enter_Exit_Deep_Power_Down(); 87 | 88 | /* 89 | * Complete test suite 90 | * 91 | * FUNCTION: AS3001204_Test_MRAM_Driver 92 | * 93 | * DESCRIPTION: This function runs through the complete suite of unit tests available for 94 | * the MRAM driver. 95 | * 96 | * RETURN: HAL_OK if successful; HAL_ERROR, HAL_BUSY, or HAL_TIMEOUT if not. 97 | */ 98 | HAL_StatusTypeDef AS3001204_Test_MRAM_Driver(); 99 | 100 | 101 | #endif /* HARDWARE_PERIPHERALS_INC_AS3001204_DRIVER_TEST_H_ */ 102 | -------------------------------------------------------------------------------- /cdh-tsat-stm32project-board/Core/Inc/main.h: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file : main.h 5 | * @brief : Header for main.c file. 6 | * This file contains the common defines of the application. 7 | ****************************************************************************** 8 | * @attention 9 | * 10 | * Copyright (c) 2024 STMicroelectronics. 11 | * All rights reserved. 12 | * 13 | * This software is licensed under terms that can be found in the LICENSE file 14 | * in the root directory of this software component. 15 | * If no LICENSE file comes with this software, it is provided AS-IS. 16 | * 17 | ****************************************************************************** 18 | */ 19 | /* USER CODE END Header */ 20 | 21 | /* Define to prevent recursive inclusion -------------------------------------*/ 22 | #ifndef __MAIN_H 23 | #define __MAIN_H 24 | 25 | #ifdef __cplusplus 26 | extern "C" { 27 | #endif 28 | 29 | /* Includes ------------------------------------------------------------------*/ 30 | #include "stm32l4xx_hal.h" 31 | 32 | /* Private includes ----------------------------------------------------------*/ 33 | /* USER CODE BEGIN Includes */ 34 | 35 | /* USER CODE END Includes */ 36 | 37 | /* Exported types ------------------------------------------------------------*/ 38 | /* USER CODE BEGIN ET */ 39 | 40 | /* USER CODE END ET */ 41 | 42 | /* Exported constants --------------------------------------------------------*/ 43 | /* USER CODE BEGIN EC */ 44 | 45 | /* USER CODE END EC */ 46 | 47 | /* Exported macro ------------------------------------------------------------*/ 48 | /* USER CODE BEGIN EM */ 49 | 50 | /* USER CODE END EM */ 51 | 52 | /* Exported functions prototypes ---------------------------------------------*/ 53 | void Error_Handler(void); 54 | 55 | /* USER CODE BEGIN EFP */ 56 | 57 | /* USER CODE END EFP */ 58 | 59 | /* Private defines -----------------------------------------------------------*/ 60 | #define RELEASE_nEN_Pin GPIO_PIN_1 61 | #define RELEASE_nEN_GPIO_Port GPIOA 62 | #define RELEASE_Pin GPIO_PIN_2 63 | #define RELEASE_GPIO_Port GPIOA 64 | #define CDH_TEMP_Pin GPIO_PIN_3 65 | #define CDH_TEMP_GPIO_Port GPIOA 66 | #define SPI1_SDI_Pin GPIO_PIN_6 67 | #define SPI1_SDI_GPIO_Port GPIOA 68 | #define SPI1_SDO_Pin GPIO_PIN_7 69 | #define SPI1_SDO_GPIO_Port GPIOA 70 | #define UHF_nCS_Pin GPIO_PIN_4 71 | #define UHF_nCS_GPIO_Port GPIOC 72 | #define UHF_nIRQ_Pin GPIO_PIN_5 73 | #define UHF_nIRQ_GPIO_Port GPIOC 74 | #define UHF_SDN_Pin GPIO_PIN_0 75 | #define UHF_SDN_GPIO_Port GPIOB 76 | #define COMM_TEMP_Pin GPIO_PIN_1 77 | #define COMM_TEMP_GPIO_Port GPIOB 78 | #define LED1_Pin GPIO_PIN_2 79 | #define LED1_GPIO_Port GPIOB 80 | #define LED2_Pin GPIO_PIN_10 81 | #define LED2_GPIO_Port GPIOB 82 | #define LED3_Pin GPIO_PIN_11 83 | #define LED3_GPIO_Port GPIOB 84 | #define FLASH_nWP_Pin GPIO_PIN_12 85 | #define FLASH_nWP_GPIO_Port GPIOB 86 | #define SPI2_SDI_Pin GPIO_PIN_14 87 | #define SPI2_SDI_GPIO_Port GPIOB 88 | #define SPI2_SDO_Pin GPIO_PIN_15 89 | #define SPI2_SDO_GPIO_Port GPIOB 90 | #define FLASH_nCS_Pin GPIO_PIN_6 91 | #define FLASH_nCS_GPIO_Port GPIOC 92 | #define FLASH_nHOLD_Pin GPIO_PIN_7 93 | #define FLASH_nHOLD_GPIO_Port GPIOC 94 | #define MRAM_nWP_Pin GPIO_PIN_15 95 | #define MRAM_nWP_GPIO_Port GPIOA 96 | #define SPI3_SDI_Pin GPIO_PIN_11 97 | #define SPI3_SDI_GPIO_Port GPIOC 98 | #define SPI3_SDO_Pin GPIO_PIN_12 99 | #define SPI3_SDO_GPIO_Port GPIOC 100 | #define MRAM_nCS_Pin GPIO_PIN_2 101 | #define MRAM_nCS_GPIO_Port GPIOD 102 | #define WDI_Pin GPIO_PIN_6 103 | #define WDI_GPIO_Port GPIOB 104 | #define M_nRESET_Pin GPIO_PIN_7 105 | #define M_nRESET_GPIO_Port GPIOB 106 | 107 | /* USER CODE BEGIN Private defines */ 108 | 109 | /* USER CODE END Private defines */ 110 | 111 | #ifdef __cplusplus 112 | } 113 | #endif 114 | 115 | #endif /* __MAIN_H */ 116 | -------------------------------------------------------------------------------- /cdh-tsat-stm32project-nucleo/Core/Inc/main.h: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file : main.h 5 | * @brief : Header for main.c file. 6 | * This file contains the common defines of the application. 7 | ****************************************************************************** 8 | * @attention 9 | * 10 | * Copyright (c) 2024 STMicroelectronics. 11 | * All rights reserved. 12 | * 13 | * This software is licensed under terms that can be found in the LICENSE file 14 | * in the root directory of this software component. 15 | * If no LICENSE file comes with this software, it is provided AS-IS. 16 | * 17 | ****************************************************************************** 18 | */ 19 | /* USER CODE END Header */ 20 | 21 | /* Define to prevent recursive inclusion -------------------------------------*/ 22 | #ifndef __MAIN_H 23 | #define __MAIN_H 24 | 25 | #ifdef __cplusplus 26 | extern "C" { 27 | #endif 28 | 29 | /* Includes ------------------------------------------------------------------*/ 30 | #include "stm32l4xx_hal.h" 31 | 32 | /* Private includes ----------------------------------------------------------*/ 33 | /* USER CODE BEGIN Includes */ 34 | 35 | /* USER CODE END Includes */ 36 | 37 | /* Exported types ------------------------------------------------------------*/ 38 | /* USER CODE BEGIN ET */ 39 | 40 | /* USER CODE END ET */ 41 | 42 | /* Exported constants --------------------------------------------------------*/ 43 | /* USER CODE BEGIN EC */ 44 | 45 | /* USER CODE END EC */ 46 | 47 | /* Exported macro ------------------------------------------------------------*/ 48 | /* USER CODE BEGIN EM */ 49 | 50 | /* USER CODE END EM */ 51 | 52 | /* Exported functions prototypes ---------------------------------------------*/ 53 | void Error_Handler(void); 54 | 55 | /* USER CODE BEGIN EFP */ 56 | 57 | /* USER CODE END EFP */ 58 | 59 | /* Private defines -----------------------------------------------------------*/ 60 | #define B1_Pin GPIO_PIN_13 61 | #define B1_GPIO_Port GPIOC 62 | #define CAM_TX_Pin GPIO_PIN_0 63 | #define CAM_TX_GPIO_Port GPIOA 64 | #define USART_TX_Pin GPIO_PIN_2 65 | #define USART_TX_GPIO_Port GPIOA 66 | #define USART_RX_Pin GPIO_PIN_3 67 | #define USART_RX_GPIO_Port GPIOA 68 | #define LD4_Pin GPIO_PIN_5 69 | #define LD4_GPIO_Port GPIOA 70 | #define RELEASE_Pin GPIO_PIN_5 71 | #define RELEASE_GPIO_Port GPIOC 72 | #define RELEASE_nEN_Pin GPIO_PIN_0 73 | #define RELEASE_nEN_GPIO_Port GPIOB 74 | #define UHF_nIRQ_Pin GPIO_PIN_1 75 | #define UHF_nIRQ_GPIO_Port GPIOB 76 | #define UHF_nCS_Pin GPIO_PIN_2 77 | #define UHF_nCS_GPIO_Port GPIOB 78 | #define UHF_SDN_Pin GPIO_PIN_11 79 | #define UHF_SDN_GPIO_Port GPIOB 80 | #define FLASH_nCS_Pin GPIO_PIN_15 81 | #define FLASH_nCS_GPIO_Port GPIOB 82 | #define FLASH_nWP_Pin GPIO_PIN_6 83 | #define FLASH_nWP_GPIO_Port GPIOC 84 | #define FLASH_nHOLD_Pin GPIO_PIN_7 85 | #define FLASH_nHOLD_GPIO_Port GPIOC 86 | #define MRAM_nCS_Pin GPIO_PIN_8 87 | #define MRAM_nCS_GPIO_Port GPIOC 88 | #define MRAM_nWP_Pin GPIO_PIN_9 89 | #define MRAM_nWP_GPIO_Port GPIOC 90 | #define CAM_FSH_Pin GPIO_PIN_9 91 | #define CAM_FSH_GPIO_Port GPIOA 92 | #define CAM_ON_Pin GPIO_PIN_10 93 | #define CAM_ON_GPIO_Port GPIOA 94 | #define WDI_Pin GPIO_PIN_11 95 | #define WDI_GPIO_Port GPIOA 96 | #define M_nRESET_Pin GPIO_PIN_12 97 | #define M_nRESET_GPIO_Port GPIOA 98 | #define TMS_Pin GPIO_PIN_13 99 | #define TMS_GPIO_Port GPIOA 100 | #define TCK_Pin GPIO_PIN_14 101 | #define TCK_GPIO_Port GPIOA 102 | #define CAM_RX_Pin GPIO_PIN_11 103 | #define CAM_RX_GPIO_Port GPIOC 104 | #define SWO_Pin GPIO_PIN_3 105 | #define SWO_GPIO_Port GPIOB 106 | #define LED3_Pin GPIO_PIN_5 107 | #define LED3_GPIO_Port GPIOB 108 | #define LED2_Pin GPIO_PIN_6 109 | #define LED2_GPIO_Port GPIOB 110 | #define LED1_Pin GPIO_PIN_7 111 | #define LED1_GPIO_Port GPIOB 112 | 113 | /* USER CODE BEGIN Private defines */ 114 | 115 | /* USER CODE END Private defines */ 116 | 117 | #ifdef __cplusplus 118 | } 119 | #endif 120 | 121 | #endif /* __MAIN_H */ 122 | -------------------------------------------------------------------------------- /cdh-tsat-stm32project-board/Core/Src/stm32l4xx_hal_timebase_tim.c: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file stm32l4xx_hal_timebase_tim.c 5 | * @brief HAL time base based on the hardware TIM. 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | * Copyright (c) 2024 STMicroelectronics. 10 | * All rights reserved. 11 | * 12 | * This software is licensed under terms that can be found in the LICENSE file 13 | * in the root directory of this software component. 14 | * If no LICENSE file comes with this software, it is provided AS-IS. 15 | * 16 | ****************************************************************************** 17 | */ 18 | /* USER CODE END Header */ 19 | 20 | /* Includes ------------------------------------------------------------------*/ 21 | #include "stm32l4xx_hal.h" 22 | #include "stm32l4xx_hal_tim.h" 23 | 24 | /* Private typedef -----------------------------------------------------------*/ 25 | /* Private define ------------------------------------------------------------*/ 26 | /* Private macro -------------------------------------------------------------*/ 27 | /* Private variables ---------------------------------------------------------*/ 28 | TIM_HandleTypeDef htim6; 29 | /* Private function prototypes -----------------------------------------------*/ 30 | /* Private functions ---------------------------------------------------------*/ 31 | 32 | /** 33 | * @brief This function configures the TIM6 as a time base source. 34 | * The time source is configured to have 1ms time base with a dedicated 35 | * Tick interrupt priority. 36 | * @note This function is called automatically at the beginning of program after 37 | * reset by HAL_Init() or at any time when clock is configured, by HAL_RCC_ClockConfig(). 38 | * @param TickPriority: Tick interrupt priority. 39 | * @retval HAL status 40 | */ 41 | HAL_StatusTypeDef HAL_InitTick(uint32_t TickPriority) 42 | { 43 | RCC_ClkInitTypeDef clkconfig; 44 | uint32_t uwTimclock, uwAPB1Prescaler; 45 | 46 | uint32_t uwPrescalerValue; 47 | uint32_t pFLatency; 48 | HAL_StatusTypeDef status = HAL_OK; 49 | 50 | /* Enable TIM6 clock */ 51 | __HAL_RCC_TIM6_CLK_ENABLE(); 52 | 53 | /* Get clock configuration */ 54 | HAL_RCC_GetClockConfig(&clkconfig, &pFLatency); 55 | 56 | /* Get APB1 prescaler */ 57 | uwAPB1Prescaler = clkconfig.APB1CLKDivider; 58 | /* Compute TIM6 clock */ 59 | if (uwAPB1Prescaler == RCC_HCLK_DIV1) 60 | { 61 | uwTimclock = HAL_RCC_GetPCLK1Freq(); 62 | } 63 | else 64 | { 65 | uwTimclock = 2UL * HAL_RCC_GetPCLK1Freq(); 66 | } 67 | 68 | /* Compute the prescaler value to have TIM6 counter clock equal to 1MHz */ 69 | uwPrescalerValue = (uint32_t) ((uwTimclock / 1000000U) - 1U); 70 | 71 | /* Initialize TIM6 */ 72 | htim6.Instance = TIM6; 73 | 74 | /* Initialize TIMx peripheral as follow: 75 | 76 | + Period = [(TIM6CLK/1000) - 1]. to have a (1/1000) s time base. 77 | + Prescaler = (uwTimclock/1000000 - 1) to have a 1MHz counter clock. 78 | + ClockDivision = 0 79 | + Counter direction = Up 80 | */ 81 | htim6.Init.Period = (1000000U / 1000U) - 1U; 82 | htim6.Init.Prescaler = uwPrescalerValue; 83 | htim6.Init.ClockDivision = 0; 84 | htim6.Init.CounterMode = TIM_COUNTERMODE_UP; 85 | htim6.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE; 86 | 87 | status = HAL_TIM_Base_Init(&htim6); 88 | if (status == HAL_OK) 89 | { 90 | /* Start the TIM time Base generation in interrupt mode */ 91 | status = HAL_TIM_Base_Start_IT(&htim6); 92 | if (status == HAL_OK) 93 | { 94 | /* Enable the TIM6 global Interrupt */ 95 | HAL_NVIC_EnableIRQ(TIM6_DAC_IRQn); 96 | /* Configure the SysTick IRQ priority */ 97 | if (TickPriority < (1UL << __NVIC_PRIO_BITS)) 98 | { 99 | /* Configure the TIM IRQ priority */ 100 | HAL_NVIC_SetPriority(TIM6_DAC_IRQn, TickPriority, 0U); 101 | uwTickPrio = TickPriority; 102 | } 103 | else 104 | { 105 | status = HAL_ERROR; 106 | } 107 | } 108 | } 109 | 110 | /* Return function status */ 111 | return status; 112 | } 113 | 114 | /** 115 | * @brief Suspend Tick increment. 116 | * @note Disable the tick increment by disabling TIM6 update interrupt. 117 | * @param None 118 | * @retval None 119 | */ 120 | void HAL_SuspendTick(void) 121 | { 122 | /* Disable TIM6 update Interrupt */ 123 | __HAL_TIM_DISABLE_IT(&htim6, TIM_IT_UPDATE); 124 | } 125 | 126 | /** 127 | * @brief Resume Tick increment. 128 | * @note Enable the tick increment by Enabling TIM6 update interrupt. 129 | * @param None 130 | * @retval None 131 | */ 132 | void HAL_ResumeTick(void) 133 | { 134 | /* Enable TIM6 Update interrupt */ 135 | __HAL_TIM_ENABLE_IT(&htim6, TIM_IT_UPDATE); 136 | } 137 | 138 | -------------------------------------------------------------------------------- /cdh-tsat-stm32project-nucleo/Core/Src/stm32l4xx_hal_timebase_tim.c: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file stm32l4xx_hal_timebase_tim.c 5 | * @brief HAL time base based on the hardware TIM. 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | * Copyright (c) 2025 STMicroelectronics. 10 | * All rights reserved. 11 | * 12 | * This software is licensed under terms that can be found in the LICENSE file 13 | * in the root directory of this software component. 14 | * If no LICENSE file comes with this software, it is provided AS-IS. 15 | * 16 | ****************************************************************************** 17 | */ 18 | /* USER CODE END Header */ 19 | 20 | /* Includes ------------------------------------------------------------------*/ 21 | #include "stm32l4xx_hal.h" 22 | #include "stm32l4xx_hal_tim.h" 23 | 24 | /* Private typedef -----------------------------------------------------------*/ 25 | /* Private define ------------------------------------------------------------*/ 26 | /* Private macro -------------------------------------------------------------*/ 27 | /* Private variables ---------------------------------------------------------*/ 28 | TIM_HandleTypeDef htim6; 29 | /* Private function prototypes -----------------------------------------------*/ 30 | /* Private functions ---------------------------------------------------------*/ 31 | 32 | /** 33 | * @brief This function configures the TIM6 as a time base source. 34 | * The time source is configured to have 1ms time base with a dedicated 35 | * Tick interrupt priority. 36 | * @note This function is called automatically at the beginning of program after 37 | * reset by HAL_Init() or at any time when clock is configured, by HAL_RCC_ClockConfig(). 38 | * @param TickPriority: Tick interrupt priority. 39 | * @retval HAL status 40 | */ 41 | HAL_StatusTypeDef HAL_InitTick(uint32_t TickPriority) 42 | { 43 | RCC_ClkInitTypeDef clkconfig; 44 | uint32_t uwTimclock, uwAPB1Prescaler; 45 | 46 | uint32_t uwPrescalerValue; 47 | uint32_t pFLatency; 48 | HAL_StatusTypeDef status = HAL_OK; 49 | 50 | /* Enable TIM6 clock */ 51 | __HAL_RCC_TIM6_CLK_ENABLE(); 52 | 53 | /* Get clock configuration */ 54 | HAL_RCC_GetClockConfig(&clkconfig, &pFLatency); 55 | 56 | /* Get APB1 prescaler */ 57 | uwAPB1Prescaler = clkconfig.APB1CLKDivider; 58 | /* Compute TIM6 clock */ 59 | if (uwAPB1Prescaler == RCC_HCLK_DIV1) 60 | { 61 | uwTimclock = HAL_RCC_GetPCLK1Freq(); 62 | } 63 | else 64 | { 65 | uwTimclock = 2UL * HAL_RCC_GetPCLK1Freq(); 66 | } 67 | 68 | /* Compute the prescaler value to have TIM6 counter clock equal to 1MHz */ 69 | uwPrescalerValue = (uint32_t) ((uwTimclock / 1000000U) - 1U); 70 | 71 | /* Initialize TIM6 */ 72 | htim6.Instance = TIM6; 73 | 74 | /* Initialize TIMx peripheral as follow: 75 | 76 | + Period = [(TIM6CLK/1000) - 1]. to have a (1/1000) s time base. 77 | + Prescaler = (uwTimclock/1000000 - 1) to have a 1MHz counter clock. 78 | + ClockDivision = 0 79 | + Counter direction = Up 80 | */ 81 | htim6.Init.Period = (1000000U / 1000U) - 1U; 82 | htim6.Init.Prescaler = uwPrescalerValue; 83 | htim6.Init.ClockDivision = 0; 84 | htim6.Init.CounterMode = TIM_COUNTERMODE_UP; 85 | htim6.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE; 86 | 87 | status = HAL_TIM_Base_Init(&htim6); 88 | if (status == HAL_OK) 89 | { 90 | /* Start the TIM time Base generation in interrupt mode */ 91 | status = HAL_TIM_Base_Start_IT(&htim6); 92 | if (status == HAL_OK) 93 | { 94 | /* Enable the TIM6 global Interrupt */ 95 | HAL_NVIC_EnableIRQ(TIM6_DAC_IRQn); 96 | /* Configure the SysTick IRQ priority */ 97 | if (TickPriority < (1UL << __NVIC_PRIO_BITS)) 98 | { 99 | /* Configure the TIM IRQ priority */ 100 | HAL_NVIC_SetPriority(TIM6_DAC_IRQn, TickPriority, 0U); 101 | uwTickPrio = TickPriority; 102 | } 103 | else 104 | { 105 | status = HAL_ERROR; 106 | } 107 | } 108 | } 109 | 110 | /* Return function status */ 111 | return status; 112 | } 113 | 114 | /** 115 | * @brief Suspend Tick increment. 116 | * @note Disable the tick increment by disabling TIM6 update interrupt. 117 | * @param None 118 | * @retval None 119 | */ 120 | void HAL_SuspendTick(void) 121 | { 122 | /* Disable TIM6 update Interrupt */ 123 | __HAL_TIM_DISABLE_IT(&htim6, TIM_IT_UPDATE); 124 | } 125 | 126 | /** 127 | * @brief Resume Tick increment. 128 | * @note Enable the tick increment by Enabling TIM6 update interrupt. 129 | * @param None 130 | * @retval None 131 | */ 132 | void HAL_ResumeTick(void) 133 | { 134 | /* Enable TIM6 Update interrupt */ 135 | __HAL_TIM_ENABLE_IT(&htim6, TIM_IT_UPDATE); 136 | } 137 | 138 | -------------------------------------------------------------------------------- /cdh-tsat-stm32project-board/Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_hal_crc_ex.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32l4xx_hal_crc_ex.h 4 | * @author MCD Application Team 5 | * @brief Header file of CRC HAL extended module. 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | * Copyright (c) 2017 STMicroelectronics. 10 | * All rights reserved. 11 | * 12 | * This software is licensed under terms that can be found in the LICENSE file 13 | * in the root directory of this software component. 14 | * If no LICENSE file comes with this software, it is provided AS-IS. 15 | * 16 | ****************************************************************************** 17 | */ 18 | 19 | /* Define to prevent recursive inclusion -------------------------------------*/ 20 | #ifndef STM32L4xx_HAL_CRC_EX_H 21 | #define STM32L4xx_HAL_CRC_EX_H 22 | 23 | #ifdef __cplusplus 24 | extern "C" { 25 | #endif 26 | 27 | /* Includes ------------------------------------------------------------------*/ 28 | #include "stm32l4xx_hal_def.h" 29 | 30 | /** @addtogroup STM32L4xx_HAL_Driver 31 | * @{ 32 | */ 33 | 34 | /** @addtogroup CRCEx 35 | * @{ 36 | */ 37 | 38 | /* Exported types ------------------------------------------------------------*/ 39 | /* Exported constants --------------------------------------------------------*/ 40 | /** @defgroup CRCEx_Exported_Constants CRC Extended Exported Constants 41 | * @{ 42 | */ 43 | 44 | /** @defgroup CRCEx_Input_Data_Inversion Input Data Inversion Modes 45 | * @{ 46 | */ 47 | #define CRC_INPUTDATA_INVERSION_NONE 0x00000000U /*!< No input data inversion */ 48 | #define CRC_INPUTDATA_INVERSION_BYTE CRC_CR_REV_IN_0 /*!< Byte-wise input data inversion */ 49 | #define CRC_INPUTDATA_INVERSION_HALFWORD CRC_CR_REV_IN_1 /*!< HalfWord-wise input data inversion */ 50 | #define CRC_INPUTDATA_INVERSION_WORD CRC_CR_REV_IN /*!< Word-wise input data inversion */ 51 | /** 52 | * @} 53 | */ 54 | 55 | /** @defgroup CRCEx_Output_Data_Inversion Output Data Inversion Modes 56 | * @{ 57 | */ 58 | #define CRC_OUTPUTDATA_INVERSION_DISABLE 0x00000000U /*!< No output data inversion */ 59 | #define CRC_OUTPUTDATA_INVERSION_ENABLE CRC_CR_REV_OUT /*!< Bit-wise output data inversion */ 60 | /** 61 | * @} 62 | */ 63 | 64 | /** 65 | * @} 66 | */ 67 | 68 | /* Exported macro ------------------------------------------------------------*/ 69 | /** @defgroup CRCEx_Exported_Macros CRC Extended Exported Macros 70 | * @{ 71 | */ 72 | 73 | /** 74 | * @brief Set CRC output reversal 75 | * @param __HANDLE__ CRC handle 76 | * @retval None 77 | */ 78 | #define __HAL_CRC_OUTPUTREVERSAL_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR |= CRC_CR_REV_OUT) 79 | 80 | /** 81 | * @brief Unset CRC output reversal 82 | * @param __HANDLE__ CRC handle 83 | * @retval None 84 | */ 85 | #define __HAL_CRC_OUTPUTREVERSAL_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR &= ~(CRC_CR_REV_OUT)) 86 | 87 | /** 88 | * @brief Set CRC non-default polynomial 89 | * @param __HANDLE__ CRC handle 90 | * @param __POLYNOMIAL__ 7, 8, 16 or 32-bit polynomial 91 | * @retval None 92 | */ 93 | #define __HAL_CRC_POLYNOMIAL_CONFIG(__HANDLE__, __POLYNOMIAL__) ((__HANDLE__)->Instance->POL = (__POLYNOMIAL__)) 94 | 95 | /** 96 | * @} 97 | */ 98 | 99 | /* Private macros --------------------------------------------------------*/ 100 | /** @defgroup CRCEx_Private_Macros CRC Extended Private Macros 101 | * @{ 102 | */ 103 | 104 | #define IS_CRC_INPUTDATA_INVERSION_MODE(MODE) (((MODE) == CRC_INPUTDATA_INVERSION_NONE) || \ 105 | ((MODE) == CRC_INPUTDATA_INVERSION_BYTE) || \ 106 | ((MODE) == CRC_INPUTDATA_INVERSION_HALFWORD) || \ 107 | ((MODE) == CRC_INPUTDATA_INVERSION_WORD)) 108 | 109 | #define IS_CRC_OUTPUTDATA_INVERSION_MODE(MODE) (((MODE) == CRC_OUTPUTDATA_INVERSION_DISABLE) || \ 110 | ((MODE) == CRC_OUTPUTDATA_INVERSION_ENABLE)) 111 | 112 | /** 113 | * @} 114 | */ 115 | 116 | /* Exported functions --------------------------------------------------------*/ 117 | 118 | /** @addtogroup CRCEx_Exported_Functions 119 | * @{ 120 | */ 121 | 122 | /** @addtogroup CRCEx_Exported_Functions_Group1 123 | * @{ 124 | */ 125 | /* Initialization and de-initialization functions ****************************/ 126 | HAL_StatusTypeDef HAL_CRCEx_Polynomial_Set(CRC_HandleTypeDef *hcrc, uint32_t Pol, uint32_t PolyLength); 127 | HAL_StatusTypeDef HAL_CRCEx_Input_Data_Reverse(CRC_HandleTypeDef *hcrc, uint32_t InputReverseMode); 128 | HAL_StatusTypeDef HAL_CRCEx_Output_Data_Reverse(CRC_HandleTypeDef *hcrc, uint32_t OutputReverseMode); 129 | 130 | /** 131 | * @} 132 | */ 133 | 134 | /** 135 | * @} 136 | */ 137 | 138 | /** 139 | * @} 140 | */ 141 | 142 | /** 143 | * @} 144 | */ 145 | 146 | #ifdef __cplusplus 147 | } 148 | #endif 149 | 150 | #endif /* STM32L4xx_HAL_CRC_EX_H */ 151 | -------------------------------------------------------------------------------- /cdh-tsat-stm32project-board/STM32L496RGTX_RAM.ld: -------------------------------------------------------------------------------- 1 | /* 2 | ****************************************************************************** 3 | ** 4 | ** @file : LinkerScript.ld (debug in RAM dedicated) 5 | ** 6 | ** @author : Auto-generated by STM32CubeIDE 7 | ** 8 | ** @brief : Linker script for STM32L496RGTx Device from STM32L4 series 9 | ** 1024KBytes FLASH 10 | ** 320KBytes RAM 11 | ** 64KBytes RAM2 12 | ** 13 | ** Set heap size, stack size and stack location according 14 | ** to application requirements. 15 | ** 16 | ** Set memory bank area and size if external memory is used 17 | ** 18 | ** Target : STMicroelectronics STM32 19 | ** 20 | ** Distribution: The file is distributed as is, without any warranty 21 | ** of any kind. 22 | ** 23 | ****************************************************************************** 24 | ** @attention 25 | ** 26 | ** Copyright (c) 2024 STMicroelectronics. 27 | ** All rights reserved. 28 | ** 29 | ** This software is licensed under terms that can be found in the LICENSE file 30 | ** in the root directory of this software component. 31 | ** If no LICENSE file comes with this software, it is provided AS-IS. 32 | ** 33 | ****************************************************************************** 34 | */ 35 | 36 | /* Entry Point */ 37 | ENTRY(Reset_Handler) 38 | 39 | /* Highest address of the user mode stack */ 40 | _estack = ORIGIN(RAM) + LENGTH(RAM); /* end of "RAM" Ram type memory */ 41 | 42 | _Min_Heap_Size = 0x200; /* required amount of heap */ 43 | _Min_Stack_Size = 0x400; /* required amount of stack */ 44 | 45 | /* Memories definition */ 46 | MEMORY 47 | { 48 | RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 320K 49 | RAM2 (xrw) : ORIGIN = 0x10000000, LENGTH = 64K 50 | FLASH (rx) : ORIGIN = 0x8000000, LENGTH = 1024K 51 | } 52 | 53 | /* Sections */ 54 | SECTIONS 55 | { 56 | /* The startup code into "RAM" Ram type memory */ 57 | .isr_vector : 58 | { 59 | . = ALIGN(4); 60 | KEEP(*(.isr_vector)) /* Startup code */ 61 | . = ALIGN(4); 62 | } >RAM 63 | 64 | /* The program code and other data into "RAM" Ram type memory */ 65 | .text : 66 | { 67 | . = ALIGN(4); 68 | *(.text) /* .text sections (code) */ 69 | *(.text*) /* .text* sections (code) */ 70 | *(.glue_7) /* glue arm to thumb code */ 71 | *(.glue_7t) /* glue thumb to arm code */ 72 | *(.eh_frame) 73 | *(.RamFunc) /* .RamFunc sections */ 74 | *(.RamFunc*) /* .RamFunc* sections */ 75 | 76 | KEEP (*(.init)) 77 | KEEP (*(.fini)) 78 | 79 | . = ALIGN(4); 80 | _etext = .; /* define a global symbols at end of code */ 81 | } >RAM 82 | 83 | /* Constant data into "RAM" Ram type memory */ 84 | .rodata : 85 | { 86 | . = ALIGN(4); 87 | *(.rodata) /* .rodata sections (constants, strings, etc.) */ 88 | *(.rodata*) /* .rodata* sections (constants, strings, etc.) */ 89 | . = ALIGN(4); 90 | } >RAM 91 | 92 | .ARM.extab : { 93 | . = ALIGN(4); 94 | *(.ARM.extab* .gnu.linkonce.armextab.*) 95 | . = ALIGN(4); 96 | } >RAM 97 | 98 | .ARM : { 99 | . = ALIGN(4); 100 | __exidx_start = .; 101 | *(.ARM.exidx*) 102 | __exidx_end = .; 103 | . = ALIGN(4); 104 | } >RAM 105 | 106 | .preinit_array : 107 | { 108 | . = ALIGN(4); 109 | PROVIDE_HIDDEN (__preinit_array_start = .); 110 | KEEP (*(.preinit_array*)) 111 | PROVIDE_HIDDEN (__preinit_array_end = .); 112 | . = ALIGN(4); 113 | } >RAM 114 | 115 | .init_array : 116 | { 117 | . = ALIGN(4); 118 | PROVIDE_HIDDEN (__init_array_start = .); 119 | KEEP (*(SORT(.init_array.*))) 120 | KEEP (*(.init_array*)) 121 | PROVIDE_HIDDEN (__init_array_end = .); 122 | . = ALIGN(4); 123 | } >RAM 124 | 125 | .fini_array : 126 | { 127 | . = ALIGN(4); 128 | PROVIDE_HIDDEN (__fini_array_start = .); 129 | KEEP (*(SORT(.fini_array.*))) 130 | KEEP (*(.fini_array*)) 131 | PROVIDE_HIDDEN (__fini_array_end = .); 132 | . = ALIGN(4); 133 | } >RAM 134 | 135 | /* Used by the startup to initialize data */ 136 | _sidata = LOADADDR(.data); 137 | 138 | /* Initialized data sections into "RAM" Ram type memory */ 139 | .data : 140 | { 141 | . = ALIGN(4); 142 | _sdata = .; /* create a global symbol at data start */ 143 | *(.data) /* .data sections */ 144 | *(.data*) /* .data* sections */ 145 | 146 | . = ALIGN(4); 147 | _edata = .; /* define a global symbol at data end */ 148 | 149 | } >RAM 150 | 151 | /* Uninitialized data section into "RAM" Ram type memory */ 152 | . = ALIGN(4); 153 | .bss : 154 | { 155 | /* This is used by the startup in order to initialize the .bss section */ 156 | _sbss = .; /* define a global symbol at bss start */ 157 | __bss_start__ = _sbss; 158 | *(.bss) 159 | *(.bss*) 160 | *(COMMON) 161 | 162 | . = ALIGN(4); 163 | _ebss = .; /* define a global symbol at bss end */ 164 | __bss_end__ = _ebss; 165 | } >RAM 166 | 167 | /* User_heap_stack section, used to check that there is enough "RAM" Ram type memory left */ 168 | ._user_heap_stack : 169 | { 170 | . = ALIGN(8); 171 | PROVIDE ( end = . ); 172 | PROVIDE ( _end = . ); 173 | . = . + _Min_Heap_Size; 174 | . = . + _Min_Stack_Size; 175 | . = ALIGN(8); 176 | } >RAM 177 | 178 | /* Remove information from the compiler libraries */ 179 | /DISCARD/ : 180 | { 181 | libc.a ( * ) 182 | libm.a ( * ) 183 | libgcc.a ( * ) 184 | } 185 | 186 | .ARM.attributes 0 : { *(.ARM.attributes) } 187 | } 188 | -------------------------------------------------------------------------------- /cdh-tsat-stm32project-board/STM32L496RGTX_FLASH.ld: -------------------------------------------------------------------------------- 1 | /* 2 | ****************************************************************************** 3 | ** 4 | ** @file : LinkerScript.ld 5 | ** 6 | ** @author : Auto-generated by STM32CubeIDE 7 | ** 8 | ** @brief : Linker script for STM32L496RGTx Device from STM32L4 series 9 | ** 1024KBytes FLASH 10 | ** 320KBytes RAM 11 | ** 64KBytes RAM2 12 | ** 13 | ** Set heap size, stack size and stack location according 14 | ** to application requirements. 15 | ** 16 | ** Set memory bank area and size if external memory is used 17 | ** 18 | ** Target : STMicroelectronics STM32 19 | ** 20 | ** Distribution: The file is distributed as is, without any warranty 21 | ** of any kind. 22 | ** 23 | ****************************************************************************** 24 | ** @attention 25 | ** 26 | ** Copyright (c) 2024 STMicroelectronics. 27 | ** All rights reserved. 28 | ** 29 | ** This software is licensed under terms that can be found in the LICENSE file 30 | ** in the root directory of this software component. 31 | ** If no LICENSE file comes with this software, it is provided AS-IS. 32 | ** 33 | ****************************************************************************** 34 | */ 35 | 36 | /* Entry Point */ 37 | ENTRY(Reset_Handler) 38 | 39 | /* Highest address of the user mode stack */ 40 | _estack = ORIGIN(RAM) + LENGTH(RAM); /* end of "RAM" Ram type memory */ 41 | 42 | _Min_Heap_Size = 0x200; /* required amount of heap */ 43 | _Min_Stack_Size = 0x400; /* required amount of stack */ 44 | 45 | /* Memories definition */ 46 | MEMORY 47 | { 48 | RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 320K 49 | RAM2 (xrw) : ORIGIN = 0x10000000, LENGTH = 64K 50 | FLASH (rx) : ORIGIN = 0x8000000, LENGTH = 1024K 51 | } 52 | 53 | /* Sections */ 54 | SECTIONS 55 | { 56 | /* The startup code into "FLASH" Rom type memory */ 57 | .isr_vector : 58 | { 59 | . = ALIGN(4); 60 | KEEP(*(.isr_vector)) /* Startup code */ 61 | . = ALIGN(4); 62 | } >FLASH 63 | 64 | /* The program code and other data into "FLASH" Rom type memory */ 65 | .text : 66 | { 67 | . = ALIGN(4); 68 | *(.text) /* .text sections (code) */ 69 | *(.text*) /* .text* sections (code) */ 70 | *(.glue_7) /* glue arm to thumb code */ 71 | *(.glue_7t) /* glue thumb to arm code */ 72 | *(.eh_frame) 73 | 74 | KEEP (*(.init)) 75 | KEEP (*(.fini)) 76 | 77 | . = ALIGN(4); 78 | _etext = .; /* define a global symbols at end of code */ 79 | } >FLASH 80 | 81 | /* Constant data into "FLASH" Rom type memory */ 82 | .rodata : 83 | { 84 | . = ALIGN(4); 85 | *(.rodata) /* .rodata sections (constants, strings, etc.) */ 86 | *(.rodata*) /* .rodata* sections (constants, strings, etc.) */ 87 | . = ALIGN(4); 88 | } >FLASH 89 | 90 | .ARM.extab : { 91 | . = ALIGN(4); 92 | *(.ARM.extab* .gnu.linkonce.armextab.*) 93 | . = ALIGN(4); 94 | } >FLASH 95 | 96 | .ARM : { 97 | . = ALIGN(4); 98 | __exidx_start = .; 99 | *(.ARM.exidx*) 100 | __exidx_end = .; 101 | . = ALIGN(4); 102 | } >FLASH 103 | 104 | .preinit_array : 105 | { 106 | . = ALIGN(4); 107 | PROVIDE_HIDDEN (__preinit_array_start = .); 108 | KEEP (*(.preinit_array*)) 109 | PROVIDE_HIDDEN (__preinit_array_end = .); 110 | . = ALIGN(4); 111 | } >FLASH 112 | 113 | .init_array : 114 | { 115 | . = ALIGN(4); 116 | PROVIDE_HIDDEN (__init_array_start = .); 117 | KEEP (*(SORT(.init_array.*))) 118 | KEEP (*(.init_array*)) 119 | PROVIDE_HIDDEN (__init_array_end = .); 120 | . = ALIGN(4); 121 | } >FLASH 122 | 123 | .fini_array : 124 | { 125 | . = ALIGN(4); 126 | PROVIDE_HIDDEN (__fini_array_start = .); 127 | KEEP (*(SORT(.fini_array.*))) 128 | KEEP (*(.fini_array*)) 129 | PROVIDE_HIDDEN (__fini_array_end = .); 130 | . = ALIGN(4); 131 | } >FLASH 132 | 133 | /* Used by the startup to initialize data */ 134 | _sidata = LOADADDR(.data); 135 | 136 | /* Initialized data sections into "RAM" Ram type memory */ 137 | .data : 138 | { 139 | . = ALIGN(4); 140 | _sdata = .; /* create a global symbol at data start */ 141 | *(.data) /* .data sections */ 142 | *(.data*) /* .data* sections */ 143 | *(.RamFunc) /* .RamFunc sections */ 144 | *(.RamFunc*) /* .RamFunc* sections */ 145 | 146 | . = ALIGN(4); 147 | _edata = .; /* define a global symbol at data end */ 148 | 149 | } >RAM AT> FLASH 150 | 151 | /* Uninitialized data section into "RAM" Ram type memory */ 152 | . = ALIGN(4); 153 | .bss : 154 | { 155 | /* This is used by the startup in order to initialize the .bss section */ 156 | _sbss = .; /* define a global symbol at bss start */ 157 | __bss_start__ = _sbss; 158 | *(.bss) 159 | *(.bss*) 160 | *(COMMON) 161 | 162 | . = ALIGN(4); 163 | _ebss = .; /* define a global symbol at bss end */ 164 | __bss_end__ = _ebss; 165 | } >RAM 166 | 167 | /* User_heap_stack section, used to check that there is enough "RAM" Ram type memory left */ 168 | ._user_heap_stack : 169 | { 170 | . = ALIGN(8); 171 | PROVIDE ( end = . ); 172 | PROVIDE ( _end = . ); 173 | . = . + _Min_Heap_Size; 174 | . = . + _Min_Stack_Size; 175 | . = ALIGN(8); 176 | } >RAM 177 | 178 | /* Remove information from the compiler libraries */ 179 | /DISCARD/ : 180 | { 181 | libc.a ( * ) 182 | libm.a ( * ) 183 | libgcc.a ( * ) 184 | } 185 | 186 | .ARM.attributes 0 : { *(.ARM.attributes) } 187 | } 188 | -------------------------------------------------------------------------------- /cdh-tsat-stm32project-nucleo/STM32L452RETX_RAM.ld: -------------------------------------------------------------------------------- 1 | /* 2 | ****************************************************************************** 3 | ** 4 | ** @file : LinkerScript.ld (debug in RAM dedicated) 5 | ** 6 | ** @author : Auto-generated by STM32CubeIDE 7 | ** 8 | ** Abstract : Linker script for NUCLEO-L452RE Board embedding STM32L452RETx Device from stm32l4 series 9 | ** 512KBytes FLASH 10 | ** 160KBytes RAM 11 | ** 32KBytes RAM2 12 | ** 13 | ** Set heap size, stack size and stack location according 14 | ** to application requirements. 15 | ** 16 | ** Set memory bank area and size if external memory is used 17 | ** 18 | ** Target : STMicroelectronics STM32 19 | ** 20 | ** Distribution: The file is distributed as is, without any warranty 21 | ** of any kind. 22 | ** 23 | ****************************************************************************** 24 | ** @attention 25 | ** 26 | ** Copyright (c) 2024 STMicroelectronics. 27 | ** All rights reserved. 28 | ** 29 | ** This software is licensed under terms that can be found in the LICENSE file 30 | ** in the root directory of this software component. 31 | ** If no LICENSE file comes with this software, it is provided AS-IS. 32 | ** 33 | ****************************************************************************** 34 | */ 35 | 36 | /* Entry Point */ 37 | ENTRY(Reset_Handler) 38 | 39 | /* Highest address of the user mode stack */ 40 | _estack = ORIGIN(RAM) + LENGTH(RAM); /* end of "RAM" Ram type memory */ 41 | 42 | _Min_Heap_Size = 0x200; /* required amount of heap */ 43 | _Min_Stack_Size = 0x400; /* required amount of stack */ 44 | 45 | /* Memories definition */ 46 | MEMORY 47 | { 48 | RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 160K 49 | RAM2 (xrw) : ORIGIN = 0x10000000, LENGTH = 32K 50 | FLASH (rx) : ORIGIN = 0x8000000, LENGTH = 512K 51 | } 52 | 53 | /* Sections */ 54 | SECTIONS 55 | { 56 | /* The startup code into "RAM" Ram type memory */ 57 | .isr_vector : 58 | { 59 | . = ALIGN(4); 60 | KEEP(*(.isr_vector)) /* Startup code */ 61 | . = ALIGN(4); 62 | } >RAM 63 | 64 | /* The program code and other data into "RAM" Ram type memory */ 65 | .text : 66 | { 67 | . = ALIGN(4); 68 | *(.text) /* .text sections (code) */ 69 | *(.text*) /* .text* sections (code) */ 70 | *(.glue_7) /* glue arm to thumb code */ 71 | *(.glue_7t) /* glue thumb to arm code */ 72 | *(.eh_frame) 73 | *(.RamFunc) /* .RamFunc sections */ 74 | *(.RamFunc*) /* .RamFunc* sections */ 75 | 76 | KEEP (*(.init)) 77 | KEEP (*(.fini)) 78 | 79 | . = ALIGN(4); 80 | _etext = .; /* define a global symbols at end of code */ 81 | } >RAM 82 | 83 | /* Constant data into "RAM" Ram type memory */ 84 | .rodata : 85 | { 86 | . = ALIGN(4); 87 | *(.rodata) /* .rodata sections (constants, strings, etc.) */ 88 | *(.rodata*) /* .rodata* sections (constants, strings, etc.) */ 89 | . = ALIGN(4); 90 | } >RAM 91 | 92 | .ARM.extab : { 93 | . = ALIGN(4); 94 | *(.ARM.extab* .gnu.linkonce.armextab.*) 95 | . = ALIGN(4); 96 | } >RAM 97 | 98 | .ARM : { 99 | . = ALIGN(4); 100 | __exidx_start = .; 101 | *(.ARM.exidx*) 102 | __exidx_end = .; 103 | . = ALIGN(4); 104 | } >RAM 105 | 106 | .preinit_array : 107 | { 108 | . = ALIGN(4); 109 | PROVIDE_HIDDEN (__preinit_array_start = .); 110 | KEEP (*(.preinit_array*)) 111 | PROVIDE_HIDDEN (__preinit_array_end = .); 112 | . = ALIGN(4); 113 | } >RAM 114 | 115 | .init_array : 116 | { 117 | . = ALIGN(4); 118 | PROVIDE_HIDDEN (__init_array_start = .); 119 | KEEP (*(SORT(.init_array.*))) 120 | KEEP (*(.init_array*)) 121 | PROVIDE_HIDDEN (__init_array_end = .); 122 | . = ALIGN(4); 123 | } >RAM 124 | 125 | .fini_array : 126 | { 127 | . = ALIGN(4); 128 | PROVIDE_HIDDEN (__fini_array_start = .); 129 | KEEP (*(SORT(.fini_array.*))) 130 | KEEP (*(.fini_array*)) 131 | PROVIDE_HIDDEN (__fini_array_end = .); 132 | . = ALIGN(4); 133 | } >RAM 134 | 135 | /* Used by the startup to initialize data */ 136 | _sidata = LOADADDR(.data); 137 | 138 | /* Initialized data sections into "RAM" Ram type memory */ 139 | .data : 140 | { 141 | . = ALIGN(4); 142 | _sdata = .; /* create a global symbol at data start */ 143 | *(.data) /* .data sections */ 144 | *(.data*) /* .data* sections */ 145 | 146 | . = ALIGN(4); 147 | _edata = .; /* define a global symbol at data end */ 148 | 149 | } >RAM 150 | 151 | /* Uninitialized data section into "RAM" Ram type memory */ 152 | . = ALIGN(4); 153 | .bss : 154 | { 155 | /* This is used by the startup in order to initialize the .bss section */ 156 | _sbss = .; /* define a global symbol at bss start */ 157 | __bss_start__ = _sbss; 158 | *(.bss) 159 | *(.bss*) 160 | *(COMMON) 161 | 162 | . = ALIGN(4); 163 | _ebss = .; /* define a global symbol at bss end */ 164 | __bss_end__ = _ebss; 165 | } >RAM 166 | 167 | /* User_heap_stack section, used to check that there is enough "RAM" Ram type memory left */ 168 | ._user_heap_stack : 169 | { 170 | . = ALIGN(8); 171 | PROVIDE ( end = . ); 172 | PROVIDE ( _end = . ); 173 | . = . + _Min_Heap_Size; 174 | . = . + _Min_Stack_Size; 175 | . = ALIGN(8); 176 | } >RAM 177 | 178 | /* Remove information from the compiler libraries */ 179 | /DISCARD/ : 180 | { 181 | libc.a ( * ) 182 | libm.a ( * ) 183 | libgcc.a ( * ) 184 | } 185 | 186 | .ARM.attributes 0 : { *(.ARM.attributes) } 187 | } 188 | -------------------------------------------------------------------------------- /cdh-tsat-stm32project-nucleo/STM32L452RETX_FLASH.ld: -------------------------------------------------------------------------------- 1 | /* 2 | ****************************************************************************** 3 | ** 4 | ** @file : LinkerScript.ld 5 | ** 6 | ** @author : Auto-generated by STM32CubeIDE 7 | ** 8 | ** Abstract : Linker script for NUCLEO-L452RE Board embedding STM32L452RETx Device from stm32l4 series 9 | ** 512KBytes FLASH 10 | ** 160KBytes RAM 11 | ** 32KBytes RAM2 12 | ** 13 | ** Set heap size, stack size and stack location according 14 | ** to application requirements. 15 | ** 16 | ** Set memory bank area and size if external memory is used 17 | ** 18 | ** Target : STMicroelectronics STM32 19 | ** 20 | ** Distribution: The file is distributed as is, without any warranty 21 | ** of any kind. 22 | ** 23 | ****************************************************************************** 24 | ** @attention 25 | ** 26 | ** Copyright (c) 2024 STMicroelectronics. 27 | ** All rights reserved. 28 | ** 29 | ** This software is licensed under terms that can be found in the LICENSE file 30 | ** in the root directory of this software component. 31 | ** If no LICENSE file comes with this software, it is provided AS-IS. 32 | ** 33 | ****************************************************************************** 34 | */ 35 | 36 | /* Entry Point */ 37 | ENTRY(Reset_Handler) 38 | 39 | /* Highest address of the user mode stack */ 40 | _estack = ORIGIN(RAM) + LENGTH(RAM); /* end of "RAM" Ram type memory */ 41 | 42 | _Min_Heap_Size = 0x200; /* required amount of heap */ 43 | _Min_Stack_Size = 0x400; /* required amount of stack */ 44 | 45 | /* Memories definition */ 46 | MEMORY 47 | { 48 | RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 160K 49 | RAM2 (xrw) : ORIGIN = 0x10000000, LENGTH = 32K 50 | FLASH (rx) : ORIGIN = 0x8000000, LENGTH = 512K 51 | } 52 | 53 | /* Sections */ 54 | SECTIONS 55 | { 56 | /* The startup code into "FLASH" Rom type memory */ 57 | .isr_vector : 58 | { 59 | . = ALIGN(4); 60 | KEEP(*(.isr_vector)) /* Startup code */ 61 | . = ALIGN(4); 62 | } >FLASH 63 | 64 | /* The program code and other data into "FLASH" Rom type memory */ 65 | .text : 66 | { 67 | . = ALIGN(4); 68 | *(.text) /* .text sections (code) */ 69 | *(.text*) /* .text* sections (code) */ 70 | *(.glue_7) /* glue arm to thumb code */ 71 | *(.glue_7t) /* glue thumb to arm code */ 72 | *(.eh_frame) 73 | 74 | KEEP (*(.init)) 75 | KEEP (*(.fini)) 76 | 77 | . = ALIGN(4); 78 | _etext = .; /* define a global symbols at end of code */ 79 | } >FLASH 80 | 81 | /* Constant data into "FLASH" Rom type memory */ 82 | .rodata : 83 | { 84 | . = ALIGN(4); 85 | *(.rodata) /* .rodata sections (constants, strings, etc.) */ 86 | *(.rodata*) /* .rodata* sections (constants, strings, etc.) */ 87 | . = ALIGN(4); 88 | } >FLASH 89 | 90 | .ARM.extab : { 91 | . = ALIGN(4); 92 | *(.ARM.extab* .gnu.linkonce.armextab.*) 93 | . = ALIGN(4); 94 | } >FLASH 95 | 96 | .ARM : { 97 | . = ALIGN(4); 98 | __exidx_start = .; 99 | *(.ARM.exidx*) 100 | __exidx_end = .; 101 | . = ALIGN(4); 102 | } >FLASH 103 | 104 | .preinit_array : 105 | { 106 | . = ALIGN(4); 107 | PROVIDE_HIDDEN (__preinit_array_start = .); 108 | KEEP (*(.preinit_array*)) 109 | PROVIDE_HIDDEN (__preinit_array_end = .); 110 | . = ALIGN(4); 111 | } >FLASH 112 | 113 | .init_array : 114 | { 115 | . = ALIGN(4); 116 | PROVIDE_HIDDEN (__init_array_start = .); 117 | KEEP (*(SORT(.init_array.*))) 118 | KEEP (*(.init_array*)) 119 | PROVIDE_HIDDEN (__init_array_end = .); 120 | . = ALIGN(4); 121 | } >FLASH 122 | 123 | .fini_array : 124 | { 125 | . = ALIGN(4); 126 | PROVIDE_HIDDEN (__fini_array_start = .); 127 | KEEP (*(SORT(.fini_array.*))) 128 | KEEP (*(.fini_array*)) 129 | PROVIDE_HIDDEN (__fini_array_end = .); 130 | . = ALIGN(4); 131 | } >FLASH 132 | 133 | /* Used by the startup to initialize data */ 134 | _sidata = LOADADDR(.data); 135 | 136 | /* Initialized data sections into "RAM" Ram type memory */ 137 | .data : 138 | { 139 | . = ALIGN(4); 140 | _sdata = .; /* create a global symbol at data start */ 141 | *(.data) /* .data sections */ 142 | *(.data*) /* .data* sections */ 143 | *(.RamFunc) /* .RamFunc sections */ 144 | *(.RamFunc*) /* .RamFunc* sections */ 145 | 146 | . = ALIGN(4); 147 | _edata = .; /* define a global symbol at data end */ 148 | 149 | } >RAM AT> FLASH 150 | 151 | /* Uninitialized data section into "RAM" Ram type memory */ 152 | . = ALIGN(4); 153 | .bss : 154 | { 155 | /* This is used by the startup in order to initialize the .bss section */ 156 | _sbss = .; /* define a global symbol at bss start */ 157 | __bss_start__ = _sbss; 158 | *(.bss) 159 | *(.bss*) 160 | *(COMMON) 161 | 162 | . = ALIGN(4); 163 | _ebss = .; /* define a global symbol at bss end */ 164 | __bss_end__ = _ebss; 165 | } >RAM 166 | 167 | /* User_heap_stack section, used to check that there is enough "RAM" Ram type memory left */ 168 | ._user_heap_stack : 169 | { 170 | . = ALIGN(8); 171 | PROVIDE ( end = . ); 172 | PROVIDE ( _end = . ); 173 | . = . + _Min_Heap_Size; 174 | . = . + _Min_Stack_Size; 175 | . = ALIGN(8); 176 | } >RAM 177 | 178 | /* Remove information from the compiler libraries */ 179 | /DISCARD/ : 180 | { 181 | libc.a ( * ) 182 | libm.a ( * ) 183 | libgcc.a ( * ) 184 | } 185 | 186 | .ARM.attributes 0 : { *(.ARM.attributes) } 187 | } 188 | -------------------------------------------------------------------------------- /cdh-tsat-stm32project-board/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 | -------------------------------------------------------------------------------- /cdh-tsat-stm32project-nucleo/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 | -------------------------------------------------------------------------------- /cdh-tsat-stm32project-board/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 | -------------------------------------------------------------------------------- /cdh-tsat-stm32project-nucleo/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 | -------------------------------------------------------------------------------- /cdh-tsat-stm32project-board/Core/Src/stm32l4xx_it.c: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file stm32l4xx_it.c 5 | * @brief Interrupt Service Routines. 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | * Copyright (c) 2024 STMicroelectronics. 10 | * All rights reserved. 11 | * 12 | * This software is licensed under terms that can be found in the LICENSE file 13 | * in the root directory of this software component. 14 | * If no LICENSE file comes with this software, it is provided AS-IS. 15 | * 16 | ****************************************************************************** 17 | */ 18 | /* USER CODE END Header */ 19 | 20 | /* Includes ------------------------------------------------------------------*/ 21 | #include "main.h" 22 | #include "stm32l4xx_it.h" 23 | /* Private includes ----------------------------------------------------------*/ 24 | /* USER CODE BEGIN Includes */ 25 | /* USER CODE END Includes */ 26 | 27 | /* Private typedef -----------------------------------------------------------*/ 28 | /* USER CODE BEGIN TD */ 29 | 30 | /* USER CODE END TD */ 31 | 32 | /* Private define ------------------------------------------------------------*/ 33 | /* USER CODE BEGIN PD */ 34 | 35 | /* USER CODE END PD */ 36 | 37 | /* Private macro -------------------------------------------------------------*/ 38 | /* USER CODE BEGIN PM */ 39 | 40 | /* USER CODE END PM */ 41 | 42 | /* Private variables ---------------------------------------------------------*/ 43 | /* USER CODE BEGIN PV */ 44 | 45 | /* USER CODE END PV */ 46 | 47 | /* Private function prototypes -----------------------------------------------*/ 48 | /* USER CODE BEGIN PFP */ 49 | 50 | /* USER CODE END PFP */ 51 | 52 | /* Private user code ---------------------------------------------------------*/ 53 | /* USER CODE BEGIN 0 */ 54 | 55 | /* USER CODE END 0 */ 56 | 57 | /* External variables --------------------------------------------------------*/ 58 | extern CAN_HandleTypeDef hcan1; 59 | extern RTC_HandleTypeDef hrtc; 60 | extern TIM_HandleTypeDef htim6; 61 | 62 | /* USER CODE BEGIN EV */ 63 | 64 | /* USER CODE END EV */ 65 | 66 | /******************************************************************************/ 67 | /* Cortex-M4 Processor Interruption and Exception Handlers */ 68 | /******************************************************************************/ 69 | /** 70 | * @brief This function handles Non maskable interrupt. 71 | */ 72 | void NMI_Handler(void) 73 | { 74 | /* USER CODE BEGIN NonMaskableInt_IRQn 0 */ 75 | 76 | /* USER CODE END NonMaskableInt_IRQn 0 */ 77 | HAL_RCC_NMI_IRQHandler(); 78 | /* USER CODE BEGIN NonMaskableInt_IRQn 1 */ 79 | while (1) 80 | { 81 | } 82 | /* USER CODE END NonMaskableInt_IRQn 1 */ 83 | } 84 | 85 | /** 86 | * @brief This function handles Hard fault interrupt. 87 | */ 88 | void HardFault_Handler(void) 89 | { 90 | /* USER CODE BEGIN HardFault_IRQn 0 */ 91 | 92 | /* USER CODE END HardFault_IRQn 0 */ 93 | while (1) 94 | { 95 | /* USER CODE BEGIN W1_HardFault_IRQn 0 */ 96 | /* USER CODE END W1_HardFault_IRQn 0 */ 97 | } 98 | } 99 | 100 | /** 101 | * @brief This function handles Memory management fault. 102 | */ 103 | void MemManage_Handler(void) 104 | { 105 | /* USER CODE BEGIN MemoryManagement_IRQn 0 */ 106 | 107 | /* USER CODE END MemoryManagement_IRQn 0 */ 108 | while (1) 109 | { 110 | /* USER CODE BEGIN W1_MemoryManagement_IRQn 0 */ 111 | /* USER CODE END W1_MemoryManagement_IRQn 0 */ 112 | } 113 | } 114 | 115 | /** 116 | * @brief This function handles Prefetch fault, memory access fault. 117 | */ 118 | void BusFault_Handler(void) 119 | { 120 | /* USER CODE BEGIN BusFault_IRQn 0 */ 121 | 122 | /* USER CODE END BusFault_IRQn 0 */ 123 | while (1) 124 | { 125 | /* USER CODE BEGIN W1_BusFault_IRQn 0 */ 126 | /* USER CODE END W1_BusFault_IRQn 0 */ 127 | } 128 | } 129 | 130 | /** 131 | * @brief This function handles Undefined instruction or illegal state. 132 | */ 133 | void UsageFault_Handler(void) 134 | { 135 | /* USER CODE BEGIN UsageFault_IRQn 0 */ 136 | 137 | /* USER CODE END UsageFault_IRQn 0 */ 138 | while (1) 139 | { 140 | /* USER CODE BEGIN W1_UsageFault_IRQn 0 */ 141 | /* USER CODE END W1_UsageFault_IRQn 0 */ 142 | } 143 | } 144 | 145 | /** 146 | * @brief This function handles Debug monitor. 147 | */ 148 | void DebugMon_Handler(void) 149 | { 150 | /* USER CODE BEGIN DebugMonitor_IRQn 0 */ 151 | 152 | /* USER CODE END DebugMonitor_IRQn 0 */ 153 | /* USER CODE BEGIN DebugMonitor_IRQn 1 */ 154 | 155 | /* USER CODE END DebugMonitor_IRQn 1 */ 156 | } 157 | 158 | /******************************************************************************/ 159 | /* STM32L4xx Peripheral Interrupt Handlers */ 160 | /* Add here the Interrupt Handlers for the used peripherals. */ 161 | /* For the available peripheral interrupt handler names, */ 162 | /* please refer to the startup file (startup_stm32l4xx.s). */ 163 | /******************************************************************************/ 164 | 165 | /** 166 | * @brief This function handles CAN1 RX0 interrupt. 167 | */ 168 | void CAN1_RX0_IRQHandler(void) 169 | { 170 | /* USER CODE BEGIN CAN1_RX0_IRQn 0 */ 171 | 172 | /* USER CODE END CAN1_RX0_IRQn 0 */ 173 | HAL_CAN_IRQHandler(&hcan1); 174 | /* USER CODE BEGIN CAN1_RX0_IRQn 1 */ 175 | 176 | /* USER CODE END CAN1_RX0_IRQn 1 */ 177 | } 178 | 179 | /** 180 | * @brief This function handles RTC alarm interrupt through EXTI line 18. 181 | */ 182 | void RTC_Alarm_IRQHandler(void) 183 | { 184 | /* USER CODE BEGIN RTC_Alarm_IRQn 0 */ 185 | 186 | /* USER CODE END RTC_Alarm_IRQn 0 */ 187 | HAL_RTC_AlarmIRQHandler(&hrtc); 188 | /* USER CODE BEGIN RTC_Alarm_IRQn 1 */ 189 | 190 | /* USER CODE END RTC_Alarm_IRQn 1 */ 191 | } 192 | 193 | /** 194 | * @brief This function handles TIM6 global interrupt, DAC channel1 and channel2 underrun error interrupts. 195 | */ 196 | void TIM6_DAC_IRQHandler(void) 197 | { 198 | /* USER CODE BEGIN TIM6_DAC_IRQn 0 */ 199 | 200 | /* USER CODE END TIM6_DAC_IRQn 0 */ 201 | HAL_TIM_IRQHandler(&htim6); 202 | /* USER CODE BEGIN TIM6_DAC_IRQn 1 */ 203 | 204 | /* USER CODE END TIM6_DAC_IRQn 1 */ 205 | } 206 | 207 | /* USER CODE BEGIN 1 */ 208 | 209 | /* USER CODE END 1 */ 210 | -------------------------------------------------------------------------------- /cdh-tsat-stm32project-board/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 | -------------------------------------------------------------------------------- /cdh-tsat-stm32project-nucleo/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 | --------------------------------------------------------------------------------