10 #define SDK_MEM_MAGIC_NUMBER 12345U
19 #ifndef FSL_COMPONENT_ID
20 #define FSL_COMPONENT_ID "platform.drivers.common"
23 #ifndef __GIC_PRIO_BITS
24 #if defined(ENABLE_RAM_VECTOR_TABLE)
25 uint32_t InstallIRQHandler(
IRQn_Type irq, uint32_t irqHandler)
28 #if defined(__CC_ARM) || defined(__ARMCC_VERSION)
29 extern uint32_t Image$$VECTOR_ROM$$Base[];
30 extern uint32_t Image$$VECTOR_RAM$$Base[];
31 extern uint32_t Image$$RW_m_data$$Base[];
33 #define __VECTOR_TABLE Image$$VECTOR_ROM$$Base
34 #define __VECTOR_RAM Image$$VECTOR_RAM$$Base
35 #define __RAM_VECTOR_TABLE_SIZE (((uint32_t)Image$$RW_m_data$$Base - (uint32_t)Image$$VECTOR_RAM$$Base))
36 #elif defined(__ICCARM__)
37 extern uint32_t __RAM_VECTOR_TABLE_SIZE[];
39 extern uint32_t __VECTOR_RAM[];
40 #elif defined(__GNUC__)
42 extern uint32_t __VECTOR_RAM[];
43 extern uint32_t __RAM_VECTOR_TABLE_SIZE_BYTES[];
44 uint32_t __RAM_VECTOR_TABLE_SIZE = (uint32_t)(__RAM_VECTOR_TABLE_SIZE_BYTES);
48 uint32_t irqMaskValue;
51 if (
SCB->VTOR != (uint32_t)__VECTOR_RAM)
54 for (n = 0; n < ((uint32_t)__RAM_VECTOR_TABLE_SIZE) /
sizeof(uint32_t); n++)
59 SCB->VTOR = (uint32_t)__VECTOR_RAM;
62 ret = __VECTOR_RAM[irq + 16];
64 __VECTOR_RAM[irq + 16] = irqHandler;
74 #if (defined(FSL_FEATURE_SOC_SYSCON_COUNT) && (FSL_FEATURE_SOC_SYSCON_COUNT > 0))
75 #if !(defined(FSL_FEATURE_SYSCON_STARTER_DISCONTINUOUS) && FSL_FEATURE_SYSCON_STARTER_DISCONTINUOUS)
77 void EnableDeepSleepIRQ(
IRQn_Type interrupt)
79 uint32_t intNumber = (uint32_t)interrupt;
83 while (intNumber >= 32u)
89 SYSCON->STARTERSET[index] = 1u << intNumber;
93 void DisableDeepSleepIRQ(
IRQn_Type interrupt)
95 uint32_t intNumber = (uint32_t)interrupt;
100 while (intNumber >= 32u)
106 SYSCON->STARTERCLR[index] = 1u << intNumber;
118 uint32_t unsigned_value;
119 } p_align_addr, p_addr;
121 p_addr.pointer_value = malloc(alignedsize);
123 if (p_addr.pointer_value ==
NULL)
132 p_cb->
offset = (uint16_t)(p_align_addr.unsigned_value - p_addr.unsigned_value);
134 return p_align_addr.pointer_value;
142 uint32_t unsigned_value;
144 p_free.pointer_value = ptr;
152 p_free.unsigned_value = p_free.unsigned_value - p_cb->
offset;
154 free(p_free.pointer_value);
162 #if defined(SDK_DELAY_USE_DWT) && defined(DWT)
163 void enableCpuCycleCounter(
void)
181 uint32_t getCpuCycleCount(
void)
185 #elif defined __XCC__
186 extern uint32_t xthal_get_ccount(
void);
187 void enableCpuCycleCounter(
void)
192 uint32_t getCpuCycleCount(
void)
194 return xthal_get_ccount();
199 #if (!defined(SDK_DELAY_USE_DWT)) || (!defined(DWT))
200 #if defined(__CC_ARM)
211 #elif defined(__ARMCC_VERSION) || defined(__ICCARM__) || defined(__GNUC__)
214 static void DelayLoop(uint32_t
count)
219 #if defined(__GNUC__) && !defined(__ARMCC_VERSION)
222 " SUBS R0, R0, #1 \n"
243 assert(0U != delay_us);
247 #if defined(SDK_DELAY_USE_DWT) && defined(DWT) || (defined __XCC__)
249 enableCpuCycleCounter();
251 count += getCpuCycleCount();
257 while (
count < getCpuCycleCount())
263 while (
count > getCpuCycleCount())
273 #if (__CORTEX_M == 7)
278 DelayLoop((uint32_t)
count);