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
594699bc
Commit
594699bc
authored
10 years ago
by
Damien George
Browse files
Options
Downloads
Patches
Plain Diff
stmhal: Protect SD_WriteBlocks by IRQ disable/enable pair.
parent
90ba80dc
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
stmhal/sdcard.c
+12
-4
12 additions, 4 deletions
stmhal/sdcard.c
with
12 additions
and
4 deletions
stmhal/sdcard.c
+
12
−
4
View file @
594699bc
...
...
@@ -144,10 +144,11 @@ bool sdcard_read_blocks(uint8_t *dest, uint32_t block_num, uint32_t num_blocks)
return
false
;
}
HAL_SD_ErrorTypedef
err
;
// We must disable IRQs because the SDIO peripheral has a small FIFO
// buffer and we can't let it fill up in the middle of a read.
// This will not be needed when SD uses DMA for transfer.
__disable_irq
();
err
=
HAL_SD_ReadBlocks
(
&
sd_handle
,
(
uint32_t
*
)
dest
,
block_num
*
SDCARD_BLOCK_SIZE
,
SDCARD_BLOCK_SIZE
,
num_blocks
);
HAL_SD_ErrorTypedef
err
=
HAL_SD_ReadBlocks
(
&
sd_handle
,
(
uint32_t
*
)
dest
,
block_num
*
SDCARD_BLOCK_SIZE
,
SDCARD_BLOCK_SIZE
,
num_blocks
);
__enable_irq
();
if
(
err
!=
SD_OK
)
{
...
...
@@ -168,7 +169,14 @@ bool sdcard_write_blocks(const uint8_t *src, uint32_t block_num, uint32_t num_bl
return
false
;
}
if
(
HAL_SD_WriteBlocks
(
&
sd_handle
,
(
uint32_t
*
)
src
,
block_num
*
SDCARD_BLOCK_SIZE
,
SDCARD_BLOCK_SIZE
,
num_blocks
)
!=
SD_OK
)
{
// We must disable IRQs because the SDIO peripheral has a small FIFO
// buffer and we can't let it drain to empty in the middle of a write.
// This will not be needed when SD uses DMA for transfer.
__disable_irq
();
HAL_SD_ErrorTypedef
err
=
HAL_SD_WriteBlocks
(
&
sd_handle
,
(
uint32_t
*
)
src
,
block_num
*
SDCARD_BLOCK_SIZE
,
SDCARD_BLOCK_SIZE
,
num_blocks
);
__enable_irq
();
if
(
err
!=
SD_OK
)
{
return
false
;
}
...
...
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