XCORE SDK
XCORE Software Development Kit
ascii_trace.h
1 // Copyright 2020-2021 XMOS LIMITED.
2 // This Software is subject to the terms of the XMOS Public Licence: Version 1.
3 
4 #ifndef TRACEMACRO_H_
5 #define TRACEMACRO_H_
6 
7 #ifndef __ASSEMBLER__
8 
9 #ifdef __cplusplus
10 extern "C" {
11 #endif
12 
13 int xscope_gettime( void );
14 
15 #ifdef configNUM_CORES
16 #define asciitraceGET_CORE_ID() rtos_core_id_get()
17 #else
18 #define asciitraceGET_CORE_ID() ({(int)0;})
19 #endif
20 
21 #ifdef THIS_XCORE_TILE
22 #define asciitraceGET_TILE_ID() ({(int)THIS_XCORE_TILE;})
23 #else
24 #define asciitraceGET_TILE_ID() get_local_tile_id()
25 #endif
26 
27 
28 void traceFreeRTOS_to_xscope(char* fmt, ...);
29 
30 #define traceOUTPUT(...) \
31  do { \
32  uint32_t ulState = portDISABLE_INTERRUPTS(); \
33  traceFreeRTOS_to_xscope(__VA_ARGS__); \
34  portRESTORE_INTERRUPTS(ulState); \
35  } while(0)
36 
37 #define traceTASK_SWITCHED_OUT() traceOUTPUT( "%d:%d:%d:OUT:%s\n", asciitraceGET_TILE_ID(), asciitraceGET_CORE_ID(), xscope_gettime(), pxCurrentTCB->pcTaskName )
38 #define traceTASK_SWITCHED_IN() traceOUTPUT( "%d:%d:%d:IN:%s\n", asciitraceGET_TILE_ID(), asciitraceGET_CORE_ID(), xscope_gettime(), pxCurrentTCB->pcTaskName )
39 
40 #ifdef __cplusplus
41 }
42 #endif
43 
44 #endif /* __ASSEMBLER__ */
45 
46 #endif /* TRACEMACRO_H_ */