Skip to content

Commit 2451ac1

Browse files
adustm0xc0170
authored andcommitted
[STM32F4 STM32F7] Overwrite HAL_Delay to allow SD example (#1624)
* [STM32F4 STM32F7] Overwrite HAL_Delay to allow SD example The weak function HAL_Delay is overwritten to use us ticker API. 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 (cherry picked from commit d491e3c)
1 parent 0b67bf0 commit 2451ac1

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

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

Lines changed: 16 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+
#include "us_ticker_api.h"
2930

3031
// This function is called after RAM initialization and before main.
3132
void mbed_sdk_init()
@@ -35,3 +36,18 @@ 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 This function is the modified version of the __weak version contained in
44+
* stm32f4xx_hal.c, using us_ticker
45+
* @param Delay: specifies the delay time length, in milliseconds.
46+
* @retval None
47+
*/
48+
void HAL_Delay(__IO uint32_t Delay)
49+
{
50+
uint32_t start = us_ticker_read();
51+
while ((us_ticker_read() - start) < (uint32_t)(Delay * 1000));
52+
}
53+

libraries/mbed/targets/hal/TARGET_STM/TARGET_STM32F7/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+
#include "us_ticker_api.h"
2930

3031
HAL_StatusTypeDef HAL_Init(void);
3132

@@ -37,3 +38,19 @@ void mbed_sdk_init()
3738
// Need to restart HAL driver after the RAM is initialized
3839
HAL_Init();
3940
}
41+
42+
43+
/**
44+
* @brief This function provides accurate delay (in milliseconds) based
45+
* on variable incremented.
46+
* @note This function is the modified version of the __weak version contained in
47+
* stm32f7xx_hal.c, using us_ticker
48+
* @param Delay: specifies the delay time length, in milliseconds.
49+
* @retval None
50+
*/
51+
void HAL_Delay(__IO uint32_t Delay)
52+
{
53+
uint32_t start = us_ticker_read();
54+
while ((us_ticker_read() - start) < (uint32_t)(Delay * 1000));
55+
}
56+

0 commit comments

Comments
 (0)