source: ctrl/firmware/Main/CubeMX/FileX/App/app_filex.c @ 54

Last change on this file since 54 was 54, checked in by Zed, 5 weeks ago

SDMMC(DMA) and Azure_RTOS(with FileX) are activated.

File size: 4.2 KB
Line 
1
2/* USER CODE BEGIN Header */
3/**
4  ******************************************************************************
5  * @file    app_filex.c
6  * @author  MCD Application Team
7  * @brief   FileX applicative file
8  ******************************************************************************
9  * @attention
10  *
11  * Copyright (c) 2020-2021 STMicroelectronics.
12  * All rights reserved.
13  *
14  * This software is licensed under terms that can be found in the LICENSE file
15  * in the root directory of this software component.
16  * If no LICENSE file comes with this software, it is provided AS-IS.
17  *
18  ******************************************************************************
19  */
20/* USER CODE END Header */
21
22/* Includes ------------------------------------------------------------------*/
23#include "app_filex.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/* Main thread stack size */
37#define FX_APP_THREAD_STACK_SIZE         1024
38/* Main thread priority */
39#define FX_APP_THREAD_PRIO               10
40
41/* USER CODE BEGIN PD */
42
43/* USER CODE END PD */
44
45/* Private macro -------------------------------------------------------------*/
46/* USER CODE BEGIN PM */
47
48/* USER CODE END PM */
49
50/* Private variables ---------------------------------------------------------*/
51/* Main thread global data structures.  */
52TX_THREAD       fx_app_thread;
53
54/* Buffer for FileX FX_MEDIA sector cache. */
55ALIGN_32BYTES (uint32_t fx_sd_media_memory[FX_STM32_SD_DEFAULT_SECTOR_SIZE / sizeof(uint32_t)]);
56/* Define FileX global data structures.  */
57FX_MEDIA        sdio_disk;
58
59/* USER CODE BEGIN PV */
60
61/* USER CODE END PV */
62
63/* Private function prototypes -----------------------------------------------*/
64/* Main thread entry function.  */
65void fx_app_thread_entry(ULONG thread_input);
66
67/* USER CODE BEGIN PFP */
68
69/* USER CODE END PFP */
70
71/**
72  * @brief  Application FileX Initialization.
73  * @param memory_ptr: memory pointer
74  * @retval int
75  */
76UINT MX_FileX_Init(VOID *memory_ptr)
77{
78  UINT ret = FX_SUCCESS;
79
80  TX_BYTE_POOL *byte_pool = (TX_BYTE_POOL*)memory_ptr;
81  VOID *pointer;
82
83  /* USER CODE BEGIN MX_FileX_MEM_POOL */
84
85  /* USER CODE END MX_FileX_MEM_POOL */
86
87  /* USER CODE BEGIN 0 */
88
89  /* USER CODE END 0 */
90
91  /*Allocate memory for the main thread's stack*/
92  ret = tx_byte_allocate(byte_pool, &pointer, FX_APP_THREAD_STACK_SIZE, TX_NO_WAIT);
93
94  /* Check FX_APP_THREAD_STACK_SIZE allocation*/
95  if (ret != FX_SUCCESS)
96  {
97    return TX_POOL_ERROR;
98  }
99
100  /* Create the main thread.  */
101  ret = tx_thread_create(&fx_app_thread, FX_APP_THREAD_NAME, fx_app_thread_entry, 0, pointer, FX_APP_THREAD_STACK_SIZE,
102                         FX_APP_THREAD_PRIO, FX_APP_PREEMPTION_THRESHOLD, FX_APP_THREAD_TIME_SLICE, FX_APP_THREAD_AUTO_START);
103
104  /* Check main thread creation */
105  if (ret != TX_SUCCESS)
106  {
107    return TX_THREAD_ERROR;
108  }
109  /* USER CODE BEGIN MX_FileX_Init */
110
111  /* USER CODE END MX_FileX_Init */
112
113  /* Initialize FileX.  */
114  fx_system_initialize();
115
116  /* USER CODE BEGIN MX_FileX_Init 1*/
117
118  /* USER CODE END MX_FileX_Init 1*/
119
120  return ret;
121}
122
123 /**
124 * @brief  Main thread entry.
125 * @param thread_input: ULONG user argument used by the thread entry
126 * @retval none
127 */
128void fx_app_thread_entry(ULONG thread_input)
129{
130  UINT sd_status = FX_SUCCESS;
131  /* USER CODE BEGIN fx_app_thread_entry 0 */
132
133  /* USER CODE END fx_app_thread_entry 0 */
134
135  /* Open the SD disk driver */
136  sd_status =  fx_media_open(&sdio_disk, FX_SD_VOLUME_NAME, fx_stm32_sd_driver, (VOID *)FX_NULL, (VOID *) fx_sd_media_memory, sizeof(fx_sd_media_memory));
137
138  /* Check the media open sd_status */
139  if (sd_status != FX_SUCCESS)
140  {
141    /* USER CODE BEGIN SD open error */
142    while(1);
143    /* USER CODE END SD open error */
144  }
145
146  /* USER CODE BEGIN fx_app_thread_entry 1 */
147
148  /* USER CODE END fx_app_thread_entry 1 */
149}
150
151/* USER CODE BEGIN 1 */
152
153/* USER CODE END 1 */
Note: See TracBrowser for help on using the repository browser.