Merge pull request #10683 from OpenNuvoton/nuvoton_wait-ns_weak

Export wait_ns to be overridable
pull/10741/head
Martin Kojtal 2019-06-03 08:54:50 +01:00 committed by GitHub
commit a93542bab5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 1 deletions

View File

@ -112,7 +112,10 @@ static const uint16_t delay_loop_code[] = {
/* Take the address of the code, set LSB to indicate Thumb, and cast to void() function pointer */
#define delay_loop ((void(*)()) ((uintptr_t) delay_loop_code | 1))
void wait_ns(unsigned int ns)
/* Some targets may not provide zero-wait-state flash performance. Export this function
* to be overridable for targets to provide more accurate implementation like locating
* 'delay_loop_code' in SRAM. */
MBED_WEAK void wait_ns(unsigned int ns)
{
uint32_t cycles_per_us = SystemCoreClock / 1000000;
// Note that this very calculation, plus call overhead, will take multiple