]> git.sur5r.net Git - freertos/blob - FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace(streaming)/trcHardwarePort.h
Update FreeRTOS+Trace recorder library to v3.0.2
[freertos] / FreeRTOS-Plus / Source / FreeRTOS-Plus-Trace(streaming) / trcHardwarePort.h
1 /*******************************************************************************\r
2  * Trace Recorder Library for Tracealyzer v3.0.2\r
3  * Percepio AB, www.percepio.com\r
4  *\r
5  * trcHardwarePort.h\r
6  *\r
7  * The hardware abstraction layer for the trace recorder library.\r
8  *\r
9  * Terms of Use\r
10  * This software (the "Tracealyzer Recorder Library") is the intellectual\r
11  * property of Percepio AB and may not be sold or in other ways commercially\r
12  * redistributed without explicit written permission by Percepio AB.\r
13  *\r
14  * Separate conditions applies for the SEGGER branded source code included.\r
15  *\r
16  * The recorder library is free for use together with Percepio products.\r
17  * You may distribute the recorder library in its original form, but public\r
18  * distribution of modified versions require approval by Percepio AB.\r
19  *\r
20  * Disclaimer\r
21  * The trace tool and recorder library is being delivered to you AS IS and\r
22  * Percepio AB makes no warranty as to its use or performance. Percepio AB does\r
23  * not and cannot warrant the performance or results you may obtain by using the\r
24  * software or documentation. Percepio AB make no warranties, express or\r
25  * implied, as to noninfringement of third party rights, merchantability, or\r
26  * fitness for any particular purpose. In no event will Percepio AB, its\r
27  * technology partners, or distributors be liable to you for any consequential,\r
28  * incidental or special damages, including any lost profits or lost savings,\r
29  * even if a representative of Percepio AB has been advised of the possibility\r
30  * of such damages, or for any claim by any third party. Some jurisdictions do\r
31  * not allow the exclusion or limitation of incidental, consequential or special\r
32  * damages, or the exclusion of implied warranties or limitations on how long an\r
33  * implied warranty may last, so the above limitations may not apply to you.\r
34  *\r
35  * Tabs are used for indent in this file (1 tab = 4 spaces)\r
36  *\r
37  * Copyright Percepio AB, 2015.\r
38  * www.percepio.com\r
39  ******************************************************************************/\r
40 \r
41 #ifndef TRC_HARDWARE_PORT_H\r
42 #define TRC_HARDWARE_PORT_H\r
43 \r
44 #ifdef __cplusplus\r
45 extern \93C\94 {\r
46 #endif\r
47 \r
48 #include <stdint.h>\r
49 \r
50 /******************************************************************************\r
51  * Hardware ports\r
52  * To get accurate timestamping, a hardware timer is necessary. Below are the\r
53  * available ports. Some of these are "unofficial", meaning that\r
54  * they have not yet been verified by Percepio but have been contributed by\r
55  * external developers. They should work, otherwise let us know by emailing\r
56  * support@percepio.com. Some work on any OS platform, while other are specific\r
57  * to a certain operating system.\r
58  *****************************************************************************/\r
59 \r
60 \r
61 /****** Port Name ***************************** Code */\r
62 #define TRC_PORT_APPLICATION_DEFINED                    -1\r
63 #define TRC_PORT_NOT_SET                                                0\r
64 #define TRC_PORT_ARM_Cortex_M                                   1\r
65 #define TRC_PORT_ARM_CORTEX_A9                                  2\r
66 #define TRC_PORT_Renesas_RX600                                  3\r
67 #define TRC_PORT_TEXAS_INSTRUMENTS_TMS570_RM48  4\r
68 #define TRC_PORT_MICROCHIP_PIC32_MX_MZ                  5\r
69 \r
70 /*******************************************************************************\r
71  *\r
72  * HWTC Macros - Hardware Timer/Counter Isolation Layer\r
73  *\r
74  * These two HWTC macros provides a hardware isolation layer representing a\r
75  * generic hardware timer/counter used for the timestamping.\r
76  *\r
77  * HWTC_COUNT: The current value of the counter. This is expected to be reset\r
78  * a each tick interrupt. Thus, when the tick handler starts, the counter has\r
79  * already wrapped.\r
80  *\r
81  * HWTC_TYPE: Defines the type of timer/counter used for HWTC_COUNT:\r
82  *\r
83  * - FREE_RUNNING_32BIT_INCR:\r
84  *   Free-running 32-bit timer, counting upwards from 0 - > 0xFFFFFFFF\r
85  *\r
86  * - FREE_RUNNING_32BIT_DECR\r
87  *   Free-running 32-bit counter, counting downwards from 0xFFFFFFFF -> 0\r
88  *\r
89  * - OS_TIMER_INCR\r
90  *       Interrupt timer, counts upwards from 0 until HWTC_PERIOD-1\r
91  *\r
92  * - OS_TIMER_DECR\r
93  *   Interrupt timer, counts downwards from HWTC_PERIOD-1 until 0\r
94  *\r
95  *******************************************************************************\r
96  *\r
97  * IRQ_PRIORITY_ORDER\r
98  *\r
99  * Macro which should be defined as an integer of 0 or 1.\r
100  *\r
101  * It is only used only to sort and colorize the interrupts in priority order,\r
102  * in case you record interrupts using the vTraceStoreISRBegin and\r
103  * vTraceStoreISREnd routines. 1 indicates higher value is more important.\r
104  *\r
105  ******************************************************************************/\r
106 \r
107 #define TRC_FREE_RUNNING_32BIT_INCR 1\r
108 #define TRC_FREE_RUNNING_32BIT_DECR 2\r
109 #define TRC_OS_TIMER_INCR 3\r
110 #define TRC_OS_TIMER_DECR 4\r
111 \r
112 #if (TRC_RECORDER_HARDWARE_PORT == TRC_PORT_ARM_Cortex_M)\r
113 \r
114         #define HWTC_TYPE TRC_OS_TIMER_DECR\r
115     #define HWTC_COUNT (*((uint32_t*)0xE000E018)) /* SysTick counter */\r
116         #define IRQ_PRIORITY_ORDER 0\r
117 \r
118 #elif (TRC_RECORDER_HARDWARE_PORT == TRC_PORT_Renesas_RX600)\r
119 \r
120         #include "iodefine.h"\r
121 \r
122         #define HWTC_TYPE TRC_OS_TIMER_INCR\r
123         #define HWTC_COUNT (CMT0.CMCNT)\r
124         #define IRQ_PRIORITY_ORDER 1\r
125 \r
126 #elif (TRC_RECORDER_HARDWARE_PORT == TRC_PORT_MICROCHIP_PIC32_MX_MZ)\r
127 \r
128         #define HWTC_TYPE TRC_OS_TIMER_INCR\r
129         #define HWTC_COUNT (TMR1)\r
130         #define IRQ_PRIORITY_ORDER 0\r
131 \r
132 #elif (TRC_RECORDER_HARDWARE_PORT == TRC_PORT_TEXAS_INSTRUMENTS_TMS570_RM48)\r
133 \r
134         #define RTIFRC0 *((uint32_t *)0xFFFFFC10)\r
135         #define RTICOMP0 *((uint32_t *)0xFFFFFC50)\r
136         #define RTIUDCP0 *((uint32_t *)0xFFFFFC54)\r
137 \r
138         #define HWTC_TYPE TRC_OS_TIMER_INCR\r
139         #define HWTC_COUNT (RTIFRC0 - (RTICOMP0 - RTIUDCP0))\r
140         #define IRQ_PRIORITY_ORDER 0\r
141 \r
142 #elif (TRC_RECORDER_HARDWARE_PORT == TRC_PORT_ARM_CORTEX_A9)\r
143         /* INPUT YOUR PERIPHERAL BASE ADDRESS HERE */\r
144         #define CA9_MPCORE_PERIPHERAL_BASE_ADDRESS      0xSOMETHING\r
145         \r
146         #define CA9_MPCORE_PRIVATE_MEMORY_OFFSET        0x0600\r
147         #define CA9_MPCORE_PRIVCTR_PERIOD_REG   (*(volatile uint32_t*)(CA9_MPCORE_PERIPHERAL_BASE_ADDRESS + CA9_MPCORE_PRIVATE_MEMORY_OFFSET + 0x00))\r
148         #define CA9_MPCORE_PRIVCTR_COUNTER_REG  (*(volatile uint32_t*)(CA9_MPCORE_PERIPHERAL_BASE_ADDRESS + CA9_MPCORE_PRIVATE_MEMORY_OFFSET + 0x04))\r
149         #define CA9_MPCORE_PRIVCTR_CONTROL_REG  (*(volatile uint32_t*)(CA9_MPCORE_PERIPHERAL_BASE_ADDRESS + CA9_MPCORE_PRIVATE_MEMORY_OFFSET + 0x08))\r
150         \r
151         #define CA9_MPCORE_PRIVCTR_CONTROL_PRESCALER_MASK    0x0000FF00\r
152         #define CA9_MPCORE_PRIVCTR_CONTROL_PRESCALER_SHIFT   8\r
153         #define CA9_MPCORE_PRIVCTR_PRESCALER        (((CA9_MPCORE_PRIVCTR_CONTROL_REG & CA9_MPCORE_PRIVCTR_CONTROL_PRESCALER_MASK) >> CA9_MPCORE_PRIVCTR_CONTROL_PRESCALER_SHIFT) + 1)\r
154 \r
155     #define HWTC_TYPE                                                   TRC_OS_TIMER_DECR\r
156     #define HWTC_COUNT                          CA9_MPCORE_PRIVCTR_COUNTER_REG\r
157     #define IRQ_PRIORITY_ORDER 0\r
158 \r
159 #elif (TRC_RECORDER_HARDWARE_PORT == TRC_PORT_APPLICATION_DEFINED)\r
160 \r
161         #if !( defined (HWTC_TYPE) && defined (HWTC_COUNT) && defined (IRQ_PRIORITY_ORDER))\r
162                 #error RECORDER_HARDWARE_PORT is PORT_APPLICATION_DEFINED but not all of the necessary constants have been defined.\r
163         #endif\r
164 \r
165 #elif (TRC_RECORDER_HARDWARE_PORT != TRC_PORT_NOT_SET)\r
166 \r
167         #error "RECORDER_HARDWARE_PORT had unsupported value!"\r
168         #define TRC_RECORDER_HARDWARE_PORT PORT_NOT_SET\r
169 \r
170 #endif\r
171 \r
172 #if (TRC_RECORDER_HARDWARE_PORT != TRC_PORT_NOT_SET)\r
173 \r
174         #ifndef HWTC_COUNT\r
175         #error "HWTC_COUNT is not set!"\r
176         #endif\r
177 \r
178         #ifndef HWTC_TYPE\r
179         #error "HWTC_TYPE is not set!"\r
180         #endif\r
181 \r
182         #ifndef IRQ_PRIORITY_ORDER\r
183         #error "IRQ_PRIORITY_ORDER is not set!"\r
184         #elif (IRQ_PRIORITY_ORDER != 0) && (IRQ_PRIORITY_ORDER != 1)\r
185         #error "IRQ_PRIORITY_ORDER has bad value!"\r
186         #endif\r
187 \r
188 #endif\r
189 \r
190 #ifdef __cplusplus\r
191 }\r
192 #endif\r
193 \r
194 #endif /* TRC_HARDWARE_PORT_H */\r