prova
Dependencies: X_NUCLEO_53L0A1 mbed
Fork of 53L0A1_HandGestureRecognition by
Middlewares/ST/Gestures/GesturesDetect/Inc/Diag/Trace.h@9:6205ef056c8a, 2018-02-22 (annotated)
- Committer:
- mapellil
- Date:
- Thu Feb 22 15:50:29 2018 +0000
- Revision:
- 9:6205ef056c8a
- Parent:
- 7:d79cbeda2982
AStDay
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mapellil | 7:d79cbeda2982 | 1 | // |
mapellil | 7:d79cbeda2982 | 2 | // This file is part of the µOS++ III distribution. |
mapellil | 7:d79cbeda2982 | 3 | // Copyright (c) 2014 Liviu Ionescu. |
mapellil | 7:d79cbeda2982 | 4 | // |
mapellil | 7:d79cbeda2982 | 5 | |
mapellil | 7:d79cbeda2982 | 6 | #ifndef DIAG_TRACE_H_ |
mapellil | 7:d79cbeda2982 | 7 | #define DIAG_TRACE_H_ |
mapellil | 7:d79cbeda2982 | 8 | |
mapellil | 7:d79cbeda2982 | 9 | // ---------------------------------------------------------------------------- |
mapellil | 7:d79cbeda2982 | 10 | |
mapellil | 7:d79cbeda2982 | 11 | //#include <unistd.h> |
mapellil | 7:d79cbeda2982 | 12 | typedef int ssize_t; |
mapellil | 7:d79cbeda2982 | 13 | |
mapellil | 7:d79cbeda2982 | 14 | // ---------------------------------------------------------------------------- |
mapellil | 7:d79cbeda2982 | 15 | |
mapellil | 7:d79cbeda2982 | 16 | // The trace device is an independent output channel, intended for debug |
mapellil | 7:d79cbeda2982 | 17 | // purposes. |
mapellil | 7:d79cbeda2982 | 18 | // |
mapellil | 7:d79cbeda2982 | 19 | // The API is simple, and mimics the standard output calls: |
mapellil | 7:d79cbeda2982 | 20 | // - trace_printf() |
mapellil | 7:d79cbeda2982 | 21 | // - trace_puts() |
mapellil | 7:d79cbeda2982 | 22 | // - trace_putchar(); |
mapellil | 7:d79cbeda2982 | 23 | // |
mapellil | 7:d79cbeda2982 | 24 | // The implementation is done in |
mapellil | 7:d79cbeda2982 | 25 | // - trace_write() |
mapellil | 7:d79cbeda2982 | 26 | // |
mapellil | 7:d79cbeda2982 | 27 | // Trace support is enabled by adding the TRACE definition. |
mapellil | 7:d79cbeda2982 | 28 | // By default the trace messages are forwarded to the ITM output, |
mapellil | 7:d79cbeda2982 | 29 | // but can be rerouted via any device or completely suppressed by |
mapellil | 7:d79cbeda2982 | 30 | // changing the definitions required in system/src/diag/trace_impl.c |
mapellil | 7:d79cbeda2982 | 31 | // (currently OS_USE_TRACE_ITM, OS_USE_TRACE_SEMIHOSTING_DEBUG/_STDOUT). |
mapellil | 7:d79cbeda2982 | 32 | // |
mapellil | 7:d79cbeda2982 | 33 | // When TRACE is not defined, all functions are inlined to empty bodies. |
mapellil | 7:d79cbeda2982 | 34 | // This has the advantage that the trace call do not need to be conditionally |
mapellil | 7:d79cbeda2982 | 35 | // compiled with #ifdef TRACE/#endif |
mapellil | 7:d79cbeda2982 | 36 | |
mapellil | 7:d79cbeda2982 | 37 | |
mapellil | 7:d79cbeda2982 | 38 | #if defined(TRACE) |
mapellil | 7:d79cbeda2982 | 39 | |
mapellil | 7:d79cbeda2982 | 40 | #if defined(__cplusplus) |
mapellil | 7:d79cbeda2982 | 41 | extern "C" |
mapellil | 7:d79cbeda2982 | 42 | { |
mapellil | 7:d79cbeda2982 | 43 | #endif |
mapellil | 7:d79cbeda2982 | 44 | |
mapellil | 7:d79cbeda2982 | 45 | void |
mapellil | 7:d79cbeda2982 | 46 | trace_initialize(void); |
mapellil | 7:d79cbeda2982 | 47 | |
mapellil | 7:d79cbeda2982 | 48 | // Implementation dependent |
mapellil | 7:d79cbeda2982 | 49 | ssize_t |
mapellil | 7:d79cbeda2982 | 50 | trace_write(const char* buf, size_t nbyte); |
mapellil | 7:d79cbeda2982 | 51 | |
mapellil | 7:d79cbeda2982 | 52 | // ----- Portable ----- |
mapellil | 7:d79cbeda2982 | 53 | |
mapellil | 7:d79cbeda2982 | 54 | int |
mapellil | 7:d79cbeda2982 | 55 | trace_printf(const char* format, ...); |
mapellil | 7:d79cbeda2982 | 56 | |
mapellil | 7:d79cbeda2982 | 57 | int |
mapellil | 7:d79cbeda2982 | 58 | trace_puts(const char *s); |
mapellil | 7:d79cbeda2982 | 59 | |
mapellil | 7:d79cbeda2982 | 60 | int |
mapellil | 7:d79cbeda2982 | 61 | trace_putchar(int c); |
mapellil | 7:d79cbeda2982 | 62 | |
mapellil | 7:d79cbeda2982 | 63 | void |
mapellil | 7:d79cbeda2982 | 64 | trace_dump_args(int argc, char* argv[]); |
mapellil | 7:d79cbeda2982 | 65 | |
mapellil | 7:d79cbeda2982 | 66 | #if defined(__cplusplus) |
mapellil | 7:d79cbeda2982 | 67 | } |
mapellil | 7:d79cbeda2982 | 68 | #endif |
mapellil | 7:d79cbeda2982 | 69 | |
mapellil | 7:d79cbeda2982 | 70 | #else // !defined(TRACE) |
mapellil | 7:d79cbeda2982 | 71 | |
mapellil | 7:d79cbeda2982 | 72 | #if defined(__cplusplus) |
mapellil | 7:d79cbeda2982 | 73 | extern "C" |
mapellil | 7:d79cbeda2982 | 74 | { |
mapellil | 7:d79cbeda2982 | 75 | #endif |
mapellil | 7:d79cbeda2982 | 76 | |
mapellil | 7:d79cbeda2982 | 77 | inline void |
mapellil | 7:d79cbeda2982 | 78 | trace_initialize(void); |
mapellil | 7:d79cbeda2982 | 79 | |
mapellil | 7:d79cbeda2982 | 80 | // Implementation dependent |
mapellil | 7:d79cbeda2982 | 81 | inline ssize_t |
mapellil | 7:d79cbeda2982 | 82 | trace_write(const char* buf, size_t nbyte); |
mapellil | 7:d79cbeda2982 | 83 | |
mapellil | 7:d79cbeda2982 | 84 | inline int |
mapellil | 7:d79cbeda2982 | 85 | trace_printf(const char* format, ...); |
mapellil | 7:d79cbeda2982 | 86 | |
mapellil | 7:d79cbeda2982 | 87 | inline int |
mapellil | 7:d79cbeda2982 | 88 | trace_puts(const char *s); |
mapellil | 7:d79cbeda2982 | 89 | |
mapellil | 7:d79cbeda2982 | 90 | inline int |
mapellil | 7:d79cbeda2982 | 91 | trace_putchar(int c); |
mapellil | 7:d79cbeda2982 | 92 | |
mapellil | 7:d79cbeda2982 | 93 | inline void |
mapellil | 7:d79cbeda2982 | 94 | trace_dump_args(int argc, char* argv[]); |
mapellil | 7:d79cbeda2982 | 95 | |
mapellil | 7:d79cbeda2982 | 96 | #if defined(__cplusplus) |
mapellil | 7:d79cbeda2982 | 97 | } |
mapellil | 7:d79cbeda2982 | 98 | #endif |
mapellil | 7:d79cbeda2982 | 99 | |
mapellil | 7:d79cbeda2982 | 100 | inline void |
mapellil | 7:d79cbeda2982 | 101 | __attribute__((always_inline)) |
mapellil | 7:d79cbeda2982 | 102 | trace_initialize(void) |
mapellil | 7:d79cbeda2982 | 103 | { |
mapellil | 7:d79cbeda2982 | 104 | } |
mapellil | 7:d79cbeda2982 | 105 | |
mapellil | 7:d79cbeda2982 | 106 | // Empty definitions when trace is not defined |
mapellil | 7:d79cbeda2982 | 107 | inline ssize_t |
mapellil | 7:d79cbeda2982 | 108 | __attribute__((always_inline)) |
mapellil | 7:d79cbeda2982 | 109 | trace_write(const char* buf __attribute__((unused)), |
mapellil | 7:d79cbeda2982 | 110 | size_t nbyte __attribute__((unused))) |
mapellil | 7:d79cbeda2982 | 111 | { |
mapellil | 7:d79cbeda2982 | 112 | return 0; |
mapellil | 7:d79cbeda2982 | 113 | } |
mapellil | 7:d79cbeda2982 | 114 | |
mapellil | 7:d79cbeda2982 | 115 | inline int |
mapellil | 7:d79cbeda2982 | 116 | __attribute__((always_inline)) |
mapellil | 7:d79cbeda2982 | 117 | trace_printf(const char* format __attribute__((unused)), ...) |
mapellil | 7:d79cbeda2982 | 118 | { |
mapellil | 7:d79cbeda2982 | 119 | return 0; |
mapellil | 7:d79cbeda2982 | 120 | } |
mapellil | 7:d79cbeda2982 | 121 | |
mapellil | 7:d79cbeda2982 | 122 | inline int |
mapellil | 7:d79cbeda2982 | 123 | __attribute__((always_inline)) |
mapellil | 7:d79cbeda2982 | 124 | trace_puts(const char *s __attribute__((unused))) |
mapellil | 7:d79cbeda2982 | 125 | { |
mapellil | 7:d79cbeda2982 | 126 | return 0; |
mapellil | 7:d79cbeda2982 | 127 | } |
mapellil | 7:d79cbeda2982 | 128 | |
mapellil | 7:d79cbeda2982 | 129 | inline int |
mapellil | 7:d79cbeda2982 | 130 | __attribute__((always_inline)) |
mapellil | 7:d79cbeda2982 | 131 | trace_putchar(int c) |
mapellil | 7:d79cbeda2982 | 132 | { |
mapellil | 7:d79cbeda2982 | 133 | return c; |
mapellil | 7:d79cbeda2982 | 134 | } |
mapellil | 7:d79cbeda2982 | 135 | |
mapellil | 7:d79cbeda2982 | 136 | inline void |
mapellil | 7:d79cbeda2982 | 137 | __attribute__((always_inline)) |
mapellil | 7:d79cbeda2982 | 138 | trace_dump_args(int argc __attribute__((unused)), |
mapellil | 7:d79cbeda2982 | 139 | char* argv[] __attribute__((unused))) |
mapellil | 7:d79cbeda2982 | 140 | { |
mapellil | 7:d79cbeda2982 | 141 | } |
mapellil | 7:d79cbeda2982 | 142 | |
mapellil | 7:d79cbeda2982 | 143 | #endif // defined(TRACE) |
mapellil | 7:d79cbeda2982 | 144 | |
mapellil | 7:d79cbeda2982 | 145 | // ---------------------------------------------------------------------------- |
mapellil | 7:d79cbeda2982 | 146 | |
mapellil | 7:d79cbeda2982 | 147 | #endif // DIAG_TRACE_H_ |
mapellil | 7:d79cbeda2982 | 148 |