Dynamically Changing RTT Blocking
If that title means anything to you, you’ve spent time on the internet trying to make RTT work for you. Read on for code to help you dynamically change if your RTT output blocks or not.
RTT is great for getting debug data from your device with minimal interruption to your real-time system. The only downside is that when trying to keep it real-time you often miss debug data. It would be really nice to be able to choose when the RTT output blocks so that you can get big chunks of data, say configuration data at startup, when real-time behavior is not required. After some digging in the Segger RTT libraries, I have the solution:
* @brief This reaches into the RTT Configuration and will change the RTT Mode.
* @param Flags This can be SEGGER_RTT_MODE_BLOCK_IF_FIFO_FULL, SEGGER_RTT_MODE_NO_BLOCK_TRIM, SEGGER_RTT_MODE_NO_BLOCK_SKIP, or SEGGER_RTT_MODE_DEFAULT
void rttReconfigure(unsigned Flags)
SEGGER_RTT_LOCK(); //This keeps things thread-safe
pRing = (SEGGER_RTT_BUFFER_UP*)((char*)&_SEGGER_RTT.aUp + SEGGER_RTT_UNCACHED_OFF); // Access uncached to make sure we see changes made by the J-Link side and all of our changes go into HW directly
pRing->Flags = Flags;