ujurmsde wrote: ↑Mon Jan 09, 2023 4:12 am
It is a custom function which is based on STM32 API's so I need to port it to ESP32.!!
Ah cool. Perhaps you could show the content of the function (source). Knowing how the parameters are used might indicate how they need to be ported.
Not knowing much more detail, I think the corresponding functions would approximately be `vTaskDelay` and `esp_timer_get_time`. I don't know what the STM32 system you are porting from used as an environment, but ESP-IDF uses FreeRTOS. So delays are done with `vTaskDelay` which accepts ticks. `esp_timer_get_time` gives the number of microseconds since boot. To get the equivalent of the `HAL_GetTick` function, you want milliseconds.
So you'd write some simple wrappers, something like this. You'll need to adjust data types as needed (I don't know the signature of your custom function):
Code: Select all
uint32_t ticks(void)
{
return static_cast<uint32_t>(esp_timer_get_time() / 1000);
}
Code: Select all
void delay(uint32_t ms)
{
vTaskDelay(pdMS_TO_TICKS(ms));
}
Note that `millis` above returns milliseconds which, by default, is what `HAL_GetTick` will return because (by default) I think a tick is a millisecond in the STM32 (I may be wrong about that). Anyway, you can use your wrapper to scale as needed.
And then pass these to your ported function.
Code: Select all
NoteSetFn(malloc, free, delay, ticks);