-
@Sazerac4 asked:
#define trice8(tid, fmt, ...) // Log (no timestamp)
#define Trice8(tid, fmt, ...) // Log (16 bits timestamp)
#define TRice8(tid, fmt, ...) // Log (32 bits timestamp)
//
#define TRICE8(tid, fmt, ...) // What is the purpose of this kind of macros ?
//! TRICE8_0 writes trice data as fast as possible in a buffer.
//! \param tid is a 16 bit Trice id in upper 2 bytes of a 32 bit value
#define TRICE8_0(tid, pFmt) \
TRICE_ENTER tid; \
TRICE_CNTC(0); \
TRICE_LEAVE |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
The macros trice8, trice16, trice32 and trice64 are always usable and the number 8, 16, 32, 64 specifies the parameter width. They are partially disabled, when the value
Mainly speed. If you do all byte wise, things slow down. Of course alignment is important when using 32-bit instructions. The Trice macro base size is 4 bytes. If, for example a single 8-bit value is parameter, its includes 3 padding 0-bytes. These are not transferred - they only occupy RAM. A 64-bit alignment would be overkill, so 32-bit seems to be a good choice, as many MCUs nowadays are 32-bit ones.
"the full uppercase one" is the real Trice macro only using inline code. Because the main design aim was speed, this was the original design. Then I realized, that several hundred of The
tid in this context is executable code //! ID writes 14-bit id with 11 as 2 most significant bits, followed by a 32-bit stamp.
//! 11iiiiiiI TT | TT (NC) | ...
//! C000 = 1100 0000 0000 0000
#define ID(n) \
do { \
uint32_t ts = TriceStamp32; \
TRICE_PUT16_1616((0xC000 | (n)), ts); \
} while (0)
//! Id writes 14-bit id with 10 as 2 most significant bits two times, followed by a 16-bit stamp.
//! 10iiiiiiI 10iiiiiiI | TT (NC) | ...
//! 8000 = 1000 0000 0000 0000
#define Id(n) \
do { \
uint16_t ts = TriceStamp16; \
TRICE_PUT((0x80008000 | ((n) << 16) | (n))); \
TRICE_PUT16(ts); \
} while (0)
//! id writes 14-bit id with 01 as 2 most significant bits, followed by no stamp.
//! 01iiiiiiI (NC) | ...
//! 4000 = 0100 0000 0000 0000
#define id(n) TRICE_PUT16(0x4000 | (n));
//! iD is just a code parsing helper.
#define iD(n) (n) |
Beta Was this translation helpful? Give feedback.
The macros trice8, trice16, trice32 and trice64 are always usable and the number 8, 16, 32, 64 specifies the parameter width. They are partially disabled, when the value
TRICE_SINGLE_MAX_SIZE
is defined to be smaller than 104. That's mainly to get compiler errors rather than runtime errors. The valueTRICE_DEFAULT_PARAMETER_BIT_WIDTH
is the parameter bit with for the macrotrice
(without number). It can make sense to set this va…