source: ctrl/firmware/Main/CubeMX/FATFS/Target/bsp_driver_sd.h

Last change on this file was 74, checked in by Zed, 3 months ago

FatFs? with DMA were implemented.

File size: 3.1 KB
Line 
1/* USER CODE BEGIN Header */
2/**
3 ******************************************************************************
4  * @file    bsp_driver_sd.h (based on stm32h743i_eval_sd.h)
5  * @brief   This file contains the common defines and functions prototypes for
6  *          the bsp_driver_sd.c driver.
7  ******************************************************************************
8  * @attention
9  *
10  * Copyright (c) 2025 STMicroelectronics.
11  * All rights reserved.
12  *
13  * This software is licensed under terms that can be found in the LICENSE file
14  * in the root directory of this software component.
15  * If no LICENSE file comes with this software, it is provided AS-IS.
16  *
17  ******************************************************************************
18  */
19/* USER CODE END Header */
20
21/* Define to prevent recursive inclusion -------------------------------------*/
22#ifndef __STM32H7_SD_H
23#define __STM32H7_SD_H
24
25#ifdef __cplusplus
26 extern "C" {
27#endif
28
29/* Includes ------------------------------------------------------------------*/
30#include "stm32h7xx_hal.h"
31#include "fatfs_platform.h"
32
33/* Exported types --------------------------------------------------------*/
34/**
35  * @brief SD Card information structure
36  */
37#define BSP_SD_CardInfo HAL_SD_CardInfoTypeDef
38
39/* Exported constants --------------------------------------------------------*/
40/**
41  * @brief  SD status structure definition
42  */
43#define   MSD_OK                        ((uint8_t)0x00)
44#define   MSD_ERROR                     ((uint8_t)0x01)
45#define   MSD_ERROR_SD_NOT_PRESENT      ((uint8_t)0x02)
46
47/**
48  * @brief  SD transfer state definition
49  */
50#define   SD_TRANSFER_OK                ((uint8_t)0x00)
51#define   SD_TRANSFER_BUSY              ((uint8_t)0x01)
52
53#define SD_PRESENT               ((uint8_t)0x01)
54#define SD_NOT_PRESENT           ((uint8_t)0x00)
55#define SD_DATATIMEOUT           ((uint32_t)100000000)
56
57/* USER CODE BEGIN BSP_H_CODE */
58#define SD_DetectIRQHandler()             HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_8)
59
60/* Exported functions --------------------------------------------------------*/
61uint8_t BSP_SD_Init(void);
62uint8_t BSP_SD_ITConfig(void);
63uint8_t BSP_SD_ReadBlocks(uint32_t *pData, uint32_t ReadAddr, uint32_t NumOfBlocks, uint32_t Timeout);
64uint8_t BSP_SD_WriteBlocks(uint32_t *pData, uint32_t WriteAddr, uint32_t NumOfBlocks, uint32_t Timeout);
65uint8_t BSP_SD_ReadBlocks_DMA(uint32_t *pData, uint32_t ReadAddr, uint32_t NumOfBlocks);
66uint8_t BSP_SD_WriteBlocks_DMA(uint32_t *pData, uint32_t WriteAddr, uint32_t NumOfBlocks);
67uint8_t BSP_SD_Erase(uint32_t StartAddr, uint32_t EndAddr);
68uint8_t BSP_SD_GetCardState(void);
69void    BSP_SD_GetCardInfo(BSP_SD_CardInfo *CardInfo);
70uint8_t BSP_SD_IsDetected(void);
71
72/* These functions can be modified in case the current settings (e.g. DMA stream)
73   need to be changed for specific application needs */
74void    BSP_SD_AbortCallback(void);
75void    BSP_SD_WriteCpltCallback(void);
76void    BSP_SD_ReadCpltCallback(void);
77/* USER CODE END BSP_H_CODE */
78
79#ifdef __cplusplus
80}
81#endif
82
83#endif /* __STM32H7_SD_H */
Note: See TracBrowser for help on using the repository browser.