Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhanced Interface Board #145

Merged
merged 15 commits into from
Feb 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
4 changes: 4 additions & 0 deletions benchmark/interface/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.idea/
cmake-build-*/
/STM32CubeIDE/Debug/
/STM32CubeIDE/Release/
72 changes: 72 additions & 0 deletions benchmark/interface/.mxproject

Large diffs are not rendered by default.

199 changes: 199 additions & 0 deletions benchmark/interface/AZURE_RTOS/App/app_azure_rtos.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,199 @@
/* USER CODE BEGIN Header */
/**
******************************************************************************
* @file app_azure_rtos.c
* @author MCD Application Team
* @brief app_azure_rtos application implementation file
******************************************************************************
* @attention
*
* Copyright (c) 2023 STMicroelectronics.
* All rights reserved.
*
* This software is licensed under terms that can be found in the LICENSE file
* in the root directory of this software component.
* If no LICENSE file comes with this software, it is provided AS-IS.
*
******************************************************************************
*/
/* USER CODE END Header */

/* Includes ------------------------------------------------------------------*/
#include "app_azure_rtos.h"
/* Private includes ----------------------------------------------------------*/
/* USER CODE BEGIN Includes */

#include "ResourceManager.h"

/* USER CODE END Includes */

/* Private typedef -----------------------------------------------------------*/
/* USER CODE BEGIN PTD */

/* USER CODE END PTD */

/* Private define ------------------------------------------------------------*/
/* USER CODE BEGIN PD */

/* USER CODE END PD */

/* Private macro -------------------------------------------------------------*/
/* USER CODE BEGIN PM */

/* USER CODE END PM */

/* Private variables ---------------------------------------------------------*/
/* USER CODE BEGIN PV */

#if (USE_STATIC_ALLOCATION == 1)

#if defined ( __ICCARM__ )
#pragma data_alignment=4
#endif
__ALIGN_BEGIN static UCHAR resource_pool_buffer[RESOURCE_MEM_POOL_SIZE] __ALIGN_END;
static TX_BYTE_POOL resource_byte_pool;

#endif

/* USER CODE END PV */

#if (USE_STATIC_ALLOCATION == 1)

/* USER CODE BEGIN TX_Pool_Buffer */
/* USER CODE END TX_Pool_Buffer */
#if defined ( __ICCARM__ )
#pragma data_alignment=4
#endif
__ALIGN_BEGIN static UCHAR tx_byte_pool_buffer[TX_APP_MEM_POOL_SIZE] __ALIGN_END;
static TX_BYTE_POOL tx_app_byte_pool;

/* USER CODE BEGIN FX_Pool_Buffer */
/* USER CODE END FX_Pool_Buffer */
#if defined ( __ICCARM__ )
#pragma data_alignment=4
#endif
__ALIGN_BEGIN static UCHAR fx_byte_pool_buffer[FX_APP_MEM_POOL_SIZE] __ALIGN_END;
static TX_BYTE_POOL fx_app_byte_pool;

#endif

/* Private function prototypes -----------------------------------------------*/
/* USER CODE BEGIN PFP */

/* USER CODE END PFP */

/**
* @brief Define the initial system.
* @param first_unused_memory : Pointer to the first unused memory
* @retval None
*/
VOID tx_application_define(VOID *first_unused_memory)
{
/* USER CODE BEGIN tx_application_define_1*/

#if (USE_STATIC_ALLOCATION == 1)
if (tx_byte_pool_create(&resource_byte_pool, "Resource memory pool", resource_pool_buffer, RESOURCE_MEM_POOL_SIZE) != TX_SUCCESS)
{

}
else
{
InitializeResourceManager(&resource_byte_pool);
}
#endif

/* USER CODE END tx_application_define_1 */
#if (USE_STATIC_ALLOCATION == 1)
UINT status = TX_SUCCESS;
VOID *memory_ptr;

if (tx_byte_pool_create(&tx_app_byte_pool, "Tx App memory pool", tx_byte_pool_buffer, TX_APP_MEM_POOL_SIZE) != TX_SUCCESS)
{
/* USER CODE BEGIN TX_Byte_Pool_Error */

/* USER CODE END TX_Byte_Pool_Error */
}
else
{
/* USER CODE BEGIN TX_Byte_Pool_Success */

/* USER CODE END TX_Byte_Pool_Success */

memory_ptr = (VOID *)&tx_app_byte_pool;
status = App_ThreadX_Init(memory_ptr);
if (status != TX_SUCCESS)
{
/* USER CODE BEGIN App_ThreadX_Init_Error */
while(1)
{
}
/* USER CODE END App_ThreadX_Init_Error */
}
/* USER CODE BEGIN App_ThreadX_Init_Success */

/* USER CODE END App_ThreadX_Init_Success */

}
if (tx_byte_pool_create(&fx_app_byte_pool, "Fx App memory pool", fx_byte_pool_buffer, FX_APP_MEM_POOL_SIZE) != TX_SUCCESS)
{
/* USER CODE BEGIN FX_Byte_Pool_Error */

/* USER CODE END FX_Byte_Pool_Error */
}
else
{
/* USER CODE BEGIN FX_Byte_Pool_Success */

/* USER CODE END FX_Byte_Pool_Success */

memory_ptr = (VOID *)&fx_app_byte_pool;
status = MX_FileX_Init(memory_ptr);
if (status != FX_SUCCESS)
{
/* USER CODE BEGIN MX_FileX_Init_Error */
// while(1)
// {
// }
/* USER CODE END MX_FileX_Init_Error */
}
/* USER CODE BEGIN MX_FileX_Init_Success */

/* USER CODE END MX_FileX_Init_Success */
}

#else
/*
* Using dynamic memory allocation requires to apply some changes to the linker file.
* ThreadX needs to pass a pointer to the first free memory location in RAM to the tx_application_define() function,
* using the "first_unused_memory" argument.
* This require changes in the linker files to expose this memory location.
* For EWARM add the following section into the .icf file:
place in RAM_region { last section FREE_MEM };
* For MDK-ARM
- either define the RW_IRAM1 region in the ".sct" file
- or modify the line below in "tx_initialize_low_level.S to match the memory region being used
LDR r1, =|Image$$RW_IRAM1$$ZI$$Limit|

* For STM32CubeIDE add the following section into the .ld file:
._threadx_heap :
{
. = ALIGN(8);
__RAM_segment_used_end__ = .;
. = . + 64K;
. = ALIGN(8);
} >RAM_D1 AT> RAM_D1
* The simplest way to provide memory for ThreadX is to define a new section, see ._threadx_heap above.
* In the example above the ThreadX heap size is set to 64KBytes.
* The ._threadx_heap must be located between the .bss and the ._user_heap_stack sections in the linker script.
* Caution: Make sure that ThreadX does not need more than the provided heap memory (64KBytes in this example).
* Read more in STM32CubeIDE User Guide, chapter: "Linker script".

* The "tx_initialize_low_level.S" should be also modified to enable the "USE_DYNAMIC_MEMORY_ALLOCATION" flag.
*/

/* USER CODE BEGIN DYNAMIC_MEM_ALLOC */
(void)first_unused_memory;
/* USER CODE END DYNAMIC_MEM_ALLOC */
#endif

}
70 changes: 70 additions & 0 deletions benchmark/interface/AZURE_RTOS/App/app_azure_rtos.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
/* USER CODE BEGIN Header */
/**
******************************************************************************
* @file app_azure_rtos.h
* @author MCD Application Team
* @brief app_azure_rtos application header file
******************************************************************************
* @attention
*
* Copyright (c) 2023 STMicroelectronics.
* All rights reserved.
*
* This software is licensed under terms that can be found in the LICENSE file
* in the root directory of this software component.
* If no LICENSE file comes with this software, it is provided AS-IS.
*
******************************************************************************
*/
/* USER CODE END Header */

/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef APP_AZURE_RTOS_H
#define APP_AZURE_RTOS_H
#ifdef __cplusplus
extern "C" {
#endif

/* Includes ------------------------------------------------------------------*/

#include "app_threadx.h"
#include "stm32h5xx_hal.h"
#include "app_azure_rtos_config.h"
#include "app_filex.h"

/* Private includes ----------------------------------------------------------*/
/* USER CODE BEGIN Includes */

/* USER CODE END Includes */

/* Exported types ------------------------------------------------------------*/
/* USER CODE BEGIN ET */

/* USER CODE END ET */

/* Exported constants --------------------------------------------------------*/
/* USER CODE BEGIN EC */

/* USER CODE END EC */

/* Exported macro ------------------------------------------------------------*/
/* USER CODE BEGIN EM */

/* USER CODE END EM */

/* Exported functions prototypes ---------------------------------------------*/

/* USER CODE BEGIN EFP */

/* USER CODE END EFP */

/* Private defines -----------------------------------------------------------*/
/* USER CODE BEGIN PD */

/* USER CODE END PD */

#ifdef __cplusplus
}
#endif
#endif /* APP_AZURE_RTOS_H */

76 changes: 76 additions & 0 deletions benchmark/interface/AZURE_RTOS/App/app_azure_rtos_config.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@

/* USER CODE BEGIN Header */
/**
******************************************************************************
* @file app_azure_rtos_config.h
* @author MCD Application Team
* @brief app_azure_rtos config header file
******************************************************************************
* @attention
*
* Copyright (c) 2023 STMicroelectronics.
* All rights reserved.
*
* This software is licensed under terms that can be found in the LICENSE file
* in the root directory of this software component.
* If no LICENSE file comes with this software, it is provided AS-IS.
*
******************************************************************************
*/
/* USER CODE END Header */

/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef APP_AZURE_RTOS_CONFIG_H
#define APP_AZURE_RTOS_CONFIG_H
#ifdef __cplusplus
extern "C" {
#endif

/* Includes ------------------------------------------------------------------*/

/* Private includes ----------------------------------------------------------*/
/* USER CODE BEGIN Includes */

/* USER CODE END Includes */

/* Exported types ------------------------------------------------------------*/
/* USER CODE BEGIN ET */

/* USER CODE END ET */

/* Exported constants --------------------------------------------------------*/
/* Using static memory allocation via threadX Byte memory pools */

#define USE_STATIC_ALLOCATION 1

#define TX_APP_MEM_POOL_SIZE 2 * 1024

#define FX_APP_MEM_POOL_SIZE 6144

/* USER CODE BEGIN EC */

#define RESOURCE_MEM_POOL_SIZE 16384

/* USER CODE END EC */

/* Exported macro ------------------------------------------------------------*/
/* USER CODE BEGIN EM */

/* USER CODE END EM */

/* Exported functions prototypes ---------------------------------------------*/
/* USER CODE BEGIN EFP */

/* USER CODE END EFP */

/* Private defines -----------------------------------------------------------*/
/* USER CODE BEGIN PD */

/* USER CODE END PD */

#ifdef __cplusplus
}
#endif

#endif /* APP_AZURE_RTOS_CONFIG_H */

Loading
Loading