Use us_ticker_read while SDK is not ready

pull/7352/head
bcostm 2018-06-27 14:34:51 +02:00
parent f12afde757
commit 26cb388d14
2 changed files with 15 additions and 1 deletions

View File

@ -17,9 +17,19 @@
// Overwrite default HAL functions defined as "weak"
// This variable is set to 1 at the of mbed_sdk_init function.
// The ticker_read_us function must not be called until the mbed_sdk_init is terminated.
extern int mbed_sdk_inited;
uint32_t HAL_GetTick()
{
return ticker_read_us(get_us_ticker_data()) / 1000; // 1 ms tick is required for ST HAL
// 1 ms tick is required for ST HAL driver
if (mbed_sdk_inited) {
return (ticker_read_us(get_us_ticker_data()) / 1000);
}
else {
return (us_ticker_read() / 1000);
}
}
void HAL_SuspendTick(void)

View File

@ -27,6 +27,8 @@
*/
#include "cmsis.h"
int mbed_sdk_inited = 0;
// This function is called after RAM initialization and before main.
void mbed_sdk_init()
{
@ -51,4 +53,6 @@ void mbed_sdk_init()
AHB/APBx prescalers and Flash settings */
SetSysClock();
SystemCoreClockUpdate();
mbed_sdk_inited = 1;
}