OV7670 Support
Fork of BSP_DISCO_F746NG by
Revision 11:57139c9032e5, committed 2018-03-11
- Comitter:
- buyukesmeli
- Date:
- Sun Mar 11 08:03:46 2018 +0000
- Parent:
- 10:27e6daa4f2fe
- Commit message:
- some changes
Changed in this revision
--- a/Drivers/BSP/STM32746G-Discovery/stm32746g_discovery_sd.c Mon Mar 20 10:19:17 2017 +0000
+++ b/Drivers/BSP/STM32746G-Discovery/stm32746g_discovery_sd.c Sun Mar 11 08:03:46 2018 +0000
@@ -2,8 +2,8 @@
******************************************************************************
* @file stm32746g_discovery_sd.c
* @author MCD Application Team
- * @version V1.1.1
- * @date 02-June-2016
+ * @version V2.0.0
+ * @date 30-December-2016
* @brief This file includes the uSD card driver mounted on STM32746G-Discovery
* board.
@verbatim
@@ -42,7 +42,8 @@
are implemented by the user at application level.
o The SD erase block(s) is performed using the function BSP_SD_Erase() with specifying
the number of blocks to erase.
- o The SD runtime status is returned when calling the function BSP_SD_GetStatus().
+ o The SD runtime status is returned when calling the function BSP_SD_GetCardState().
+
@endverbatim
******************************************************************************
* @attention
@@ -115,7 +116,6 @@
* @{
*/
SD_HandleTypeDef uSdHandle;
-static SD_CardInfo uSdCardInfo;
/**
* @}
@@ -161,7 +161,7 @@
BSP_SD_MspInit(&uSdHandle, NULL);
/* HAL SD initialization */
- if(HAL_SD_Init(&uSdHandle, &uSdCardInfo) != SD_OK)
+ if(HAL_SD_Init(&uSdHandle) != HAL_OK)
{
sd_state = MSD_ERROR;
}
@@ -169,8 +169,8 @@
/* Configure SD Bus width */
if(sd_state == MSD_OK)
{
- /* Enable wide operation */
- if(HAL_SD_WideBusOperation_Config(&uSdHandle, SDMMC_BUS_WIDE_4B) != SD_OK)
+ /* Enable wide operation */
+ if(HAL_SD_ConfigWideBusOperation(&uSdHandle, SDMMC_BUS_WIDE_4B) != HAL_OK)
{
sd_state = MSD_ERROR;
}
@@ -248,14 +248,14 @@
/**
* @brief Reads block(s) from a specified address in an SD card, in polling mode.
* @param pData: Pointer to the buffer that will contain the data to transmit
- * @param ReadAddr: Address from where data is to be read
- * @param BlockSize: SD card data block size, that should be 512
- * @param NumOfBlocks: Number of SD blocks to read
+ * @param ReadAddr: Address from where data is to be read
+ * @param NumOfBlocks: Number of SD blocks to read
+ * @param Timeout: Timeout for read operation
* @retval SD status
*/
-uint8_t BSP_SD_ReadBlocks(uint32_t *pData, uint64_t ReadAddr, uint32_t BlockSize, uint32_t NumOfBlocks)
+uint8_t BSP_SD_ReadBlocks(uint32_t *pData, uint32_t ReadAddr, uint32_t NumOfBlocks, uint32_t Timeout)
{
- if(HAL_SD_ReadBlocks(&uSdHandle, pData, ReadAddr, BlockSize, NumOfBlocks) != SD_OK)
+ if(HAL_SD_ReadBlocks(&uSdHandle, (uint8_t *)pData, ReadAddr, NumOfBlocks, Timeout) != HAL_OK)
{
return MSD_ERROR;
}
@@ -268,14 +268,14 @@
/**
* @brief Writes block(s) to a specified address in an SD card, in polling mode.
* @param pData: Pointer to the buffer that will contain the data to transmit
- * @param WriteAddr: Address from where data is to be written
- * @param BlockSize: SD card data block size, that should be 512
+ * @param WriteAddr: Address from where data is to be written
* @param NumOfBlocks: Number of SD blocks to write
+ * @param Timeout: Timeout for write operation
* @retval SD status
*/
-uint8_t BSP_SD_WriteBlocks(uint32_t *pData, uint64_t WriteAddr, uint32_t BlockSize, uint32_t NumOfBlocks)
+uint8_t BSP_SD_WriteBlocks(uint32_t *pData, uint32_t WriteAddr, uint32_t NumOfBlocks, uint32_t Timeout)
{
- if(HAL_SD_WriteBlocks(&uSdHandle, pData, WriteAddr, BlockSize, NumOfBlocks) != SD_OK)
+ if(HAL_SD_WriteBlocks(&uSdHandle, (uint8_t *)pData, WriteAddr, NumOfBlocks, Timeout) != HAL_OK)
{
return MSD_ERROR;
}
@@ -288,69 +288,41 @@
/**
* @brief Reads block(s) from a specified address in an SD card, in DMA mode.
* @param pData: Pointer to the buffer that will contain the data to transmit
- * @param ReadAddr: Address from where data is to be read
- * @param BlockSize: SD card data block size, that should be 512
+ * @param ReadAddr: Address from where data is to be read
* @param NumOfBlocks: Number of SD blocks to read
* @retval SD status
*/
-uint8_t BSP_SD_ReadBlocks_DMA(uint32_t *pData, uint64_t ReadAddr, uint32_t BlockSize, uint32_t NumOfBlocks)
-{
- uint8_t sd_state = MSD_OK;
-
+uint8_t BSP_SD_ReadBlocks_DMA(uint32_t *pData, uint32_t ReadAddr, uint32_t NumOfBlocks)
+{
/* Read block(s) in DMA transfer mode */
- if(HAL_SD_ReadBlocks_DMA(&uSdHandle, pData, ReadAddr, BlockSize, NumOfBlocks) != SD_OK)
+ if(HAL_SD_ReadBlocks_DMA(&uSdHandle, (uint8_t *)pData, ReadAddr, NumOfBlocks) != HAL_OK)
{
- sd_state = MSD_ERROR;
+ return MSD_ERROR;
}
-
- /* Wait until transfer is complete */
- if(sd_state == MSD_OK)
+ else
{
- if(HAL_SD_CheckReadOperation(&uSdHandle, (uint32_t)SD_DATATIMEOUT) != SD_OK)
- {
- sd_state = MSD_ERROR;
- }
- else
- {
- sd_state = MSD_OK;
- }
+ return MSD_OK;
}
-
- return sd_state;
}
/**
* @brief Writes block(s) to a specified address in an SD card, in DMA mode.
* @param pData: Pointer to the buffer that will contain the data to transmit
- * @param WriteAddr: Address from where data is to be written
- * @param BlockSize: SD card data block size, that should be 512
+ * @param WriteAddr: Address from where data is to be written
* @param NumOfBlocks: Number of SD blocks to write
* @retval SD status
*/
-uint8_t BSP_SD_WriteBlocks_DMA(uint32_t *pData, uint64_t WriteAddr, uint32_t BlockSize, uint32_t NumOfBlocks)
-{
- uint8_t sd_state = MSD_OK;
-
+uint8_t BSP_SD_WriteBlocks_DMA(uint32_t *pData, uint32_t WriteAddr, uint32_t NumOfBlocks)
+{
/* Write block(s) in DMA transfer mode */
- if(HAL_SD_WriteBlocks_DMA(&uSdHandle, pData, WriteAddr, BlockSize, NumOfBlocks) != SD_OK)
+ if(HAL_SD_WriteBlocks_DMA(&uSdHandle, (uint8_t *)pData, WriteAddr, NumOfBlocks) != HAL_OK)
{
- sd_state = MSD_ERROR;
+ return MSD_ERROR;
}
-
- /* Wait until transfer is complete */
- if(sd_state == MSD_OK)
+ else
{
- if(HAL_SD_CheckWriteOperation(&uSdHandle, (uint32_t)SD_DATATIMEOUT) != SD_OK)
- {
- sd_state = MSD_ERROR;
- }
- else
- {
- sd_state = MSD_OK;
- }
+ return MSD_OK;
}
-
- return sd_state;
}
/**
@@ -359,9 +331,9 @@
* @param EndAddr: End byte address
* @retval SD status
*/
-uint8_t BSP_SD_Erase(uint64_t StartAddr, uint64_t EndAddr)
+uint8_t BSP_SD_Erase(uint32_t StartAddr, uint32_t EndAddr)
{
- if(HAL_SD_Erase(&uSdHandle, StartAddr, EndAddr) != SD_OK)
+ if(HAL_SD_Erase(&uSdHandle, StartAddr, EndAddr) != HAL_OK)
{
return MSD_ERROR;
}
@@ -408,7 +380,7 @@
HAL_GPIO_Init(GPIOD, &gpio_init_structure);
/* NVIC configuration for SDIO interrupts */
- HAL_NVIC_SetPriority(SDMMC1_IRQn, 5, 0);
+ HAL_NVIC_SetPriority(SDMMC1_IRQn, 0x0E, 0);
HAL_NVIC_EnableIRQ(SDMMC1_IRQn);
/* Configure DMA Rx parameters */
@@ -462,11 +434,11 @@
HAL_DMA_Init(&dma_tx_handle);
/* NVIC configuration for DMA transfer complete interrupt */
- HAL_NVIC_SetPriority(SD_DMAx_Rx_IRQn, 6, 0);
+ HAL_NVIC_SetPriority(SD_DMAx_Rx_IRQn, 0x0F, 0);
HAL_NVIC_EnableIRQ(SD_DMAx_Rx_IRQn);
/* NVIC configuration for DMA transfer complete interrupt */
- HAL_NVIC_SetPriority(SD_DMAx_Tx_IRQn, 6, 0);
+ HAL_NVIC_SetPriority(SD_DMAx_Tx_IRQn, 0x0F, 0);
HAL_NVIC_EnableIRQ(SD_DMAx_Tx_IRQn);
}
@@ -528,26 +500,87 @@
/**
* @brief Gets the current SD card data status.
+ * @param None
* @retval Data transfer state.
* This value can be one of the following values:
* @arg SD_TRANSFER_OK: No data transfer is acting
* @arg SD_TRANSFER_BUSY: Data transfer is acting
- * @arg SD_TRANSFER_ERROR: Data transfer error
*/
-HAL_SD_TransferStateTypedef BSP_SD_GetStatus(void)
+uint8_t BSP_SD_GetCardState(void)
{
- return(HAL_SD_GetStatus(&uSdHandle));
+ return((HAL_SD_GetCardState(&uSdHandle) == HAL_SD_CARD_TRANSFER ) ? SD_TRANSFER_OK : SD_TRANSFER_BUSY);
}
+
/**
* @brief Get SD information about specific SD card.
* @param CardInfo: Pointer to HAL_SD_CardInfoTypedef structure
* @retval None
*/
-void BSP_SD_GetCardInfo(HAL_SD_CardInfoTypedef *CardInfo)
+void BSP_SD_GetCardInfo(HAL_SD_CardInfoTypeDef *CardInfo)
{
/* Get SD card Information */
- HAL_SD_Get_CardInfo(&uSdHandle, CardInfo);
+ HAL_SD_GetCardInfo(&uSdHandle, CardInfo);
+}
+
+/**
+ * @brief SD Abort callbacks
+ * @param hsd: SD handle
+ * @retval None
+ */
+void HAL_SD_AbortCallback(SD_HandleTypeDef *hsd)
+{
+ BSP_SD_AbortCallback();
+}
+
+/**
+ * @brief Tx Transfer completed callbacks
+ * @param hsd: SD handle
+ * @retval None
+ */
+void HAL_SD_TxCpltCallback(SD_HandleTypeDef *hsd)
+{
+ BSP_SD_WriteCpltCallback();
+}
+
+/**
+ * @brief Rx Transfer completed callbacks
+ * @param hsd: SD handle
+ * @retval None
+ */
+void HAL_SD_RxCpltCallback(SD_HandleTypeDef *hsd)
+{
+ BSP_SD_ReadCpltCallback();
+}
+
+/**
+ * @brief BSP SD Abort callbacks
+ * @param None
+ * @retval None
+ */
+__weak void BSP_SD_AbortCallback(void)
+{
+
+}
+
+/**
+ * @brief BSP Tx Transfer completed callbacks
+ * @param None
+ * @retval None
+ */
+__weak void BSP_SD_WriteCpltCallback(void)
+{
+
+}
+
+/**
+ * @brief BSP Rx Transfer completed callbacks
+ * @param None
+ * @retval None
+ */
+__weak void BSP_SD_ReadCpltCallback(void)
+{
+
}
/**
--- a/Drivers/BSP/STM32746G-Discovery/stm32746g_discovery_sd.h Mon Mar 20 10:19:17 2017 +0000
+++ b/Drivers/BSP/STM32746G-Discovery/stm32746g_discovery_sd.h Sun Mar 11 08:03:46 2018 +0000
@@ -2,8 +2,8 @@
******************************************************************************
* @file stm32746g_discovery_sd.h
* @author MCD Application Team
- * @version V1.1.1
- * @date 02-June-2016
+ * @version V2.0.0
+ * @date 30-December-2016
* @brief This file contains the common defines and functions prototypes for
* the stm32746g_discovery_sd.c driver.
******************************************************************************
@@ -66,7 +66,7 @@
/**
* @brief SD Card information structure
*/
-#define SD_CardInfo HAL_SD_CardInfoTypedef
+#define BSP_SD_CardInfo HAL_SD_CardInfoTypeDef
/**
* @}
*/
@@ -77,6 +77,12 @@
#define MSD_OK ((uint8_t)0x00)
#define MSD_ERROR ((uint8_t)0x01)
#define MSD_ERROR_SD_NOT_PRESENT ((uint8_t)0x02)
+
+/**
+ * @brief SD transfer state definition
+ */
+#define SD_TRANSFER_OK ((uint8_t)0x00)
+#define SD_TRANSFER_BUSY ((uint8_t)0x01)
/** @defgroup STM32746G_DISCOVERY_SD_Exported_Constants STM32746G_DISCOVERY_SD Exported Constants
* @{
@@ -115,15 +121,13 @@
uint8_t BSP_SD_Init(void);
uint8_t BSP_SD_DeInit(void);
uint8_t BSP_SD_ITConfig(void);
-void BSP_SD_DetectIT(void);
-void BSP_SD_DetectCallback(void);
-uint8_t BSP_SD_ReadBlocks(uint32_t *pData, uint64_t ReadAddr, uint32_t BlockSize, uint32_t NumOfBlocks);
-uint8_t BSP_SD_WriteBlocks(uint32_t *pData, uint64_t WriteAddr, uint32_t BlockSize, uint32_t NumOfBlocks);
-uint8_t BSP_SD_ReadBlocks_DMA(uint32_t *pData, uint64_t ReadAddr, uint32_t BlockSize, uint32_t NumOfBlocks);
-uint8_t BSP_SD_WriteBlocks_DMA(uint32_t *pData, uint64_t WriteAddr, uint32_t BlockSize, uint32_t NumOfBlocks);
-uint8_t BSP_SD_Erase(uint64_t StartAddr, uint64_t EndAddr);
-HAL_SD_TransferStateTypedef BSP_SD_GetStatus(void);
-void BSP_SD_GetCardInfo(HAL_SD_CardInfoTypedef *CardInfo);
+uint8_t BSP_SD_ReadBlocks(uint32_t *pData, uint32_t ReadAddr, uint32_t NumOfBlocks, uint32_t Timeout);
+uint8_t BSP_SD_WriteBlocks(uint32_t *pData, uint32_t WriteAddr, uint32_t NumOfBlocks, uint32_t Timeout);
+uint8_t BSP_SD_ReadBlocks_DMA(uint32_t *pData, uint32_t ReadAddr, uint32_t NumOfBlocks);
+uint8_t BSP_SD_WriteBlocks_DMA(uint32_t *pData, uint32_t WriteAddr, uint32_t NumOfBlocks);
+uint8_t BSP_SD_Erase(uint32_t StartAddr, uint32_t EndAddr);
+uint8_t BSP_SD_GetCardState(void);
+void BSP_SD_GetCardInfo(HAL_SD_CardInfoTypeDef *CardInfo);
uint8_t BSP_SD_IsDetected(void);
/* These functions can be modified in case the current settings (e.g. DMA stream)
@@ -131,7 +135,9 @@
void BSP_SD_MspInit(SD_HandleTypeDef *hsd, void *Params);
void BSP_SD_Detect_MspInit(SD_HandleTypeDef *hsd, void *Params);
void BSP_SD_MspDeInit(SD_HandleTypeDef *hsd, void *Params);
-
+void BSP_SD_AbortCallback(void);
+void BSP_SD_WriteCpltCallback(void);
+void BSP_SD_ReadCpltCallback(void);
/**
* @}
*/
