Skip to content

Commit d491e3c

Browse files
committed
[STM32F4 STM32F7] Overwrite HAL_Delay to allow SD example
The weak function HAL_Delay is overwritten to use mbed function 'wait_ms'. Thanks to this, the user can use stm32f[4/7]xx_hal_sd.c that calls HAL_Delay This will allow us to add an example detecting / writing / reading an SD card on DISCO_F469NI and DISCO_F746NG
1 parent 55ce47f commit d491e3c

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

libraries/mbed/targets/hal/TARGET_STM/TARGET_STM32F4/mbed_overrides.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2727
*/
2828
#include "cmsis.h"
29+
extern void wait_ms(int ms);
2930

3031
// This function is called after RAM initialization and before main.
3132
void mbed_sdk_init()
@@ -35,3 +36,19 @@ void mbed_sdk_init()
3536
// Need to restart HAL driver after the RAM is initialized
3637
HAL_Init();
3738
}
39+
40+
/**
41+
* @brief This function provides accurate delay (in milliseconds) based
42+
* on variable incremented.
43+
* @note In the default implementation , SysTick timer is the source of time base.
44+
* It is used to generate interrupts at regular time intervals where uwTick
45+
* is incremented.
46+
* @note This function is the modified version of the __weak version contained in
47+
* stm32f4xx_hal.c
48+
* @param Delay: specifies the delay time length, in milliseconds.
49+
* @retval None
50+
*/
51+
void HAL_Delay(__IO uint32_t Delay)
52+
{
53+
wait_ms((int)Delay);
54+
}

libraries/mbed/targets/hal/TARGET_STM/TARGET_STM32F7/mbed_overrides.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2727
*/
2828
#include "cmsis.h"
29+
extern void wait_ms(int ms);
2930

3031
HAL_StatusTypeDef HAL_Init(void);
3132

@@ -37,3 +38,20 @@ void mbed_sdk_init()
3738
// Need to restart HAL driver after the RAM is initialized
3839
HAL_Init();
3940
}
41+
42+
/**
43+
* @brief This function provides accurate delay (in milliseconds) based
44+
* on variable incremented.
45+
* @note In the default implementation , SysTick timer is the source of time base.
46+
* It is used to generate interrupts at regular time intervals where uwTick
47+
* is incremented.
48+
* @note This function is the modified version of the __weak version contained in
49+
* stm32f7xx_hal.c
50+
* @param Delay: specifies the delay time length, in milliseconds.
51+
* @retval None
52+
*/
53+
void HAL_Delay(__IO uint32_t Delay)
54+
{
55+
wait_ms((int)Delay);
56+
}
57+

0 commit comments

Comments
 (0)