Changeset 75 for ctrl/firmware/Main/CubeMX
- Timestamp:
- Jan 30, 2025, 8:24:51 AM (3 months ago)
- Location:
- ctrl/firmware/Main/CubeMX
- Files:
-
- 2 added
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
ctrl/firmware/Main/CubeMX/Core/Src/main.c
r74 r75 106 106 /* USER CODE BEGIN Init */ 107 107 108 SCB_DisableDCache(); 109 108 110 /* USER CODE END Init */ 109 111 … … 123 125 MX_USART3_UART_Init(); 124 126 MX_TIM3_Init(); 127 MX_FATFS_Init(); 125 128 MX_TIM8_Init(); 126 MX_FATFS_Init();127 129 /* USER CODE BEGIN 2 */ 128 130 -
ctrl/firmware/Main/CubeMX/Core/Src/rtc.c
r47 r75 35 35 /* USER CODE END RTC_Init 0 */ 36 36 37 RTC_TimeTypeDef sTime = {0}; 38 RTC_DateTypeDef sDate = {0}; 39 37 40 /* USER CODE BEGIN RTC_Init 1 */ 38 41 … … 50 53 hrtc.Init.OutPutRemap = RTC_OUTPUT_REMAP_NONE; 51 54 if (HAL_RTC_Init(&hrtc) != HAL_OK) 55 { 56 Error_Handler(); 57 } 58 59 /* USER CODE BEGIN Check_RTC_BKUP */ 60 61 /* USER CODE END Check_RTC_BKUP */ 62 63 /** Initialize RTC and set the Time and Date 64 */ 65 sTime.Hours = 0x0; 66 sTime.Minutes = 0x0; 67 sTime.Seconds = 0x0; 68 sTime.DayLightSaving = RTC_DAYLIGHTSAVING_NONE; 69 sTime.StoreOperation = RTC_STOREOPERATION_RESET; 70 if (HAL_RTC_SetTime(&hrtc, &sTime, RTC_FORMAT_BCD) != HAL_OK) 71 { 72 Error_Handler(); 73 } 74 sDate.WeekDay = RTC_WEEKDAY_MONDAY; 75 sDate.Month = RTC_MONTH_JANUARY; 76 sDate.Date = 0x1; 77 sDate.Year = 0x0; 78 79 if (HAL_RTC_SetDate(&hrtc, &sDate, RTC_FORMAT_BCD) != HAL_OK) 52 80 { 53 81 Error_Handler(); -
ctrl/firmware/Main/CubeMX/Core/Src/sdmmc.c
r74 r75 46 46 hsd1.Init.BusWide = SDMMC_BUS_WIDE_4B; 47 47 hsd1.Init.HardwareFlowControl = SDMMC_HARDWARE_FLOW_CONTROL_ENABLE; 48 hsd1.Init.ClockDiv = 0;48 hsd1.Init.ClockDiv = 1; 49 49 /* USER CODE BEGIN SDMMC1_Init 2 */ 50 50 … … 102 102 103 103 /* SDMMC1 interrupt Init */ 104 HAL_NVIC_SetPriority(SDMMC1_IRQn, 15, 0);104 HAL_NVIC_SetPriority(SDMMC1_IRQn, 5, 0); 105 105 HAL_NVIC_EnableIRQ(SDMMC1_IRQn); 106 106 /* USER CODE BEGIN SDMMC1_MspInit 1 */ -
ctrl/firmware/Main/CubeMX/FATFS/App/fatfs.c
r74 r75 38 38 } 39 39 40 /** 41 * @brief Gets Time from RTC 42 * @param None 43 * @retval Time in DWORD 44 */ 45 DWORD get_fattime(void) 46 { 47 /* USER CODE BEGIN get_fattime */ 48 return 0; 49 /* USER CODE END get_fattime */ 50 } 51 40 52 /* USER CODE BEGIN Application */ 41 53 -
ctrl/firmware/Main/CubeMX/FATFS/Target/ffconf.h
r74 r75 26 26 #include "stm32h7xx_hal.h" 27 27 #include "bsp_driver_sd.h" 28 #include "cmsis_os.h" /* _FS_REENTRANT set to 1 and CMSIS API chosen */ 28 29 29 30 /*-----------------------------------------------------------------------------/ … … 46 47 / 3: f_lseek() function is removed in addition to 2. */ 47 48 48 #define _USE_STRFUNC 2/* 0:Disable or 1-2:Enable */49 #define _USE_STRFUNC 0 /* 0:Disable or 1-2:Enable */ 49 50 /* This option switches string functions, f_gets(), f_putc(), f_puts() and 50 51 / f_printf(). … … 127 128 / ff_memfree(), must be added to the project. */ 128 129 129 #define _LFN_UNICODE 1/* 0:ANSI/OEM or 1:Unicode */130 #define _LFN_UNICODE 0 /* 0:ANSI/OEM or 1:Unicode */ 130 131 /* This option switches character encoding on the API. (0:ANSI/OEM or 1:UTF-16) 131 132 / To use Unicode string for the path name, enable LFN and set _LFN_UNICODE = 1. 132 133 / This option also affects behavior of string I/O functions. */ 133 134 134 #define _STRF_ENCODE 3135 #define _STRF_ENCODE 0 135 136 /* When _LFN_UNICODE == 1, this option selects the character encoding ON THE FILE to 136 137 / be read/written via string I/O functions, f_gets(), f_putc(), f_puts and f_printf(). … … 210 211 / buffer in the file system object (FATFS) is used for the file data transfer. */ 211 212 212 #define _FS_EXFAT 1213 #define _FS_EXFAT 0 213 214 /* This option switches support of exFAT file system. (0:Disable or 1:Enable) 214 215 / When enable exFAT, also LFN needs to be enabled. (_USE_LFN >= 1) 215 216 / Note that enabling exFAT discards C89 compatibility. */ 216 217 217 #define _FS_NORTC 1218 #define _FS_NORTC 0 218 219 #define _NORTC_MON 1 219 220 #define _NORTC_MDAY 1 … … 239 240 / lock control is independent of re-entrancy. */ 240 241 241 #define _FS_REENTRANT 0 /* 0:Disable or 1:Enable */ 242 #define _FS_REENTRANT 1 /* 0:Disable or 1:Enable */ 243 244 #define _USE_MUTEX 1 /* 0:Disable or 1:Enable */ 242 245 #define _FS_TIMEOUT 1000 /* Timeout period in unit of time ticks */ 243 #define _SYNC_t NULL246 #define _SYNC_t osMutexId_t 244 247 /* The option _FS_REENTRANT switches the re-entrancy (thread safe) of the FatFs 245 248 / module itself. Note that regardless of this option, file access to different … … 259 262 / included somewhere in the scope of ff.h. */ 260 263 261 /* define the ff_malloc ff_free macros as standard malloc free*/264 /* define the ff_malloc ff_free macros as FreeRTOS pvPortMalloc and vPortFree macros */ 262 265 #if !defined(ff_malloc) && !defined(ff_free) 263 #include <stdlib.h> 264 #define ff_malloc malloc 265 #define ff_free free 266 #define ff_malloc pvPortMalloc 267 #define ff_free vPortFree 266 268 #endif 267 269 -
ctrl/firmware/Main/CubeMX/FATFS/Target/sd_diskio.c
r74 r75 18 18 /* USER CODE END Header */ 19 19 20 /* Note: code generation based on sd_diskio_dma_ template_bspv1.c v2.1.421 as "Use dma template"is enabled. */20 /* Note: code generation based on sd_diskio_dma_rtos_template_bspv1.c v2.1.4 21 as FreeRTOS is enabled. */ 22 22 23 23 /* USER CODE BEGIN firstSection */ … … 30 30 31 31 #include <string.h> 32 #include <stdio.h> 32 33 33 34 /* Private typedef -----------------------------------------------------------*/ 34 35 /* Private define ------------------------------------------------------------*/ 35 36 36 /* 37 #define QUEUE_SIZE (uint32_t) 10 38 #define READ_CPLT_MSG (uint32_t) 1 39 #define WRITE_CPLT_MSG (uint32_t) 2 40 /* 41 ================================================================== 42 enable the defines below to send custom rtos messages 43 when an error or an abort occurs. 44 Notice: depending on the HAL/SD driver the HAL_SD_ErrorCallback() 45 may not be available. 46 See BSP_SD_ErrorCallback() and BSP_SD_AbortCallback() below 47 ================================================================== 48 49 #define RW_ERROR_MSG (uint32_t) 3 50 #define RW_ABORT_MSG (uint32_t) 4 51 */ 52 /* 37 53 * the following Timeout is useful to give the control back to the applications 38 54 * in case of errors in either BSP_SD_ReadCpltCallback() or BSP_SD_WriteCpltCallback() … … 60 76 */ 61 77 /* USER CODE BEGIN enableSDDmaCacheMaintenance */ 62 #define ENABLE_SD_DMA_CACHE_MAINTENANCE 178 //#define ENABLE_SD_DMA_CACHE_MAINTENANCE 1 63 79 /* USER CODE END enableSDDmaCacheMaintenance */ 64 80 … … 69 85 */ 70 86 /* USER CODE BEGIN enableScratchBuffer */ 71 #define ENABLE_SCRATCH_BUFFER87 //#define ENABLE_SCRATCH_BUFFER 72 88 /* USER CODE END enableScratchBuffer */ 73 89 … … 83 99 static volatile DSTATUS Stat = STA_NOINIT; 84 100 85 static volatile UINT WriteStatus = 0, ReadStatus = 0; 101 #if (osCMSIS <= 0x20000U) 102 static osMessageQId SDQueueID = NULL; 103 #else 104 static osMessageQueueId_t SDQueueID = NULL; 105 #endif 86 106 /* Private function prototypes -----------------------------------------------*/ 87 107 static DSTATUS SD_CheckStatus(BYTE lun); … … 118 138 static int SD_CheckStatusWithTimeout(uint32_t timeout) 119 139 { 120 uint32_t timer = HAL_GetTick(); 121 /* block until SDIO IP is ready again or a timeout occur */ 122 while(HAL_GetTick() - timer < timeout) 140 uint32_t timer; 141 /* block until SDIO peripheral is ready again or a timeout occur */ 142 #if (osCMSIS <= 0x20000U) 143 timer = osKernelSysTick(); 144 while( osKernelSysTick() - timer < timeout) 145 #else 146 timer = osKernelGetTickCount(); 147 while( osKernelGetTickCount() - timer < timeout) 148 #endif 123 149 { 124 150 if (BSP_SD_GetCardState() == SD_TRANSFER_OK) … … 135 161 Stat = STA_NOINIT; 136 162 137 if(BSP_SD_GetCardState() == MSD_OK)163 if(BSP_SD_GetCardState() == SD_TRANSFER_OK) 138 164 { 139 165 Stat &= ~STA_NOINIT; … … 150 176 DSTATUS SD_initialize(BYTE lun) 151 177 { 152 178 Stat = STA_NOINIT; 179 180 /* 181 * check that the kernel has been started before continuing 182 * as the osMessage API will fail otherwise 183 */ 184 #if (osCMSIS <= 0x20000U) 185 if(osKernelRunning()) 186 #else 187 if(osKernelGetState() == osKernelRunning) 188 #endif 189 { 153 190 #if !defined(DISABLE_SD_INIT) 154 191 155 if(BSP_SD_Init() == MSD_OK) 156 { 192 if(BSP_SD_Init() == MSD_OK) 193 { 194 Stat = SD_CheckStatus(lun); 195 } 196 197 #else 157 198 Stat = SD_CheckStatus(lun); 158 } 159 160 #else 161 Stat = SD_CheckStatus(lun); 162 #endif 199 #endif 200 201 /* 202 * if the SD is correctly initialized, create the operation queue 203 * if not already created 204 */ 205 206 if (Stat != STA_NOINIT) 207 { 208 if (SDQueueID == NULL) 209 { 210 #if (osCMSIS <= 0x20000U) 211 osMessageQDef(SD_Queue, QUEUE_SIZE, uint16_t); 212 SDQueueID = osMessageCreate (osMessageQ(SD_Queue), NULL); 213 #else 214 SDQueueID = osMessageQueueNew(QUEUE_SIZE, 2, NULL); 215 #endif 216 } 217 218 if (SDQueueID == NULL) 219 { 220 Stat |= STA_NOINIT; 221 } 222 } 223 } 163 224 164 225 return Stat; … … 189 250 DRESULT SD_read(BYTE lun, BYTE *buff, DWORD sector, UINT count) 190 251 { 252 uint8_t ret; 191 253 DRESULT res = RES_ERROR; 192 uint32_t timeout; 193 #if defined(ENABLE_SCRATCH_BUFFER) 194 uint8_t ret; 254 uint32_t timer; 255 #if (osCMSIS < 0x20000U) 256 osEvent event; 257 #else 258 uint16_t event; 259 osStatus_t status; 195 260 #endif 196 261 #if (ENABLE_SD_DMA_CACHE_MAINTENANCE == 1) 197 262 uint32_t alignedAddr; 198 263 #endif 199 200 264 /* 201 265 * ensure the SDCard is ready for a new operation … … 211 275 { 212 276 #endif 213 if(BSP_SD_ReadBlocks_DMA((uint32_t*)buff, 214 (uint32_t) (sector), 215 count) == MSD_OK) 277 /* Fast path cause destination buffer is correctly aligned */ 278 ret = BSP_SD_ReadBlocks_DMA((uint32_t*)buff, (uint32_t)(sector), count); 279 280 if (ret == MSD_OK) { 281 #if (osCMSIS < 0x20000U) 282 /* wait for a message from the queue or a timeout */ 283 event = osMessageGet(SDQueueID, SD_TIMEOUT); 284 285 if (event.status == osEventMessage) 216 286 { 217 ReadStatus = 0; 218 /* Wait that the reading process is completed or a timeout occurs */ 219 timeout = HAL_GetTick(); 220 while((ReadStatus == 0) && ((HAL_GetTick() - timeout) < SD_TIMEOUT)) 287 if (event.value.v == READ_CPLT_MSG) 221 288 { 222 } 223 /* in case of a timeout return error */ 224 if (ReadStatus == 0) 225 { 226 res = RES_ERROR; 227 } 228 else 229 { 230 ReadStatus = 0; 231 timeout = HAL_GetTick(); 232 233 while((HAL_GetTick() - timeout) < SD_TIMEOUT) 234 { 235 if (BSP_SD_GetCardState() == SD_TRANSFER_OK) 289 timer = osKernelSysTick(); 290 /* block until SDIO IP is ready or a timeout occur */ 291 while(osKernelSysTick() - timer <SD_TIMEOUT) 292 #else 293 status = osMessageQueueGet(SDQueueID, (void *)&event, NULL, SD_TIMEOUT); 294 if ((status == osOK) && (event == READ_CPLT_MSG)) 236 295 { 237 res = RES_OK; 296 timer = osKernelGetTickCount(); 297 /* block until SDIO IP is ready or a timeout occur */ 298 while(osKernelGetTickCount() - timer <SD_TIMEOUT) 299 #endif 300 { 301 if (BSP_SD_GetCardState() == SD_TRANSFER_OK) 302 { 303 res = RES_OK; 238 304 #if (ENABLE_SD_DMA_CACHE_MAINTENANCE == 1) 239 /* 240 the SCB_InvalidateDCache_by_Addr() requires a 32-Byte aligned address, 241 adjust the address and the D-Cache size to invalidate accordingly. 242 */ 243 alignedAddr = (uint32_t)buff & ~0x1F; 244 SCB_InvalidateDCache_by_Addr((uint32_t*)alignedAddr, count*BLOCKSIZE + ((uint32_t)buff - alignedAddr)); 245 #endif 246 break; 305 /* 306 the SCB_InvalidateDCache_by_Addr() requires a 32-Byte aligned address, 307 adjust the address and the D-Cache size to invalidate accordingly. 308 */ 309 alignedAddr = (uint32_t)buff & ~0x1F; 310 SCB_InvalidateDCache_by_Addr((uint32_t*)alignedAddr, count*BLOCKSIZE + ((uint32_t)buff - alignedAddr)); 311 #endif 312 break; 313 } 314 } 315 #if (osCMSIS < 0x20000U) 247 316 } 248 317 } 318 #else 249 319 } 250 } 320 #endif 321 } 322 251 323 #if defined(ENABLE_SCRATCH_BUFFER) 252 }324 } 253 325 else 254 326 { … … 256 328 int i; 257 329 258 for (i = 0; i < count; i++) { 330 for (i = 0; i < count; i++) 331 { 259 332 ret = BSP_SD_ReadBlocks_DMA((uint32_t*)scratch, (uint32_t)sector++, 1); 260 if (ret == MSD_OK) { 333 if (ret == MSD_OK ) 334 { 261 335 /* wait until the read is successful or a timeout occurs */ 262 263 timeout = HAL_GetTick(); 264 while((ReadStatus == 0) && ((HAL_GetTick() - timeout) < SD_TIMEOUT)) 336 #if (osCMSIS < 0x20000U) 337 /* wait for a message from the queue or a timeout */ 338 event = osMessageGet(SDQueueID, SD_TIMEOUT); 339 340 if (event.status == osEventMessage) 265 341 { 342 if (event.value.v == READ_CPLT_MSG) 343 { 344 timer = osKernelSysTick(); 345 /* block until SDIO IP is ready or a timeout occur */ 346 while(osKernelSysTick() - timer <SD_TIMEOUT) 347 #else 348 status = osMessageQueueGet(SDQueueID, (void *)&event, NULL, SD_TIMEOUT); 349 if ((status == osOK) && (event == READ_CPLT_MSG)) 350 { 351 timer = osKernelGetTickCount(); 352 /* block until SDIO IP is ready or a timeout occur */ 353 ret = MSD_ERROR; 354 while(osKernelGetTickCount() - timer < SD_TIMEOUT) 355 #endif 356 { 357 ret = BSP_SD_GetCardState(); 358 359 if (ret == MSD_OK) 360 { 361 break; 362 } 363 } 364 365 if (ret != MSD_OK) 366 { 367 break; 368 } 369 #if (osCMSIS < 0x20000U) 370 } 371 } 372 #else 266 373 } 267 if (ReadStatus == 0) 268 { 269 res = RES_ERROR; 270 break; 271 } 272 ReadStatus = 0; 273 374 #endif 274 375 #if (ENABLE_SD_DMA_CACHE_MAINTENANCE == 1) 275 376 /* … … 288 389 } 289 390 290 if ((i == count) && (ret == MSD_OK ))391 if ((i == count) && (ret == MSD_OK )) 291 392 res = RES_OK; 292 393 } 293 394 #endif 294 295 395 return res; 296 396 } … … 312 412 { 313 413 DRESULT res = RES_ERROR; 314 uint32_t timeout; 414 uint32_t timer; 415 416 #if (osCMSIS < 0x20000U) 417 osEvent event; 418 #else 419 uint16_t event; 420 osStatus_t status; 421 #endif 422 315 423 #if defined(ENABLE_SCRATCH_BUFFER) 316 uint8_t ret; 317 int i; 318 #endif 319 320 WriteStatus = 0; 424 int32_t ret; 425 #endif 426 427 /* 428 * ensure the SDCard is ready for a new operation 429 */ 430 431 if (SD_CheckStatusWithTimeout(SD_TIMEOUT) < 0) 432 { 433 return res; 434 } 435 436 #if defined(ENABLE_SCRATCH_BUFFER) 437 if (!((uint32_t)buff & 0x3)) 438 { 439 #endif 321 440 #if (ENABLE_SD_DMA_CACHE_MAINTENANCE == 1) 322 441 uint32_t alignedAddr; 323 #endif 324 325 if (SD_CheckStatusWithTimeout(SD_TIMEOUT) < 0) 326 { 327 return res; 328 } 329 330 #if defined(ENABLE_SCRATCH_BUFFER) 331 if (!((uint32_t)buff & 0x3)) 332 { 333 #endif 334 #if (ENABLE_SD_DMA_CACHE_MAINTENANCE == 1) 335 336 /* 442 /* 337 443 the SCB_CleanDCache_by_Addr() requires a 32-Byte aligned address 338 444 adjust the address and the D-Cache size to clean accordingly. 339 */ 340 alignedAddr = (uint32_t)buff & ~0x1F; 341 SCB_CleanDCache_by_Addr((uint32_t*)alignedAddr, count*BLOCKSIZE + ((uint32_t)buff - alignedAddr)); 342 #endif 343 344 if(BSP_SD_WriteBlocks_DMA((uint32_t*)buff, 345 (uint32_t)(sector), 346 count) == MSD_OK) 445 */ 446 alignedAddr = (uint32_t)buff & ~0x1F; 447 SCB_CleanDCache_by_Addr((uint32_t*)alignedAddr, count*BLOCKSIZE + ((uint32_t)buff - alignedAddr)); 448 #endif 449 450 if(BSP_SD_WriteBlocks_DMA((uint32_t*)buff, 451 (uint32_t) (sector), 452 count) == MSD_OK) 453 { 454 #if (osCMSIS < 0x20000U) 455 /* Get the message from the queue */ 456 event = osMessageGet(SDQueueID, SD_TIMEOUT); 457 458 if (event.status == osEventMessage) 347 459 { 348 /* Wait that writing process is completed or a timeout occurs */ 349 350 timeout = HAL_GetTick(); 351 while((WriteStatus == 0) && ((HAL_GetTick() - timeout) < SD_TIMEOUT)) 460 if (event.value.v == WRITE_CPLT_MSG) 352 461 { 353 } 354 /* in case of a timeout return error */ 355 if (WriteStatus == 0) 356 { 357 res = RES_ERROR; 358 } 359 else 360 { 361 WriteStatus = 0; 362 timeout = HAL_GetTick(); 363 364 while((HAL_GetTick() - timeout) < SD_TIMEOUT) 462 #else 463 status = osMessageQueueGet(SDQueueID, (void *)&event, NULL, SD_TIMEOUT); 464 if ((status == osOK) && (event == WRITE_CPLT_MSG)) 465 { 466 #endif 467 #if (osCMSIS < 0x20000U) 468 timer = osKernelSysTick(); 469 /* block until SDIO IP is ready or a timeout occur */ 470 while(osKernelSysTick() - timer < SD_TIMEOUT) 471 #else 472 timer = osKernelGetTickCount(); 473 /* block until SDIO IP is ready or a timeout occur */ 474 while(osKernelGetTickCount() - timer < SD_TIMEOUT) 475 #endif 365 476 { 366 477 if (BSP_SD_GetCardState() == SD_TRANSFER_OK) … … 370 481 } 371 482 } 483 #if (osCMSIS < 0x20000U) 372 484 } 373 485 } 486 #else 487 } 488 #endif 489 } 374 490 #if defined(ENABLE_SCRATCH_BUFFER) 375 }376 else377 {378 /* Slow path, fetch each sector a part and memcpy to destination buffer */ 491 else { 492 /* Slow path, fetch each sector a part and memcpy to destination buffer */ 493 int i; 494 379 495 #if (ENABLE_SD_DMA_CACHE_MAINTENANCE == 1) 380 /* 381 * invalidate the scratch buffer before the next write to get the actual data instead of the cached one 382 */ 383 SCB_InvalidateDCache_by_Addr((uint32_t*)scratch, BLOCKSIZE); 384 #endif 385 496 /* 497 * invalidate the scratch buffer before the next write to get the actual data instead of the cached one 498 */ 499 SCB_InvalidateDCache_by_Addr((uint32_t*)scratch, BLOCKSIZE); 500 #endif 386 501 for (i = 0; i < count; i++) 387 502 { 388 WriteStatus = 0; 389 390 memcpy((void *)scratch, (void *)buff, BLOCKSIZE); 503 memcpy((void *)scratch, buff, BLOCKSIZE); 391 504 buff += BLOCKSIZE; 392 505 393 506 ret = BSP_SD_WriteBlocks_DMA((uint32_t*)scratch, (uint32_t)sector++, 1); 394 if (ret == MSD_OK) { 507 if (ret == MSD_OK ) 508 { 509 /* wait until the read is successful or a timeout occurs */ 510 #if (osCMSIS < 0x20000U) 395 511 /* wait for a message from the queue or a timeout */ 396 timeout = HAL_GetTick(); 397 while((WriteStatus == 0) && ((HAL_GetTick() - timeout) < SD_TIMEOUT)) 512 event = osMessageGet(SDQueueID, SD_TIMEOUT); 513 514 if (event.status == osEventMessage) 398 515 { 516 if (event.value.v == READ_CPLT_MSG) 517 { 518 timer = osKernelSysTick(); 519 /* block until SDIO IP is ready or a timeout occur */ 520 while(osKernelSysTick() - timer <SD_TIMEOUT) 521 #else 522 status = osMessageQueueGet(SDQueueID, (void *)&event, NULL, SD_TIMEOUT); 523 if ((status == osOK) && (event == READ_CPLT_MSG)) 524 { 525 timer = osKernelGetTickCount(); 526 /* block until SDIO IP is ready or a timeout occur */ 527 ret = MSD_ERROR; 528 while(osKernelGetTickCount() - timer < SD_TIMEOUT) 529 #endif 530 { 531 ret = BSP_SD_GetCardState(); 532 533 if (ret == MSD_OK) 534 { 535 break; 536 } 537 } 538 539 if (ret != MSD_OK) 540 { 541 break; 542 } 543 #if (osCMSIS < 0x20000U) 544 } 545 } 546 #else 399 547 } 400 if (WriteStatus == 0) 401 { 402 break; 403 } 404 548 #endif 405 549 } 406 550 else … … 409 553 } 410 554 } 411 if ((i == count) && (ret == MSD_OK)) 555 556 if ((i == count) && (ret == MSD_OK )) 412 557 res = RES_OK; 413 558 } 414 #endif 559 560 } 561 #endif 562 415 563 return res; 416 564 } 417 #endif /* _USE_WRITE == 1 */565 #endif /* _USE_WRITE == 1 */ 418 566 419 567 /* USER CODE BEGIN beforeIoctlSection */ … … 486 634 { 487 635 488 WriteStatus = 1; 636 /* 637 * No need to add an "osKernelRunning()" check here, as the SD_initialize() 638 * is always called before any SD_Read()/SD_Write() call 639 */ 640 #if (osCMSIS < 0x20000U) 641 osMessagePut(SDQueueID, WRITE_CPLT_MSG, 0); 642 #else 643 const uint16_t msg = WRITE_CPLT_MSG; 644 osMessageQueuePut(SDQueueID, (const void *)&msg, 0, 0); 645 #endif 489 646 } 490 647 … … 496 653 void BSP_SD_ReadCpltCallback(void) 497 654 { 498 ReadStatus = 1; 655 /* 656 * No need to add an "osKernelRunning()" check here, as the SD_initialize() 657 * is always called before any SD_Read()/SD_Write() call 658 */ 659 #if (osCMSIS < 0x20000U) 660 osMessagePut(SDQueueID, READ_CPLT_MSG, 0); 661 #else 662 const uint16_t msg = READ_CPLT_MSG; 663 osMessageQueuePut(SDQueueID, (const void *)&msg, 0, 0); 664 #endif 499 665 } 500 666 -
ctrl/firmware/Main/CubeMX/FATFS/Target/sd_diskio.h
r74 r75 18 18 /* USER CODE END Header */ 19 19 20 /* Note: code generation based on sd_diskio_dma_ template.h */20 /* Note: code generation based on sd_diskio_dma_rtos_template.h */ 21 21 22 22 /* Define to prevent recursive inclusion -------------------------------------*/ -
ctrl/firmware/Main/CubeMX/Middlewares/Third_Party/FreeRTOS/Source/portable/MemMang/heap_4.c
r74 r75 62 62 extern uint8_t ucHeap[ configTOTAL_HEAP_SIZE ]; 63 63 #else 64 static uint8_t ucHeap[ configTOTAL_HEAP_SIZE ] __attribute__((section(".DTCM_RAM")));64 static uint8_t ucHeap[ configTOTAL_HEAP_SIZE ]; 65 65 #endif /* configAPPLICATION_ALLOCATED_HEAP */ 66 66 -
ctrl/firmware/Main/CubeMX/charger.ioc
r74 r75 67 67 Dma.USART3_TX.2.SyncSignalID=NONE 68 68 FATFS.BSP.number=1 69 FATFS.IPParameters=_USE_FIND,_USE_EXPAND,_USE_LABEL,_USE_LFN,_LFN_UNICODE,_MULTI_PARTITION,_FS_EXFAT,_USE_MUTEX,_FS_REENTRANT,_FS_NORTC,_NORTC_YEAR,_NORTC_MDAY,_NORTC_MON 70 FATFS._FS_EXFAT= 171 FATFS._FS_NORTC= 172 FATFS._FS_REENTRANT= 073 FATFS._LFN_UNICODE= 169 FATFS.IPParameters=_USE_FIND,_USE_EXPAND,_USE_LABEL,_USE_LFN,_LFN_UNICODE,_MULTI_PARTITION,_FS_EXFAT,_USE_MUTEX,_FS_REENTRANT,_FS_NORTC,_NORTC_YEAR,_NORTC_MDAY,_NORTC_MON,_STRF_ENCODE,_USE_STRFUNC 70 FATFS._FS_EXFAT=0 71 FATFS._FS_NORTC=0 72 FATFS._FS_REENTRANT=1 73 FATFS._LFN_UNICODE=0 74 74 FATFS._MULTI_PARTITION=0 75 75 FATFS._NORTC_MDAY=1 76 76 FATFS._NORTC_MON=1 77 77 FATFS._NORTC_YEAR=2025 78 FATFS._STRF_ENCODE=0 78 79 FATFS._USE_EXPAND=1 79 80 FATFS._USE_FIND=1 … … 81 82 FATFS._USE_LFN=2 82 83 FATFS._USE_MUTEX=1 84 FATFS._USE_STRFUNC=0 83 85 FATFS0.BSP.STBoard=false 84 86 FATFS0.BSP.api=Unknown … … 95 97 FREERTOS.INCLUDE_xTaskGetHandle=1 96 98 FREERTOS.IPParameters=Tasks01,configENABLE_FPU,configENABLE_BACKWARD_COMPATIBILITY,configUSE_TICKLESS_IDLE,configRECORD_STACK_HIGH_ADDRESS,configCHECK_FOR_STACK_OVERFLOW,INCLUDE_xTaskGetHandle,INCLUDE_uxTaskGetStackHighWaterMark2,FootprintOK 97 FREERTOS.Tasks01=mainTask,24, 128,mainTaskStart,As weak,NULL,Static,mainTaskBuffer,mainTaskControlBlock99 FREERTOS.Tasks01=mainTask,24,512,mainTaskStart,As weak,NULL,Static,mainTaskBuffer,mainTaskControlBlock 98 100 FREERTOS.configCHECK_FOR_STACK_OVERFLOW=2 99 101 FREERTOS.configENABLE_BACKWARD_COMPATIBILITY=0 … … 419 421 ProjectManager.UAScriptBeforePath= 420 422 ProjectManager.UnderRoot=true 421 ProjectManager.functionlistsort=1- SystemClock_Config-RCC-false-HAL-false,2-MX_GPIO_Init-GPIO-false-HAL-true,3-MX_DMA_Init-DMA-false-HAL-true,4-MX_RTC_Init-RTC-false-HAL-true,5-MX_SPI4_Init-SPI4-false-HAL-true,6-MX_SDMMC1_SD_Init-SDMMC1-false-HAL-true,7-MX_USART3_UART_Init-USART3-false-HAL-true,8-MX_TIM3_Init-TIM3-false-HAL-true,9-MX_TIM8_Init-TIM8-false-HAL-true,10-MX_FATFS_Init-FATFS-false-HAL-false,0-MX_CORTEX_M7_Init-CORTEX_M7-false-HAL-true423 ProjectManager.functionlistsort=1-MX_GPIO_Init-GPIO-false-HAL-true,2-MX_DMA_Init-DMA-false-HAL-true,3-MX_MDMA_Init-MDMA-false-HAL-true,3-MX_RTC_Init-RTC-false-HAL-true,4-MX_SPI4_Init-SPI4-false-HAL-true,5-MX_SDMMC1_SD_Init-SDMMC1-false-HAL-true,6-MX_USART3_UART_Init-USART3-false-HAL-true,7-MX_TIM3_Init-TIM3-false-HAL-true,8-SystemClock_Config-RCC-false-HAL-false,9-MX_FATFS_Init-FATFS-false-HAL-false,10-MX_TIM8_Init-TIM8-false-HAL-true,0-MX_CORTEX_M7_Init-CORTEX_M7-false-HAL-true 422 424 RCC.ADCFreq_Value=166666666.66666666 423 425 RCC.AHB12Freq_Value=100000000 … … 501 503 RCC.VCOInput2Freq_Value=8333333.333333333 502 504 RCC.VCOInput3Freq_Value=1000000 505 SDMMC1.ClockDiv=1 503 506 SDMMC1.ClockPowerSave=SDMMC_CLOCK_POWER_SAVE_ENABLE 504 507 SDMMC1.HardwareFlowControl=SDMMC_HARDWARE_FLOW_CONTROL_ENABLE 505 SDMMC1.IPParameters=ClockPowerSave,HardwareFlowControl 508 SDMMC1.IPParameters=ClockPowerSave,HardwareFlowControl,ClockDiv 506 509 SH.S_TIM3_CH2.0=TIM3_CH2,PWM Generation2 CH2 507 510 SH.S_TIM3_CH2.ConfNb=1
Note: See TracChangeset
for help on using the changeset viewer.