Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
2 | mjames | 1 | #ifndef _JTEST_SYSTICK_H_ |
2 | #define _JTEST_SYSTICK_H_ |
||
3 | |||
4 | /*--------------------------------------------------------------------------------*/ |
||
5 | /* Includes */ |
||
6 | /*--------------------------------------------------------------------------------*/ |
||
7 | |||
8 | /* Get access to the SysTick structure. */ |
||
9 | #if defined ARMCM0 |
||
10 | #include "ARMCM0.h" |
||
11 | #elif defined ARMCM0P |
||
12 | #include "ARMCM0plus.h" |
||
13 | #elif defined ARMCM3 |
||
14 | #include "ARMCM3.h" |
||
15 | #elif defined ARMCM4 |
||
16 | #include "ARMCM4.h" |
||
17 | #elif defined ARMCM4_FP |
||
18 | #include "ARMCM4_FP.h" |
||
19 | #elif defined ARMCM7 |
||
20 | #include "ARMCM7.h" |
||
21 | #elif defined ARMCM7_SP |
||
22 | #include "ARMCM7_SP.h" |
||
23 | #elif defined ARMCM7_DP |
||
24 | #include "ARMCM7_DP.h" |
||
25 | #elif defined ARMSC000 |
||
26 | #include "ARMSC000.h" |
||
27 | #elif defined ARMSC300 |
||
28 | #include "ARMSC300.h" |
||
29 | #elif defined ARMv8MBL |
||
30 | #include "ARMv8MBL.h" |
||
31 | #elif defined ARMv8MML |
||
32 | #include "ARMv8MML.h" |
||
33 | #elif defined ARMv8MML_DSP |
||
34 | #include "ARMv8MML_DSP.h" |
||
35 | #elif defined ARMv8MML_SP |
||
36 | #include "ARMv8MML_SP.h" |
||
37 | #elif defined ARMv8MML_DSP_SP |
||
38 | #include "ARMv8MML_DSP_SP.h" |
||
39 | #elif defined ARMv8MML_DP |
||
40 | #include "ARMv8MML_DP.h" |
||
41 | #elif defined ARMv8MML_DSP_DP |
||
42 | #include "ARMv8MML_DSP_DP.h" |
||
43 | |||
44 | #else |
||
45 | #warning "no appropriate header file found!" |
||
46 | #endif |
||
47 | |||
48 | /*--------------------------------------------------------------------------------*/ |
||
49 | /* Macros and Defines */ |
||
50 | /*--------------------------------------------------------------------------------*/ |
||
51 | |||
52 | /** |
||
53 | * Initial value for the SysTick module. |
||
54 | * |
||
55 | * @note This is also the maximum value, important as SysTick is a decrementing |
||
56 | * counter. |
||
57 | */ |
||
58 | #define JTEST_SYSTICK_INITIAL_VALUE 0xFFFFFF |
||
59 | |||
60 | /** |
||
61 | * Reset the SysTick, decrementing timer to it's maximum value and disable it. |
||
62 | * |
||
63 | * This macro should leave the SysTick timer in a state that's ready for cycle |
||
64 | * counting. |
||
65 | */ |
||
66 | #define JTEST_SYSTICK_RESET(systick_ptr) \ |
||
67 | do \ |
||
68 | { \ |
||
69 | (systick_ptr)->LOAD = JTEST_SYSTICK_INITIAL_VALUE; \ |
||
70 | (systick_ptr)->VAL = 1; \ |
||
71 | \ |
||
72 | /* Disable the SysTick module. */ \ |
||
73 | (systick_ptr)->CTRL = UINT32_C(0x000000); \ |
||
74 | } while (0) |
||
75 | |||
76 | /** |
||
77 | * Start the SysTick timer, sourced by the processor clock. |
||
78 | */ |
||
79 | #define JTEST_SYSTICK_START(systick_ptr) \ |
||
80 | do \ |
||
81 | { \ |
||
82 | (systick_ptr)->CTRL = \ |
||
83 | SysTick_CTRL_ENABLE_Msk | \ |
||
84 | SysTick_CTRL_CLKSOURCE_Msk; /* Internal clk*/ \ |
||
85 | } while (0) |
||
86 | |||
87 | /** |
||
88 | * Evaluate to the current value of the SysTick timer. |
||
89 | */ |
||
90 | #define JTEST_SYSTICK_VALUE(systick_ptr) \ |
||
91 | ((systick_ptr)->VAL) |
||
92 | |||
93 | #endif /* _JTEST_SYSTICK_H_ */ |