#define SEGGER_SYSVIEW_ID_BASE 0x10000000 // Default value for the lowest Id reported by the application. Can be overridden by the application via SEGGER_SYSVIEW_SetRAMBase(). (i.e. 0x20000000 when all Ids are an address in this RAM)
#define SEGGER_SYSVIEW_ID_SHIFT 2 // Number of bits to shift the Id to save bandwidth. (i.e. 2 when Ids are 4 byte aligned)
#define SEGGER_SYSVIEW_GET_INTERRUPT_ID() ((*(U32 *)(0xE000ED04)) & 0x1FF) // Get the currently active interrupt Id. (i.e. read Cortex-M ICSR[8:0] = active vector)
#define SEGGER_SYSVIEW_GET_INTERRUPT_ID() ((*(U32 *)(0xE000ED04)) & 0x3F) // Get the currently active interrupt Id. (i.e. read Cortex-M ICSR[5:0] = active vector)
#else
#define SEGGER_SYSVIEW_GET_INTERRUPT_ID() SEGGER_SYSVIEW_X_GetInterruptId() // Get the currently active interrupt Id from the user-provided function.
#endif
#endif // SEGGER_SYSVIEW_CONF_H
/*************************** End of file ****************************/
TaskState 0xFC 0=Ready, 8=Wait for event, 16=Wait for sema zero, 24=Waiting, 32=Wait for sema not zero, 48=Wait for Queue not empty, 56=Wait for mailbox not full, 64=Wait for mailbox not empty, 72=Wait for event object, 80=Wait for Queue not full, 160=Wait for Memory pool, 4=Wait for timeout, 12=Wait for event with timeout, 20=Wait for sema zero with timeout, 28=Waiting with timeout, 36=Wait for sema not zero with timeout, 52=Wait for Queue not empty with timeout, 60=Wait for mailbox not full with timeout, 68=Wait for mailbox not empty with timeout, 76=Wait for event object with timeout, 84=Wait for Queue not full with timeout, 164=Wait for Memory pool with timeout
This is a legal agreement between YOU as an individual and SEGGER Microcontroller GmbH & Co. KG ( hereafter called SEGGER).
All IP rights, title and interest in SystemView Utility is and shall at all times remain with SEGGER.
By downloading and/or using SystemView, YOU agree to be bound by the terms of this agreement.
1. License Grant
The SystemView Utility is provided in executable code form only.
YOU may use SystemView for personal or for commercial purposes.
2. RESTRICTIONS
YOU may not:
(a) decompile, disassemble, reverse engineer, or otherwise attempt to derive the source code of SystemView,
(b) redistribute, encumber, sell, rent, lease, sublicense, or otherwise transfer rights to SystemView,
(c) remove or alter any trademark, logo, copyright or other proprietary notices, legends, symbols or label in SystemView.
Without prejudice to any other rights, SEGGER may terminate this agreement if YOU fail to comply with foregoing restrictions.
3. FEES
SystemView can be used free of charge without purchasing a license.
4. DISCLAIMER OF WARRANTY
SystemView is provided on an "as is" basis, without warranty of any kind, including without limitation the warranties that it is free of defects, merchantable, fit for a particular purpose or non-infringing. This disclaimer of warranty constitutes an essential part of this agreement. No use of SystemView is authorized hereunder except under this disclaimer.
5. LIMITATION OF LIABILITY
To the maximum extent permitted by applicable law, in no event will SEGGER be liable for any indirect, special, incidental or consequential damages arising out of the use of or inability to use SystemView, including, without limitation, damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other damages or losses, even if advised of the possibility thereof, and regardless of the legal or equitable theory (contract, tort or otherwise) upon which the claim is based. Some jurisdictions do not allow the exclusion or limitation of incidental or consequential damages, so this exclusion and limitation may not be applicable. In any case, SEGGER's entire liability shall not exceed in aggregate the sum of the fees YOU paid for SystemView (if any).
6. MISCELLANEOUS
(a) This agreement shall be governed by the laws of the Federal Republic of Germany. This agreement constitutes the entire agreement between the parties concerning the subject matter hereof.
(b) If any provision in this agreement should be held illegal or unenforceable by a court having jurisdiction, such provision shall be modified to the extent necessary to render it enforceable without losing its intent, or severed from this agreement if no such modification is possible, and other provisions of this agreement shall remain in full force and effect.This agreement may be changed only by an amendment in writing, signed by both parties.
(c) If any SEGGER professional services are being provided, then such professional services are provided pursuant to the terms of a separate agreement.
(c) 2004-2015 SEGGER Microcontroller GmbH & Co. KG
* Sets the terminal to be used for output on channel 0.
*
* Parameters
* TerminalId Index of the terminal.
*
* Return value
* >= 0 O.K.
* < 0 Error (e.g. if RTT is configured for non-blocking mode and there was no space in the buffer to set the new terminal Id)
*/
intSEGGER_RTT_SetTerminal(charTerminalId){
charac[2];
SEGGER_RTT_BUFFER_UP*pRing;
unsignedAvail;
intr;
//
INIT();
//
r=0;
ac[0]=0xFFU;
if((unsignedchar)TerminalId<(unsignedchar)sizeof(_aTerminalId)){// We only support a certain number of channels
ac[1]=_aTerminalId[(unsignedchar)TerminalId];
pRing=&_SEGGER_RTT.aUp[0];// Buffer 0 is always reserved for terminal I/O, so we can use index 0 here, fixed
SEGGER_RTT_LOCK();// Lock to make sure that no other task is writing into buffer, while we are and number of free bytes in buffer does not change downwards after checking and before writing
// Description for a circular buffer (also called "ring buffer")
// which is used as up-buffer (T->H)
//
typedefstruct{
constchar*sName;// Optional name. Standard names so far are: "Terminal", "SysView", "J-Scope_t4i4"
char*pBuffer;// Pointer to start of buffer
unsignedSizeOfBuffer;// Buffer size in bytes. Note that one byte is lost, as this implementation does not fill up the buffer in order to avoid the problem of being unable to distinguish between full and empty.
unsignedWrOff;// Position of next item to be written by either target.
volatileunsignedRdOff;// Position of next item to be read by host. Must be volatile since it may be modified by host.
unsignedFlags;// Contains configuration flags
}SEGGER_RTT_BUFFER_UP;
//
// Description for a circular buffer (also called "ring buffer")
// which is used as down-buffer (H->T)
//
typedefstruct{
constchar*sName;// Optional name. Standard names so far are: "Terminal", "SysView", "J-Scope_t4i4"
char*pBuffer;// Pointer to start of buffer
unsignedSizeOfBuffer;// Buffer size in bytes. Note that one byte is lost, as this implementation does not fill up the buffer in order to avoid the problem of being unable to distinguish between full and empty.
volatileunsignedWrOff;// Position of next item to be written by host. Must be volatile since it may be modified by host.
unsignedRdOff;// Position of next item to be read by target (down-buffer).
unsignedFlags;// Contains configuration flags
}SEGGER_RTT_BUFFER_DOWN;
//
// RTT control block which describes the number of buffers available
// as well as the configuration for each buffer
//
//
typedefstruct{
characID[16];// Initialized to "SEGGER RTT"
intMaxNumUpBuffers;// Initialized to SEGGER_RTT_MAX_NUM_UP_BUFFERS (type. 2)
intMaxNumDownBuffers;// Initialized to SEGGER_RTT_MAX_NUM_DOWN_BUFFERS (type. 2)
SEGGER_RTT_BUFFER_UPaUp[SEGGER_RTT_MAX_NUM_UP_BUFFERS];// Up buffers, transferring information up from target via debug probe to host
SEGGER_RTT_BUFFER_DOWNaDown[SEGGER_RTT_MAX_NUM_DOWN_BUFFERS];// Down buffers, transferring information down from host via debug probe to target
// Loop until Digit has the value of the highest digit required.
// Example: If the output is 345 (Base 10), loop 2 times until Digit is 100.
//
while(1){
if(NumDigits>1u){// User specified a min number of digits to print? => Make sure we loop at least that often, before checking anything else (> 1 check avoids problems with NumDigits being signed / unsigned)
NumDigits--;
}else{
Div=v/Digit;
if(Div<Base){// Is our divider big enough to extract the highest digit from value? => Done
#define SEGGER_SYSVIEW_INFO_SIZE 9 // Minimum size, which has to be reserved for a packet. 1-2 byte of message type, 0-2 byte of payload length, 1-5 bytes of timestamp.
#define SEGGER_SYSVIEW_QUANTA_U32 5 // Maximum number of bytes to encode a U32, should be reserved for each 32-bit value in a packet.
#define SEGGER_SYSVIEW_LOG (0u)
#define SEGGER_SYSVIEW_WARNING (1u)
#define SEGGER_SYSVIEW_ERROR (2u)
#define SEGGER_SYSVIEW_FLAG_APPEND (1u << 6)
#define SEGGER_SYSVIEW_PREPARE_PACKET(p) (p) + 4
//
// SystemView events. First 32 IDs from 0 .. 31 are reserved for these
Segger SystemView only support Segger J-Link and Segger J-Link OB. If you using the origin development boards from vendor, you can upgrade the on board debugger to J-Link OB.
* For ST ST-Link, here is the [ST-Link upgrade utility download page](https://www.segger.com/jlink-st-link.html)
* For Atmel EDBG, here is the [EDBG upgrade utility download page](https://www.segger.com/jlink-edbg.html)
* For Freescale(NXP) OpenSDA/OpenSDA-V2, here is the [OpenSDA upgrade utility download page](https://www.segger.com/opensda.html)
* For NXP LPC Link 2, here is the [LPC link 2 upgrade utility download page](https://www.segger.com/lpc-link-2.html)
* NXP LPCXpresso, here is the [LPCXpresso upgrade utility download page](https://www.segger.com/jlink-lpcxpresso-ob.html)
### 4. Intergration (Porting) limitation
* Can only trace thread, scheduler and interrupt.
* Tracing RT-Thread IPC component is not supported.