1 /* 2 * Copyright (c) 2015-2016, Freescale Semiconductor, Inc. 3 * Copyright 2016-2021 NXP 4 * All rights reserved. 5 * 6 * SPDX-License-Identifier: BSD-3-Clause 7 */ 8 9 #include "fsl_common.h" 10 11 /* Component ID definition, used by tools. */ 12 #ifndef FSL_COMPONENT_ID 13 #define FSL_COMPONENT_ID "platform.drivers.common_dsp" 14 #endif 15 16 extern uint32_t xthal_get_ccount(void); 17 SDK_DelayAtLeastUs(uint32_t delayTime_us,uint32_t coreClock_Hz)18void SDK_DelayAtLeastUs(uint32_t delayTime_us, uint32_t coreClock_Hz) 19 { 20 uint64_t count; 21 22 if (delayTime_us > 0U) 23 { 24 count = USEC_TO_COUNT(delayTime_us, coreClock_Hz); 25 26 assert(count <= UINT32_MAX); 27 28 /* Calculate the count ticks. */ 29 count += xthal_get_ccount(); 30 31 if (count > UINT32_MAX) 32 { 33 count -= UINT32_MAX; 34 /* Wait for cyccnt overflow. */ 35 while (count < xthal_get_ccount()) 36 { 37 } 38 } 39 40 /* Wait for cyccnt reach count value. */ 41 while (count > xthal_get_ccount()) 42 { 43 } 44 } 45 } 46