Skip to content

[STM32F4 STM32F7] Overwrite HAL_Delay to allow SD example #1624

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 26, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "cmsis.h"
#include "us_ticker_api.h"

// This function is called after RAM initialization and before main.
void mbed_sdk_init()
Expand All @@ -35,3 +36,18 @@ void mbed_sdk_init()
// Need to restart HAL driver after the RAM is initialized
HAL_Init();
}

/**
* @brief This function provides accurate delay (in milliseconds) based
* on variable incremented.
* @note This function is the modified version of the __weak version contained in
* stm32f4xx_hal.c, using us_ticker
* @param Delay: specifies the delay time length, in milliseconds.
* @retval None
*/
void HAL_Delay(__IO uint32_t Delay)
{
uint32_t start = us_ticker_read();
while ((us_ticker_read() - start) < (uint32_t)(Delay * 1000));
}

Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "cmsis.h"
#include "us_ticker_api.h"

HAL_StatusTypeDef HAL_Init(void);

Expand All @@ -37,3 +38,19 @@ void mbed_sdk_init()
// Need to restart HAL driver after the RAM is initialized
HAL_Init();
}


/**
* @brief This function provides accurate delay (in milliseconds) based
* on variable incremented.
* @note This function is the modified version of the __weak version contained in
* stm32f7xx_hal.c, using us_ticker
* @param Delay: specifies the delay time length, in milliseconds.
* @retval None
*/
void HAL_Delay(__IO uint32_t Delay)
{
uint32_t start = us_ticker_read();
while ((us_ticker_read() - start) < (uint32_t)(Delay * 1000));
}