Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
M
micropython
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
card10
micropython
Commits
7a55c1a8
Commit
7a55c1a8
authored
9 years ago
by
Dave Hylands
Committed by
Damien George
9 years ago
Browse files
Options
Downloads
Patches
Plain Diff
stmhal: Port of f4 hal commit
1d7fb82f
to f7 hal
parent
28e51c9e
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
stmhal/hal/f7/inc/stm32f7xx_hal_sd.h
+6
-4
6 additions, 4 deletions
stmhal/hal/f7/inc/stm32f7xx_hal_sd.h
stmhal/hal/f7/src/stm32f7xx_hal_sd.c
+40
-16
40 additions, 16 deletions
stmhal/hal/f7/src/stm32f7xx_hal_sd.c
with
46 additions
and
20 deletions
stmhal/hal/f7/inc/stm32f7xx_hal_sd.h
+
6
−
4
View file @
7a55c1a8
...
...
@@ -643,8 +643,9 @@ void HAL_SD_MspDeInit(SD_HandleTypeDef *hsd);
* @{
*/
/* Blocking mode: Polling */
HAL_SD_ErrorTypedef
HAL_SD_ReadBlocks
(
SD_HandleTypeDef
*
hsd
,
uint32_t
*
pReadBuffer
,
uint64_t
ReadAddr
,
uint32_t
BlockSize
,
uint32_t
NumberOfBlocks
);
HAL_SD_ErrorTypedef
HAL_SD_WriteBlocks
(
SD_HandleTypeDef
*
hsd
,
uint32_t
*
pWriteBuffer
,
uint64_t
WriteAddr
,
uint32_t
BlockSize
,
uint32_t
NumberOfBlocks
);
// dpgeorge: read/write functions renamed to emphasise that address is given by block number
HAL_SD_ErrorTypedef
HAL_SD_ReadBlocks_BlockNumber
(
SD_HandleTypeDef
*
hsd
,
uint32_t
*
pReadBuffer
,
uint32_t
BlockNumber
,
uint32_t
BlockSize
,
uint32_t
NumberOfBlocks
);
HAL_SD_ErrorTypedef
HAL_SD_WriteBlocks_BlockNumber
(
SD_HandleTypeDef
*
hsd
,
uint32_t
*
pWriteBuffer
,
uint32_t
BlockNumber
,
uint32_t
BlockSize
,
uint32_t
NumberOfBlocks
);
HAL_SD_ErrorTypedef
HAL_SD_Erase
(
SD_HandleTypeDef
*
hsd
,
uint64_t
startaddr
,
uint64_t
endaddr
);
/* Non-Blocking mode: Interrupt */
...
...
@@ -659,8 +660,9 @@ void HAL_SD_XferCpltCallback(SD_HandleTypeDef *hsd);
void
HAL_SD_XferErrorCallback
(
SD_HandleTypeDef
*
hsd
);
/* Non-Blocking mode: DMA */
HAL_SD_ErrorTypedef
HAL_SD_ReadBlocks_DMA
(
SD_HandleTypeDef
*
hsd
,
uint32_t
*
pReadBuffer
,
uint64_t
ReadAddr
,
uint32_t
BlockSize
,
uint32_t
NumberOfBlocks
);
HAL_SD_ErrorTypedef
HAL_SD_WriteBlocks_DMA
(
SD_HandleTypeDef
*
hsd
,
uint32_t
*
pWriteBuffer
,
uint64_t
WriteAddr
,
uint32_t
BlockSize
,
uint32_t
NumberOfBlocks
);
// dpgeorge: read/write functions renamed to emphasise that address is given by block number
HAL_SD_ErrorTypedef
HAL_SD_ReadBlocks_BlockNumber_DMA
(
SD_HandleTypeDef
*
hsd
,
uint32_t
*
pReadBuffer
,
uint32_t
BlockNumber
,
uint32_t
BlockSize
,
uint32_t
NumberOfBlocks
);
HAL_SD_ErrorTypedef
HAL_SD_WriteBlocks_BlockNumber_DMA
(
SD_HandleTypeDef
*
hsd
,
uint32_t
*
pWriteBuffer
,
uint32_t
BlockNumber
,
uint32_t
BlockSize
,
uint32_t
NumberOfBlocks
);
HAL_SD_ErrorTypedef
HAL_SD_CheckWriteOperation
(
SD_HandleTypeDef
*
hsd
,
uint32_t
Timeout
);
HAL_SD_ErrorTypedef
HAL_SD_CheckReadOperation
(
SD_HandleTypeDef
*
hsd
,
uint32_t
Timeout
);
/**
...
...
This diff is collapsed.
Click to expand it.
stmhal/hal/f7/src/stm32f7xx_hal_sd.c
+
40
−
16
View file @
7a55c1a8
...
...
@@ -453,14 +453,14 @@ __weak void HAL_SD_MspDeInit(SD_HandleTypeDef *hsd)
* @brief Reads block(s) from a specified address in a card. The Data transfer
* is managed by polling mode.
* @param hsd: SD handle
* @param pReadBuffer: pointer to the buffer that will contain the received data
* @param
ReadAddr: Address
from where data is to be read
* @param pReadBuffer: pointer to the buffer that will contain the received data
* @param
BlockNumber: Block number
from where data is to be read
(byte address = BlockNumber * BlockSize)
* @param BlockSize: SD card Data block size
* @note BlockSize must be 512 bytes.
* @param NumberOfBlocks: Number of SD blocks to read
* @retval SD Card error state
*/
HAL_SD_ErrorTypedef
HAL_SD_ReadBlocks
(
SD_HandleTypeDef
*
hsd
,
uint32_t
*
pReadBuffer
,
uint
64
_t
ReadAdd
r
,
uint32_t
BlockSize
,
uint32_t
NumberOfBlocks
)
HAL_SD_ErrorTypedef
HAL_SD_ReadBlocks
_BlockNumber
(
SD_HandleTypeDef
*
hsd
,
uint32_t
*
pReadBuffer
,
uint
32
_t
BlockNumbe
r
,
uint32_t
BlockSize
,
uint32_t
NumberOfBlocks
)
{
SDMMC_CmdInitTypeDef
sdmmc_cmdinitstructure
;
SDMMC_DataInitTypeDef
sdmmc_datainitstructure
;
...
...
@@ -470,10 +470,16 @@ HAL_SD_ErrorTypedef HAL_SD_ReadBlocks(SD_HandleTypeDef *hsd, uint32_t *pReadBuff
/* Initialize data control register */
hsd
->
Instance
->
DCTRL
=
0
;
uint32_t
ReadAddr
;
if
(
hsd
->
CardType
==
HIGH_CAPACITY_SD_CARD
)
{
BlockSize
=
512
;
ReadAddr
/=
512
;
ReadAddr
=
BlockNumber
;
}
else
{
// should not overflow for standard-capacity cards
ReadAddr
=
BlockNumber
*
BlockSize
;
}
/* Set Block Size for Card */
...
...
@@ -512,7 +518,7 @@ HAL_SD_ErrorTypedef HAL_SD_ReadBlocks(SD_HandleTypeDef *hsd, uint32_t *pReadBuff
sdmmc_cmdinitstructure
.
CmdIndex
=
SD_CMD_READ_SINGLE_BLOCK
;
}
sdmmc_cmdinitstructure
.
Argument
=
(
uint32_t
)
ReadAddr
;
sdmmc_cmdinitstructure
.
Argument
=
ReadAddr
;
SDMMC_SendCommand
(
hsd
->
Instance
,
&
sdmmc_cmdinitstructure
);
/* Read block(s) in polling mode */
...
...
@@ -630,13 +636,13 @@ HAL_SD_ErrorTypedef HAL_SD_ReadBlocks(SD_HandleTypeDef *hsd, uint32_t *pReadBuff
* transfer is managed by polling mode.
* @param hsd: SD handle
* @param pWriteBuffer: pointer to the buffer that will contain the data to transmit
* @param
WriteAddr: Address from where data is to be written
* @param
BlockNumber: Block number to where data is to be written (byte address = BlockNumber * BlockSize)
* @param BlockSize: SD card Data block size
* @note BlockSize must be 512 bytes.
* @param NumberOfBlocks: Number of SD blocks to write
* @retval SD Card error state
*/
HAL_SD_ErrorTypedef
HAL_SD_WriteBlocks
(
SD_HandleTypeDef
*
hsd
,
uint32_t
*
pWriteBuffer
,
uint
64
_t
WriteAdd
r
,
uint32_t
BlockSize
,
uint32_t
NumberOfBlocks
)
HAL_SD_ErrorTypedef
HAL_SD_WriteBlocks
_BlockNumber
(
SD_HandleTypeDef
*
hsd
,
uint32_t
*
pWriteBuffer
,
uint
32
_t
BlockNumbe
r
,
uint32_t
BlockSize
,
uint32_t
NumberOfBlocks
)
{
SDMMC_CmdInitTypeDef
sdmmc_cmdinitstructure
;
SDMMC_DataInitTypeDef
sdmmc_datainitstructure
;
...
...
@@ -648,10 +654,16 @@ HAL_SD_ErrorTypedef HAL_SD_WriteBlocks(SD_HandleTypeDef *hsd, uint32_t *pWriteBu
/* Initialize data control register */
hsd
->
Instance
->
DCTRL
=
0
;
uint32_t
WriteAddr
;
if
(
hsd
->
CardType
==
HIGH_CAPACITY_SD_CARD
)
{
BlockSize
=
512
;
WriteAddr
/=
512
;
WriteAddr
=
BlockNumber
;
}
else
{
// should not overflow for standard-capacity cards
WriteAddr
=
BlockNumber
*
BlockSize
;
}
/* Set Block Size for Card */
...
...
@@ -681,7 +693,7 @@ HAL_SD_ErrorTypedef HAL_SD_WriteBlocks(SD_HandleTypeDef *hsd, uint32_t *pWriteBu
sdmmc_cmdinitstructure
.
CmdIndex
=
SD_CMD_WRITE_SINGLE_BLOCK
;
}
sdmmc_cmdinitstructure
.
Argument
=
(
uint32_t
)
WriteAddr
;
sdmmc_cmdinitstructure
.
Argument
=
WriteAddr
;
SDMMC_SendCommand
(
hsd
->
Instance
,
&
sdmmc_cmdinitstructure
);
/* Check for error conditions */
...
...
@@ -840,13 +852,13 @@ HAL_SD_ErrorTypedef HAL_SD_WriteBlocks(SD_HandleTypeDef *hsd, uint32_t *pWriteBu
* to check the completion of the read process
* @param hsd: SD handle
* @param pReadBuffer: Pointer to the buffer that will contain the received data
* @param
ReadAddr: Address
from where data is to be read
* @param
BlockNumber: Block number
from where data is to be read
(byte address = BlockNumber * BlockSize)
* @param BlockSize: SD card Data block size
* @note BlockSize must be 512 bytes.
* @param NumberOfBlocks: Number of blocks to read.
* @retval SD Card error state
*/
HAL_SD_ErrorTypedef
HAL_SD_ReadBlocks_DMA
(
SD_HandleTypeDef
*
hsd
,
uint32_t
*
pReadBuffer
,
uint
64
_t
ReadAdd
r
,
uint32_t
BlockSize
,
uint32_t
NumberOfBlocks
)
HAL_SD_ErrorTypedef
HAL_SD_ReadBlocks_
BlockNumber_
DMA
(
SD_HandleTypeDef
*
hsd
,
uint32_t
*
pReadBuffer
,
uint
32
_t
BlockNumbe
r
,
uint32_t
BlockSize
,
uint32_t
NumberOfBlocks
)
{
SDMMC_CmdInitTypeDef
sdmmc_cmdinitstructure
;
SDMMC_DataInitTypeDef
sdmmc_datainitstructure
;
...
...
@@ -886,10 +898,16 @@ HAL_SD_ErrorTypedef HAL_SD_ReadBlocks_DMA(SD_HandleTypeDef *hsd, uint32_t *pRead
/* Enable the DMA Channel */
HAL_DMA_Start_IT
(
hsd
->
hdmarx
,
(
uint32_t
)
&
hsd
->
Instance
->
FIFO
,
(
uint32_t
)
pReadBuffer
,
(
uint32_t
)(
BlockSize
*
NumberOfBlocks
)
/
4
);
uint32_t
ReadAddr
;
if
(
hsd
->
CardType
==
HIGH_CAPACITY_SD_CARD
)
{
BlockSize
=
512
;
ReadAddr
/=
512
;
ReadAddr
=
BlockNumber
;
}
else
{
// should not overflow for standard-capacity cards
ReadAddr
=
BlockNumber
*
BlockSize
;
}
/* Set Block Size for Card */
...
...
@@ -929,7 +947,7 @@ HAL_SD_ErrorTypedef HAL_SD_ReadBlocks_DMA(SD_HandleTypeDef *hsd, uint32_t *pRead
sdmmc_cmdinitstructure
.
CmdIndex
=
SD_CMD_READ_SINGLE_BLOCK
;
}
sdmmc_cmdinitstructure
.
Argument
=
(
uint32_t
)
ReadAddr
;
sdmmc_cmdinitstructure
.
Argument
=
ReadAddr
;
SDMMC_SendCommand
(
hsd
->
Instance
,
&
sdmmc_cmdinitstructure
);
/* Check for error conditions */
...
...
@@ -956,13 +974,13 @@ HAL_SD_ErrorTypedef HAL_SD_ReadBlocks_DMA(SD_HandleTypeDef *hsd, uint32_t *pRead
* to check the completion of the write process (by SD current status polling).
* @param hsd: SD handle
* @param pWriteBuffer: pointer to the buffer that will contain the data to transmit
* @param
WriteAddr: Address from where data is to be read
* @param
BlockNumber: Block number to where data is to be written (byte address = BlockNumber * BlockSize)
* @param BlockSize: the SD card Data block size
* @note BlockSize must be 512 bytes.
* @param NumberOfBlocks: Number of blocks to write
* @retval SD Card error state
*/
HAL_SD_ErrorTypedef
HAL_SD_WriteBlocks_DMA
(
SD_HandleTypeDef
*
hsd
,
uint32_t
*
pWriteBuffer
,
uint
64
_t
WriteAdd
r
,
uint32_t
BlockSize
,
uint32_t
NumberOfBlocks
)
HAL_SD_ErrorTypedef
HAL_SD_WriteBlocks_
BlockNumber_
DMA
(
SD_HandleTypeDef
*
hsd
,
uint32_t
*
pWriteBuffer
,
uint
32
_t
BlockNumbe
r
,
uint32_t
BlockSize
,
uint32_t
NumberOfBlocks
)
{
SDMMC_CmdInitTypeDef
sdmmc_cmdinitstructure
;
SDMMC_DataInitTypeDef
sdmmc_datainitstructure
;
...
...
@@ -1002,10 +1020,16 @@ HAL_SD_ErrorTypedef HAL_SD_WriteBlocks_DMA(SD_HandleTypeDef *hsd, uint32_t *pWri
/* Enable SDMMC DMA transfer */
__HAL_SD_SDMMC_DMA_ENABLE
(
hsd
);
uint32_t
WriteAddr
;
if
(
hsd
->
CardType
==
HIGH_CAPACITY_SD_CARD
)
{
BlockSize
=
512
;
WriteAddr
/=
512
;
WriteAddr
=
BlockNumber
;
}
else
{
// should not overflow for standard-capacity cards
WriteAddr
=
BlockNumber
*
BlockSize
;
}
/* Set Block Size for Card */
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment