Rev 2 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2 | Rev 5 | ||
---|---|---|---|
Line 1... | Line 1... | ||
1 | /** |
1 | /** |
2 | ****************************************************************************** |
2 | ****************************************************************************** |
3 | * @file stm32f1xx_hal_sd.c |
3 | * @file stm32f1xx_hal_sd.c |
4 | * @author MCD Application Team |
4 | * @author MCD Application Team |
5 | * @version V1.0.1 |
5 | * @version V1.0.4 |
6 | * @date 31-July-2015 |
6 | * @date 29-April-2016 |
7 | * @brief SD card HAL module driver. |
7 | * @brief SD card HAL module driver. |
8 | * This file provides firmware functions to manage the following |
8 | * This file provides firmware functions to manage the following |
9 | * functionalities of the Secure Digital (SD) peripheral: |
9 | * functionalities of the Secure Digital (SD) peripheral: |
10 | * + Initialization and de-initialization functions |
10 | * + Initialization and de-initialization functions |
11 | * + IO operation functions |
11 | * + IO operation functions |
Line 147... | Line 147... | ||
147 | 147 | ||
148 | @endverbatim |
148 | @endverbatim |
149 | ****************************************************************************** |
149 | ****************************************************************************** |
150 | * @attention |
150 | * @attention |
151 | * |
151 | * |
152 | * <h2><center>© COPYRIGHT(c) 2015 STMicroelectronics</center></h2> |
152 | * <h2><center>© COPYRIGHT(c) 2016 STMicroelectronics</center></h2> |
153 | * |
153 | * |
154 | * Redistribution and use in source and binary forms, with or without modification, |
154 | * Redistribution and use in source and binary forms, with or without modification, |
155 | * are permitted provided that the following conditions are met: |
155 | * are permitted provided that the following conditions are met: |
156 | * 1. Redistributions of source code must retain the above copyright notice, |
156 | * 1. Redistributions of source code must retain the above copyright notice, |
157 | * this list of conditions and the following disclaimer. |
157 | * this list of conditions and the following disclaimer. |
Line 416... | Line 416... | ||
416 | * @param hsd: SD handle |
416 | * @param hsd: SD handle |
417 | * @retval None |
417 | * @retval None |
418 | */ |
418 | */ |
419 | __weak void HAL_SD_MspInit(SD_HandleTypeDef *hsd) |
419 | __weak void HAL_SD_MspInit(SD_HandleTypeDef *hsd) |
420 | { |
420 | { |
- | 421 | /* Prevent unused argument(s) compilation warning */ |
|
- | 422 | UNUSED(hsd); |
|
421 | /* NOTE : This function Should not be modified, when the callback is needed, |
423 | /* NOTE : This function Should not be modified, when the callback is needed, |
422 | the HAL_SD_MspInit could be implemented in the user file |
424 | the HAL_SD_MspInit could be implemented in the user file |
423 | */ |
425 | */ |
424 | } |
426 | } |
425 | 427 | ||
Line 428... | Line 430... | ||
428 | * @param hsd: SD handle |
430 | * @param hsd: SD handle |
429 | * @retval None |
431 | * @retval None |
430 | */ |
432 | */ |
431 | __weak void HAL_SD_MspDeInit(SD_HandleTypeDef *hsd) |
433 | __weak void HAL_SD_MspDeInit(SD_HandleTypeDef *hsd) |
432 | { |
434 | { |
- | 435 | /* Prevent unused argument(s) compilation warning */ |
|
- | 436 | UNUSED(hsd); |
|
433 | /* NOTE : This function Should not be modified, when the callback is needed, |
437 | /* NOTE : This function Should not be modified, when the callback is needed, |
434 | the HAL_SD_MspDeInit could be implemented in the user file |
438 | the HAL_SD_MspDeInit could be implemented in the user file |
435 | */ |
439 | */ |
436 | } |
440 | } |
437 | 441 | ||
Line 1400... | Line 1404... | ||
1400 | * @param hsd: SD handle |
1404 | * @param hsd: SD handle |
1401 | * @retval None |
1405 | * @retval None |
1402 | */ |
1406 | */ |
1403 | __weak void HAL_SD_XferCpltCallback(SD_HandleTypeDef *hsd) |
1407 | __weak void HAL_SD_XferCpltCallback(SD_HandleTypeDef *hsd) |
1404 | { |
1408 | { |
- | 1409 | /* Prevent unused argument(s) compilation warning */ |
|
- | 1410 | UNUSED(hsd); |
|
1405 | /* NOTE : This function Should not be modified, when the callback is needed, |
1411 | /* NOTE : This function Should not be modified, when the callback is needed, |
1406 | the HAL_SD_XferCpltCallback could be implemented in the user file |
1412 | the HAL_SD_XferCpltCallback could be implemented in the user file |
1407 | */ |
1413 | */ |
1408 | } |
1414 | } |
1409 | 1415 | ||
Line 1412... | Line 1418... | ||
1412 | * @param hsd: SD handle |
1418 | * @param hsd: SD handle |
1413 | * @retval None |
1419 | * @retval None |
1414 | */ |
1420 | */ |
1415 | __weak void HAL_SD_XferErrorCallback(SD_HandleTypeDef *hsd) |
1421 | __weak void HAL_SD_XferErrorCallback(SD_HandleTypeDef *hsd) |
1416 | { |
1422 | { |
- | 1423 | /* Prevent unused argument(s) compilation warning */ |
|
- | 1424 | UNUSED(hsd); |
|
1417 | /* NOTE : This function Should not be modified, when the callback is needed, |
1425 | /* NOTE : This function Should not be modified, when the callback is needed, |
1418 | the HAL_SD_XferErrorCallback could be implemented in the user file |
1426 | the HAL_SD_XferErrorCallback could be implemented in the user file |
1419 | */ |
1427 | */ |
1420 | } |
1428 | } |
1421 | 1429 | ||
Line 1425... | Line 1433... | ||
1425 | * the configuration information for the specified DMA module. |
1433 | * the configuration information for the specified DMA module. |
1426 | * @retval None |
1434 | * @retval None |
1427 | */ |
1435 | */ |
1428 | __weak void HAL_SD_DMA_RxCpltCallback(DMA_HandleTypeDef *hdma) |
1436 | __weak void HAL_SD_DMA_RxCpltCallback(DMA_HandleTypeDef *hdma) |
1429 | { |
1437 | { |
- | 1438 | /* Prevent unused argument(s) compilation warning */ |
|
- | 1439 | UNUSED(hdma); |
|
1430 | /* NOTE : This function Should not be modified, when the callback is needed, |
1440 | /* NOTE : This function Should not be modified, when the callback is needed, |
1431 | the HAL_SD_DMA_RxCpltCallback could be implemented in the user file |
1441 | the HAL_SD_DMA_RxCpltCallback could be implemented in the user file |
1432 | */ |
1442 | */ |
1433 | } |
1443 | } |
1434 | 1444 | ||
Line 1438... | Line 1448... | ||
1438 | * the configuration information for the specified DMA module. |
1448 | * the configuration information for the specified DMA module. |
1439 | * @retval None |
1449 | * @retval None |
1440 | */ |
1450 | */ |
1441 | __weak void HAL_SD_DMA_RxErrorCallback(DMA_HandleTypeDef *hdma) |
1451 | __weak void HAL_SD_DMA_RxErrorCallback(DMA_HandleTypeDef *hdma) |
1442 | { |
1452 | { |
- | 1453 | /* Prevent unused argument(s) compilation warning */ |
|
- | 1454 | UNUSED(hdma); |
|
1443 | /* NOTE : This function Should not be modified, when the callback is needed, |
1455 | /* NOTE : This function Should not be modified, when the callback is needed, |
1444 | the HAL_SD_DMA_RxErrorCallback could be implemented in the user file |
1456 | the HAL_SD_DMA_RxErrorCallback could be implemented in the user file |
1445 | */ |
1457 | */ |
1446 | } |
1458 | } |
1447 | 1459 | ||
Line 1451... | Line 1463... | ||
1451 | * the configuration information for the specified DMA module. |
1463 | * the configuration information for the specified DMA module. |
1452 | * @retval None |
1464 | * @retval None |
1453 | */ |
1465 | */ |
1454 | __weak void HAL_SD_DMA_TxCpltCallback(DMA_HandleTypeDef *hdma) |
1466 | __weak void HAL_SD_DMA_TxCpltCallback(DMA_HandleTypeDef *hdma) |
1455 | { |
1467 | { |
- | 1468 | /* Prevent unused argument(s) compilation warning */ |
|
- | 1469 | UNUSED(hdma); |
|
1456 | /* NOTE : This function Should not be modified, when the callback is needed, |
1470 | /* NOTE : This function Should not be modified, when the callback is needed, |
1457 | the HAL_SD_DMA_TxCpltCallback could be implemented in the user file |
1471 | the HAL_SD_DMA_TxCpltCallback could be implemented in the user file |
1458 | */ |
1472 | */ |
1459 | } |
1473 | } |
1460 | 1474 | ||
Line 1464... | Line 1478... | ||
1464 | * the configuration information for the specified DMA module. |
1478 | * the configuration information for the specified DMA module. |
1465 | * @retval None |
1479 | * @retval None |
1466 | */ |
1480 | */ |
1467 | __weak void HAL_SD_DMA_TxErrorCallback(DMA_HandleTypeDef *hdma) |
1481 | __weak void HAL_SD_DMA_TxErrorCallback(DMA_HandleTypeDef *hdma) |
1468 | { |
1482 | { |
- | 1483 | /* Prevent unused argument(s) compilation warning */ |
|
- | 1484 | UNUSED(hdma); |
|
1469 | /* NOTE : This function Should not be modified, when the callback is needed, |
1485 | /* NOTE : This function Should not be modified, when the callback is needed, |
1470 | the HAL_SD_DMA_TxErrorCallback could be implemented in the user file |
1486 | the HAL_SD_DMA_TxErrorCallback could be implemented in the user file |
1471 | */ |
1487 | */ |
1472 | } |
1488 | } |
1473 | 1489 | ||
Line 1586... | Line 1602... | ||
1586 | pCardInfo->SD_csd.DeviceSize |= (tmp); |
1602 | pCardInfo->SD_csd.DeviceSize |= (tmp); |
1587 | 1603 | ||
1588 | /* Byte 10 */ |
1604 | /* Byte 10 */ |
1589 | tmp = (uint8_t)((hsd->CSD[2] & 0x0000FF00) >> 8); |
1605 | tmp = (uint8_t)((hsd->CSD[2] & 0x0000FF00) >> 8); |
1590 | 1606 | ||
1591 | pCardInfo->CardCapacity = ((pCardInfo->SD_csd.DeviceSize + 1)) * 512 * 1024; |
1607 | pCardInfo->CardCapacity = (uint64_t)(((uint64_t)pCardInfo->SD_csd.DeviceSize + 1) * 512 * 1024); |
1592 | pCardInfo->CardBlockSize = 512; |
1608 | pCardInfo->CardBlockSize = 512; |
1593 | } |
1609 | } |
1594 | else |
1610 | else |
1595 | { |
1611 | { |
1596 | /* Not supported card type */ |
1612 | /* Not supported card type */ |