Select one of the symbols to view example projects that use it.
 
Outline
...
...
#include "fx_stm32_sd_driver.h"
transfer_semaphore
fx_stm32_sd_init(UINT)
fx_stm32_sd_deinit(UINT)
fx_stm32_sd_get_status(UINT)
fx_stm32_sd_read_blocks(UINT, UINT *, UINT, UINT)
fx_stm32_sd_write_blocks(UINT, UINT *, UINT, UINT)
HAL_SD_TxCpltCallback(SD_HandleTypeDef *)
HAL_SD_RxCpltCallback(SD_HandleTypeDef *)
Files
loading...
CodeScopeSTM32 Libraries and SamplesUx_Device_CDC_ECMFileX/Target/fx_stm32_sd_driver_glue.c
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
/**************************************************************************/ /* */ /* Copyright (c) Microsoft Corporation. All rights reserved. */ /* */ /* This software is licensed under the Microsoft Software License */ /* Terms for Microsoft Azure RTOS. Full text of the license can be */ /* found in the LICENSE file at https://aka.ms/AzureRTOS_EULA */ /* and in the root directory of this software. */ /* */... /**************************************************************************/ #include "fx_stm32_sd_driver.h" TX_SEMAPHORE transfer_semaphore; extern SD_HandleTypeDef hsd; extern void MX_SDIO_SD_Init(void); /* USER CODE BEGIN 0 */ /* USER CODE END 0 */ /** * @brief Initializes the SD IP instance * @param UINT instance SD instance to initialize * @retval 0 on success error value otherwise *//* ... */ INT fx_stm32_sd_init(UINT instance) { INT ret = 0; /* USER CODE BEGIN PRE_FX_SD_INIT */ UNUSED(instance); /* USER CODE END PRE_FX_SD_INIT */ #if (FX_STM32_SD_INIT == 1) MX_SDIO_SD_Init(); #endif /* USER CODE BEGIN POST_FX_SD_INIT */ /* USER CODE END POST_FX_SD_INIT */ return ret; }{ ... } /** * @brief Deinitializes the SD IP instance * @param UINT instance SD instance to deinitialize * @retval 0 on success error value otherwise *//* ... */ INT fx_stm32_sd_deinit(UINT instance) { INT ret = 0; /* USER CODE BEGIN PRE_FX_SD_DEINIT */ UNUSED(instance); /* USER CODE END PRE_FX_SD_DEINIT */ if(HAL_SD_DeInit(&hsd) != HAL_OK) { ret = 1; }if (HAL_SD_DeInit(&hsd) != HAL_OK) { ... } /* USER CODE BEGIN POST_FX_SD_DEINIT */ /* USER CODE END POST_FX_SD_DEINIT */ return ret; }{ ... } /** * @brief Check the SD IP status. * @param UINT instance SD instance to check * @retval 0 when ready 1 when busy *//* ... */ INT fx_stm32_sd_get_status(UINT instance) { INT ret = 0; /* USER CODE BEGIN PRE_GET_STATUS */ UNUSED(instance); /* USER CODE END PRE_GET_STATUS */ if(HAL_SD_GetCardState(&hsd) != HAL_SD_CARD_TRANSFER) { ret = 1; }if (HAL_SD_GetCardState(&hsd) != HAL_SD_CARD_TRANSFER) { ... } /* USER CODE BEGIN POST_GET_STATUS */ /* USER CODE END POST_GET_STATUS */ return ret; }{ ... } /** * @brief Read Data from the SD device into a buffer. * @param UINT instance SD IP instance to read from. * @param UINT *buffer buffer into which the data is to be read. * @param UINT start_block the first block to start reading from. * @param UINT total_blocks total number of blocks to read. * @retval 0 on success error code otherwise *//* ... */ INT fx_stm32_sd_read_blocks(UINT instance, UINT *buffer, UINT start_block, UINT total_blocks) { INT ret = 0; /* USER CODE BEGIN PRE_READ_BLOCKS */ UNUSED(instance); /* USER CODE END PRE_READ_BLOCKS */ if(HAL_SD_ReadBlocks_DMA(&hsd, (uint8_t *)buffer, start_block, total_blocks) != HAL_OK) { ret = 1; }if (HAL_SD_ReadBlocks_DMA(&hsd, (uint8_t *)buffer, start_block, total_blocks) != HAL_OK) { ... } /* USER CODE BEGIN POST_READ_BLOCKS */ /* USER CODE END POST_READ_BLOCKS */ return ret; }{ ... } /** * @brief Write data buffer into the SD device. * @param UINT instance SD IP instance to write into. * @param UINT *buffer buffer to write into the SD device. * @param UINT start_block the first block to start writing into. * @param UINT total_blocks total number of blocks to write. * @retval 0 on success error code otherwise *//* ... */ INT fx_stm32_sd_write_blocks(UINT instance, UINT *buffer, UINT start_block, UINT total_blocks) { INT ret = 0; /* USER CODE BEGIN PRE_WRITE_BLOCKS */ UNUSED(instance); /* USER CODE END PRE_WRITE_BLOCKS */ if(HAL_SD_WriteBlocks_DMA(&hsd, (uint8_t *)buffer, start_block, total_blocks) != HAL_OK) { ret = 1; }if (HAL_SD_WriteBlocks_DMA(&hsd, (uint8_t *)buffer, start_block, total_blocks) != HAL_OK) { ... } /* USER CODE BEGIN POST_WRITE_BLOCKS */ /* USER CODE END POST_WRITE_BLOCKS */ return ret; }{ ... } /** * @brief SD DMA Tx Transfer completed callbacks * @param Instance the sd instance * @retval None *//* ... */ void HAL_SD_TxCpltCallback(SD_HandleTypeDef *hsd) { /* USER CODE BEGIN PRE_TX_CMPLT */ /* USER CODE END PRE_TX_CMPLT */ tx_semaphore_put(&transfer_semaphore); /* USER CODE BEGIN POST_TX_CMPLT */ /* USER CODE END POST_TX_CMPLT */ }{ ... } /** * @brief SD DMA Rx Transfer completed callbacks * @param Instance the sd instance * @retval None *//* ... */ void HAL_SD_RxCpltCallback(SD_HandleTypeDef *hsd) { /* USER CODE BEGIN PRE_RX_CMPLT */ /* USER CODE END PRE_RX_CMPLT */ tx_semaphore_put(&transfer_semaphore); /* USER CODE BEGIN POST_RX_CMPLT */ /* USER CODE END POST_RX_CMPLT */ }{ ... } /* USER CODE BEGIN 1 */ ... /* USER CODE END 1 */