Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Miosix Kernel
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
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
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
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Emilio Corigliano
Miosix Kernel
Commits
81929591
Commit
81929591
authored
2 years ago
by
Federico Lolli
Browse files
Options
Downloads
Patches
Plain Diff
[sd_stm32l4] set up correct power-on sequence
parent
854991ba
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
miosix/arch/common/drivers/sd_stm32l4.cpp
+2
-8
2 additions, 8 deletions
miosix/arch/common/drivers/sd_stm32l4.cpp
with
2 additions
and
8 deletions
miosix/arch/common/drivers/sd_stm32l4.cpp
+
2
−
8
View file @
81929591
...
@@ -471,6 +471,7 @@ public:
...
@@ -471,6 +471,7 @@ public:
// width, no clock bypass, no powersave.
// width, no clock bypass, no powersave.
// Set low clock speed 400KHz
// Set low clock speed 400KHz
SDMMC1
->
CLKCR
=
CLOCK_400KHz
;
SDMMC1
->
CLKCR
=
CLOCK_400KHz
;
delayUs
(
185
);
// 74 clock cycles
SDMMC1
->
DTIMER
=
240000
;
//Timeout 600ms expressed in SD_CK cycles
SDMMC1
->
DTIMER
=
240000
;
//Timeout 600ms expressed in SD_CK cycles
}
}
...
@@ -919,7 +920,6 @@ static void initSDIOPeripheral()
...
@@ -919,7 +920,6 @@ static void initSDIOPeripheral()
NVIC_EnableIRQ
(
SDMMC1_IRQn
);
NVIC_EnableIRQ
(
SDMMC1_IRQn
);
SDMMC1
->
POWER
=
0
;
//Power off state
SDMMC1
->
POWER
=
0
;
//Power off state
delayUs
(
1
);
#ifdef _BOARD_STM32L4R9ZI_SENSORTILE
#ifdef _BOARD_STM32L4R9ZI_SENSORTILE
SDMMC1
->
POWER
|=
SDMMC_POWER_DIRPOL
;
SDMMC1
->
POWER
|=
SDMMC_POWER_DIRPOL
;
#endif
#endif
...
@@ -927,14 +927,8 @@ static void initSDIOPeripheral()
...
@@ -927,14 +927,8 @@ static void initSDIOPeripheral()
SDMMC1
->
CMD
=
0
;
SDMMC1
->
CMD
=
0
;
SDMMC1
->
DCTRL
=
0
;
SDMMC1
->
DCTRL
=
0
;
SDMMC1
->
ICR
=
0x1fe007ff
;
SDMMC1
->
ICR
=
0x1fe007ff
;
delayUs
(
1000
);
// at least 1ms delay
SDMMC1
->
POWER
|=
SDMMC_POWER_PWRCTRL_1
|
SDMMC_POWER_PWRCTRL_0
;
//Power on state
SDMMC1
->
POWER
|=
SDMMC_POWER_PWRCTRL_1
|
SDMMC_POWER_PWRCTRL_0
;
//Power on state
//This delay is particularly important: when setting the POWER register a
//glitch on the CMD pin happens. This glitch has a fast fall time and a slow
//rise time resembling an RC charge with a ~6us rise time. If the clock is
//started too soon, the card sees a clock pulse while CMD is low, and
//interprets it as a start bit. No, setting POWER to powerup does not
//eliminate the glitch.
delayUs
(
10
);
ClockController
::
setLowSpeedClock
();
ClockController
::
setLowSpeedClock
();
}
}
...
...
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