1 | /* |
2 | * Copyright (c) 2019-2021 NXP. |
3 | * All rights reserved. |
4 | */ |
5 | |
6 | #if defined(CPU_MIMXRT1061DVL6A) |
7 | #include "system_MIMXRT1061.h" |
8 | #elif defined(CPU_MIMXRT1062DVL6A) |
9 | #include "system_MIMXRT1062.h" |
10 | #elif defined(CPU_MIMXRT1064DVL6A) |
11 | #include "system_MIMXRT1064.h" |
12 | #elif defined(CPU_MIMXRT1176DVMAA_cm7) |
13 | #include "system_MIMXRT1176_cm7.h" |
14 | #elif defined(CPU_MIMXRT1176DVMAA_cm4) |
15 | #include "system_MIMXRT1176_cm4.h" |
16 | #elif defined(CPU_MIMXRT1175DVMAA_cm7) |
17 | #include "system_MIMXRT1175_cm7.h" |
18 | #elif defined(CPU_MIMXRT1175DVMAA_cm4) |
19 | #include "system_MIMXRT1175_cm4.h" |
20 | #elif defined(CPU_MIMXRT1173DVMAA_cm7) |
21 | #include "system_MIMXRT1173_cm7.h" |
22 | #elif defined(CPU_MIMXRT1173DVMAA_cm4) |
23 | #include "system_MIMXRT1173_cm4.h" |
24 | #elif defined(CPU_MIMXRT1171DVMAA_cm7) |
25 | #include "system_MIMXRT1171_cm7.h" |
26 | #elif defined(CPU_MIMXRT1171DVMAA_cm4) |
27 | #include "system_MIMXRT1171_cm4.h" |
28 | #endif |
29 | |
30 | #include "clock_config.h" |
31 | |
32 | #include "MW_target_hardware_resources.h" |
33 | |
34 | |
35 | unsigned long schdl_counter; |
36 | unsigned long schdl_counter_max; |
37 | |
38 | extern void rt_OneStep(); |
39 | #ifdef PERIODIC_TASK_STEP |
40 | extern void PERIODIC_TASK_STEP_FCT; |
41 | #endif // PERIODIC_TASK_STEP |
42 | |
43 | |
44 | void SysTick_Handler(void) |
45 | { |
46 | if (schdl_counter >= schdl_counter_max) { |
47 | schdl_counter = 0; |
48 | } |
49 | |
50 | if (0 == schdl_counter++) { /* Compare with zero before increament */ |
51 | #if defined(PERIODIC_TASK_STEP) && PERIODIC_TASK_STEP == 1 |
52 | PERIODIC_TASK_STEP_FCT; |
53 | #else |
54 | rt_OneStep(); |
55 | #endif |
56 | } |
57 | |
58 | #ifdef USE_ETH |
59 | time_isr(); |
60 | #endif |
61 | } |
62 | void imxrt_trigger_config(float modelBaseRate) |
63 | { |
64 | /* SysTick Scheduler is selected */ |
65 | unsigned long tick_counter; |
66 | tick_counter = (unsigned long)(SystemCoreClock * modelBaseRate); |
67 | |
68 | if (tick_counter > SysTick_LOAD_RELOAD_Msk) { |
69 | schdl_counter_max = (unsigned long)((float)tick_counter / (float)SysTick_LOAD_RELOAD_Msk) + 1; |
70 | SysTick_Config(tick_counter/schdl_counter_max); |
71 | } else { |
72 | schdl_counter_max = 0; |
73 | SysTick_Config(tick_counter); |
74 | } |
75 | |
76 | schdl_counter = 0; |
77 | |
78 | /* Set the SysTick priority */ |
79 | #ifdef MW_SCHEDULER_PRIORITY |
80 | NVIC_SetPriority((IRQn_Type)(-1), MW_SCHEDULER_PRIORITY); |
81 | #endif |
82 | |
83 | } |
84 |