Skip to content

Commit 90a519a

Browse files
committed
Added JLinkRTT library
1 parent 7d63399 commit 90a519a

12 files changed

+1582
-0
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/*********************************************************************
2+
* SEGGER MICROCONTROLLER SYSTEME GmbH
3+
* Solutions for real time microcontroller applications
4+
**********************************************************************
5+
File : Main_RTT_MenuApp.c
6+
Purpose : Sample application to demonstrate RTT bi-directional functionality
7+
Target Hardware: Debug J-Link ULTRA/PRO V4
8+
--------- END-OF-HEADER --------------------------------------------*/
9+
10+
#define MAIN_C
11+
12+
#include <stdio.h>
13+
14+
#include "SEGGER_RTT.h"
15+
16+
volatile int _Cnt;
17+
volatile int _Delay;
18+
19+
static char r;
20+
21+
/*********************************************************************
22+
*
23+
* main
24+
*/
25+
void main(void) {
26+
27+
SEGGER_RTT_WriteString(0, "SEGGER Real-Time-Terminal Sample\r\n");
28+
SEGGER_RTT_ConfigUpBuffer(0, NULL, NULL, 0, SEGGER_RTT_MODE_NO_BLOCK_SKIP);
29+
do {
30+
r = SEGGER_RTT_WaitKey();
31+
SEGGER_RTT_Write(0, &r, 1);
32+
r++;
33+
} while (1);
34+
}
35+
36+
/*************************** End of file ****************************/

JLinkRTT/Examples/Main_RTT_MenuApp.c

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
/*********************************************************************
2+
* SEGGER MICROCONTROLLER SYSTEME GmbH
3+
* Solutions for real time microcontroller applications
4+
**********************************************************************
5+
File : Main_RTT_MenuApp.c
6+
Purpose : Sample application to demonstrate RTT bi-directional functionality
7+
Target Hardware: Debug J-Link ULTRA/PRO V4
8+
--------- END-OF-HEADER --------------------------------------------*/
9+
10+
#define MAIN_C
11+
12+
#include <stdio.h>
13+
14+
#include "SEGGER_RTT.h"
15+
16+
volatile int _Cnt;
17+
volatile int _Delay;
18+
19+
/*********************************************************************
20+
*
21+
* main
22+
*/
23+
void main(void) {
24+
int r;
25+
int CancelOp;
26+
27+
do {
28+
_Cnt = 0;
29+
30+
SEGGER_RTT_WriteString(0, "SEGGER Real-Time-Terminal Sample\r\n");
31+
SEGGER_RTT_WriteString(0, "Press <1> to continue in blocking mode (Application waits if necessary, no data lost)\r\n");
32+
SEGGER_RTT_WriteString(0, "Press <2> to continue in non-blocking mode (Application does not wait, data lost if fifo full)\r\n");
33+
do {
34+
r = SEGGER_RTT_WaitKey();
35+
} while ((r != '1') && (r != '2'));
36+
if (r == '1') {
37+
SEGGER_RTT_WriteString(0, "\r\nSelected <1>. Configuring RTT and starting...\r\n");
38+
SEGGER_RTT_ConfigUpBuffer(0, NULL, NULL, 0, SEGGER_RTT_MODE_BLOCK_IF_FIFO_FULL);
39+
} else {
40+
SEGGER_RTT_WriteString(0, "\r\nSelected <2>. Configuring RTT and starting...\r\n");
41+
SEGGER_RTT_ConfigUpBuffer(0, NULL, NULL, 0, SEGGER_RTT_MODE_NO_BLOCK_SKIP);
42+
}
43+
CancelOp = 0;
44+
do {
45+
//for (_Delay = 0; _Delay < 10000; _Delay++);
46+
SEGGER_RTT_printf(0, "Count: %d. Press <Space> to get back to menu.\r\n", _Cnt++);
47+
r = SEGGER_RTT_HasKey();
48+
if (r) {
49+
CancelOp = (SEGGER_RTT_GetKey() == ' ') ? 1 : 0;
50+
}
51+
//
52+
// Check if user selected to cancel the current operation
53+
//
54+
if (CancelOp) {
55+
SEGGER_RTT_WriteString(0, "Operation cancelled, going back to menu...\r\n");
56+
break;
57+
}
58+
} while (1);
59+
SEGGER_RTT_GetKey();
60+
SEGGER_RTT_WriteString(0, "\r\n");
61+
} while (1);
62+
}
63+
64+
/*************************** End of file ****************************/
Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
/*********************************************************************
2+
* SEGGER MICROCONTROLLER SYSTEME GmbH
3+
* Solutions for real time microcontroller applications
4+
**********************************************************************
5+
File : Main_RTT_MenuApp.c
6+
Purpose : Sample application to demonstrate RTT bi-directional functionality
7+
Target Hardware: Debug J-Link ULTRA/PRO V4
8+
--------- END-OF-HEADER --------------------------------------------*/
9+
10+
#define MAIN_C
11+
12+
#include <stdio.h>
13+
14+
#include "SEGGER_RTT.h"
15+
16+
volatile int _Cnt;
17+
18+
/*********************************************************************
19+
*
20+
* main
21+
*/
22+
void main(void) {
23+
24+
SEGGER_RTT_ConfigUpBuffer(0, NULL, NULL, 0, SEGGER_RTT_MODE_BLOCK_IF_FIFO_FULL);
25+
26+
SEGGER_RTT_WriteString(0, "SEGGER Real-Time-Terminal Sample\r\n\r\n");
27+
SEGGER_RTT_WriteString(0, "###### Testing SEGGER_printf() ######\r\n");
28+
29+
SEGGER_RTT_printf(0, "printf Test: %%c, 'S' : %c.\r\n", 'S');
30+
SEGGER_RTT_printf(0, "printf Test: %%5c, 'E' : %5c.\r\n", 'E');
31+
SEGGER_RTT_printf(0, "printf Test: %%-5c, 'G' : %-5c.\r\n", 'G');
32+
SEGGER_RTT_printf(0, "printf Test: %%5.3c, 'G' : %-5c.\r\n", 'G');
33+
SEGGER_RTT_printf(0, "printf Test: %%.3c, 'E' : %-5c.\r\n", 'E');
34+
SEGGER_RTT_printf(0, "printf Test: %%c, 'R' : %c.\r\n", 'R');
35+
36+
SEGGER_RTT_printf(0, "printf Test: %%s, \"RTT\" : %s.\r\n", "RTT");
37+
SEGGER_RTT_printf(0, "printf Test: %%s, \"RTT\\r\\nRocks.\" : %s.\r\n", "RTT\r\nRocks.");
38+
39+
SEGGER_RTT_printf(0, "printf Test: %%u, 12345 : %u.\r\n", 12345);
40+
SEGGER_RTT_printf(0, "printf Test: %%+u, 12345 : %+u.\r\n", 12345);
41+
SEGGER_RTT_printf(0, "printf Test: %%.3u, 12345 : %.3u.\r\n", 12345);
42+
SEGGER_RTT_printf(0, "printf Test: %%.6u, 12345 : %.6u.\r\n", 12345);
43+
SEGGER_RTT_printf(0, "printf Test: %%6.3u, 12345 : %6.3u.\r\n", 12345);
44+
SEGGER_RTT_printf(0, "printf Test: %%8.6u, 12345 : %8.6u.\r\n", 12345);
45+
SEGGER_RTT_printf(0, "printf Test: %%08u, 12345 : %08u.\r\n", 12345);
46+
SEGGER_RTT_printf(0, "printf Test: %%08.6u, 12345 : %08.6u.\r\n", 12345);
47+
SEGGER_RTT_printf(0, "printf Test: %%0u, 12345 : %0u.\r\n", 12345);
48+
SEGGER_RTT_printf(0, "printf Test: %%-.6u, 12345 : %-.6u.\r\n", 12345);
49+
SEGGER_RTT_printf(0, "printf Test: %%-6.3u, 12345 : %-6.3u.\r\n", 12345);
50+
SEGGER_RTT_printf(0, "printf Test: %%-8.6u, 12345 : %-8.6u.\r\n", 12345);
51+
SEGGER_RTT_printf(0, "printf Test: %%-08u, 12345 : %-08u.\r\n", 12345);
52+
SEGGER_RTT_printf(0, "printf Test: %%-08.6u, 12345 : %-08.6u.\r\n", 12345);
53+
SEGGER_RTT_printf(0, "printf Test: %%-0u, 12345 : %-0u.\r\n", 12345);
54+
55+
SEGGER_RTT_printf(0, "printf Test: %%u, -12345 : %u.\r\n", -12345);
56+
SEGGER_RTT_printf(0, "printf Test: %%+u, -12345 : %+u.\r\n", -12345);
57+
SEGGER_RTT_printf(0, "printf Test: %%.3u, -12345 : %.3u.\r\n", -12345);
58+
SEGGER_RTT_printf(0, "printf Test: %%.6u, -12345 : %.6u.\r\n", -12345);
59+
SEGGER_RTT_printf(0, "printf Test: %%6.3u, -12345 : %6.3u.\r\n", -12345);
60+
SEGGER_RTT_printf(0, "printf Test: %%8.6u, -12345 : %8.6u.\r\n", -12345);
61+
SEGGER_RTT_printf(0, "printf Test: %%08u, -12345 : %08u.\r\n", -12345);
62+
SEGGER_RTT_printf(0, "printf Test: %%08.6u, -12345 : %08.6u.\r\n", -12345);
63+
SEGGER_RTT_printf(0, "printf Test: %%0u, -12345 : %0u.\r\n", -12345);
64+
SEGGER_RTT_printf(0, "printf Test: %%-.6u, -12345 : %-.6u.\r\n", -12345);
65+
SEGGER_RTT_printf(0, "printf Test: %%-6.3u, -12345 : %-6.3u.\r\n", -12345);
66+
SEGGER_RTT_printf(0, "printf Test: %%-8.6u, -12345 : %-8.6u.\r\n", -12345);
67+
SEGGER_RTT_printf(0, "printf Test: %%-08u, -12345 : %-08u.\r\n", -12345);
68+
SEGGER_RTT_printf(0, "printf Test: %%-08.6u, -12345 : %-08.6u.\r\n", -12345);
69+
SEGGER_RTT_printf(0, "printf Test: %%-0u, -12345 : %-0u.\r\n", -12345);
70+
71+
SEGGER_RTT_printf(0, "printf Test: %%d, -12345 : %d.\r\n", -12345);
72+
SEGGER_RTT_printf(0, "printf Test: %%+d, -12345 : %+d.\r\n", -12345);
73+
SEGGER_RTT_printf(0, "printf Test: %%.3d, -12345 : %.3d.\r\n", -12345);
74+
SEGGER_RTT_printf(0, "printf Test: %%.6d, -12345 : %.6d.\r\n", -12345);
75+
SEGGER_RTT_printf(0, "printf Test: %%6.3d, -12345 : %6.3d.\r\n", -12345);
76+
SEGGER_RTT_printf(0, "printf Test: %%8.6d, -12345 : %8.6d.\r\n", -12345);
77+
SEGGER_RTT_printf(0, "printf Test: %%08d, -12345 : %08d.\r\n", -12345);
78+
SEGGER_RTT_printf(0, "printf Test: %%08.6d, -12345 : %08.6d.\r\n", -12345);
79+
SEGGER_RTT_printf(0, "printf Test: %%0d, -12345 : %0d.\r\n", -12345);
80+
SEGGER_RTT_printf(0, "printf Test: %%-.6d, -12345 : %-.6d.\r\n", -12345);
81+
SEGGER_RTT_printf(0, "printf Test: %%-6.3d, -12345 : %-6.3d.\r\n", -12345);
82+
SEGGER_RTT_printf(0, "printf Test: %%-8.6d, -12345 : %-8.6d.\r\n", -12345);
83+
SEGGER_RTT_printf(0, "printf Test: %%-08d, -12345 : %-08d.\r\n", -12345);
84+
SEGGER_RTT_printf(0, "printf Test: %%-08.6d, -12345 : %-08.6d.\r\n", -12345);
85+
SEGGER_RTT_printf(0, "printf Test: %%-0d, -12345 : %-0d.\r\n", -12345);
86+
87+
SEGGER_RTT_printf(0, "printf Test: %%x, 0x1234ABC : %x.\r\n", 0x1234ABC);
88+
SEGGER_RTT_printf(0, "printf Test: %%+x, 0x1234ABC : %+x.\r\n", 0x1234ABC);
89+
SEGGER_RTT_printf(0, "printf Test: %%.3x, 0x1234ABC : %.3x.\r\n", 0x1234ABC);
90+
SEGGER_RTT_printf(0, "printf Test: %%.6x, 0x1234ABC : %.6x.\r\n", 0x1234ABC);
91+
SEGGER_RTT_printf(0, "printf Test: %%6.3x, 0x1234ABC : %6.3x.\r\n", 0x1234ABC);
92+
SEGGER_RTT_printf(0, "printf Test: %%8.6x, 0x1234ABC : %8.6x.\r\n", 0x1234ABC);
93+
SEGGER_RTT_printf(0, "printf Test: %%08x, 0x1234ABC : %08x.\r\n", 0x1234ABC);
94+
SEGGER_RTT_printf(0, "printf Test: %%08.6x, 0x1234ABC : %08.6x.\r\n", 0x1234ABC);
95+
SEGGER_RTT_printf(0, "printf Test: %%0x, 0x1234ABC : %0x.\r\n", 0x1234ABC);
96+
SEGGER_RTT_printf(0, "printf Test: %%-.6x, 0x1234ABC : %-.6x.\r\n", 0x1234ABC);
97+
SEGGER_RTT_printf(0, "printf Test: %%-6.3x, 0x1234ABC : %-6.3x.\r\n", 0x1234ABC);
98+
SEGGER_RTT_printf(0, "printf Test: %%-8.6x, 0x1234ABC : %-8.6x.\r\n", 0x1234ABC);
99+
SEGGER_RTT_printf(0, "printf Test: %%-08x, 0x1234ABC : %-08x.\r\n", 0x1234ABC);
100+
SEGGER_RTT_printf(0, "printf Test: %%-08.6x, 0x1234ABC : %-08.6x.\r\n", 0x1234ABC);
101+
SEGGER_RTT_printf(0, "printf Test: %%-0x, 0x1234ABC : %-0x.\r\n", 0x1234ABC);
102+
103+
SEGGER_RTT_printf(0, "printf Test: %%p, &_Cnt : %p.\r\n", &_Cnt);
104+
105+
SEGGER_RTT_WriteString(0, "###### SEGGER_printf() Tests done. ######\r\n");
106+
do {
107+
_Cnt++;
108+
} while (1);
109+
}
110+
111+
/*************************** End of file ****************************/
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
/*********************************************************************
2+
* SEGGER MICROCONTROLLER GmbH & Co KG *
3+
* Solutions for real time microcontroller applications *
4+
**********************************************************************
5+
* *
6+
* (c) 1995 - 2013 SEGGER Microcontroller GmbH & Co KG *
7+
* *
8+
* www.segger.com Support: support@segger.com *
9+
* *
10+
**********************************************************************
11+
* *
12+
* embOS * Real time operating system for microcontrollers *
13+
* *
14+
* *
15+
* Please note: *
16+
* *
17+
* Knowledge of this file may under no circumstances *
18+
* be used to write a similar product or a real-time *
19+
* operating system for in-house use. *
20+
* *
21+
* Thank you for your fairness ! *
22+
* *
23+
**********************************************************************
24+
* *
25+
* OS version: 3.88g *
26+
* *
27+
**********************************************************************
28+
29+
----------------------------------------------------------------------
30+
File : Main_RTT_SpeedTestApp.c
31+
Purpose : Sample program for measuring RTT performance.
32+
Target Hardware: Debug J-Link ULTRA/PRO V4
33+
--------- END-OF-HEADER --------------------------------------------*/
34+
35+
36+
#include "RTOS.h"
37+
#include "BSP.h"
38+
39+
#include "SEGGER_RTT.h"
40+
#include <stdio.h>
41+
42+
OS_STACKPTR int StackHP[128], StackLP[128]; /* Task stacks */
43+
OS_TASK TCBHP, TCBLP; /* Task-control-blocks */
44+
45+
static void HPTask(void) {
46+
while (1) {
47+
//
48+
// Measure time needed for RTT output
49+
// Perform dummy write with 0 characters, so we know the overhead of toggling LEDs and RTT in general
50+
//
51+
// Set BP here. Then start sampling on scope
52+
BSP_ClrLED(0);
53+
SEGGER_RTT_Write(0, 0, 0);
54+
BSP_SetLED(0);
55+
BSP_ClrLED(0);
56+
SEGGER_RTT_Write(0, "01234567890123456789012345678901234567890123456789012345678901234567890123456789\r\n", 82);
57+
BSP_SetLED(0);
58+
// Set BP here. Then stop sampling on scope
59+
OS_Delay(200);
60+
}
61+
}
62+
63+
static void LPTask(void) {
64+
while (1) {
65+
BSP_ToggleLED(1);
66+
OS_Delay (500);
67+
}
68+
}
69+
70+
/*********************************************************************
71+
*
72+
* main
73+
*
74+
*********************************************************************/
75+
76+
int main(void) {
77+
OS_IncDI(); /* Initially disable interrupts */
78+
OS_InitKern(); /* Initialize OS */
79+
OS_InitHW(); /* Initialize Hardware for OS */
80+
BSP_Init(); /* Initialize LED ports */
81+
BSP_SetLED(0);
82+
/* You need to create at least one task before calling OS_Start() */
83+
OS_CREATETASK(&TCBHP, "HP Task", HPTask, 100, StackHP);
84+
OS_CREATETASK(&TCBLP, "LP Task", LPTask, 50, StackLP);
85+
OS_Start(); /* Start multitasking */
86+
return 0;
87+
}
88+

JLinkRTT/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# SEGGER J-Link RTT Support in Visual Studio Code Arduino
2+
3+
Segger J-Link RTT is a facility to support low-impact, data I/O from embedded application under test to a debugging host.
4+

JLinkRTT/README.txt

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
README.txt for the SEGGER RTT Implementation Pack.
2+
Date: 17 Dec 2014
3+
4+
Included files:
5+
===============
6+
Root Directory
7+
- Examples
8+
- RTT_MenuApp.c - Sample application to demonstrate RTT bi-directional functionality. No OS.
9+
- RTT_embOS_SpeedTestApp.c - Sample application for measuring RTT performance. embOS needed.
10+
- RTT
11+
- SEGGER_RTT.c - The RTT implementation.
12+
- SEGGER_RTT.h - Header for RTT implementation.
13+
- SEGGER_RTT_Conf.h - Pre-processor configuration for the RTT implementation.
14+
- SEGGER_RTT_Printf.c - Simple implementation of printf to write formatted strings via RTT.
15+
- Syscalls
16+
- RTT_Syscalls_GCC.c - Low-level syscalls to retarget printf() to RTT with GCC / Newlib.
17+
- RTT_Syscalls_IAR.c - Low-level syscalls to retarget printf() to RTT with IAR compiler.
18+
- RTT_Syscalls_KEIL.c - Low-level syscalls to retarget printf() to RTT with KEIL/uVision compiler.

JLinkRTT/library.properties

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
name=SEGGER_JLINK_RTT
2+
version=0.0.1
3+
author=SEGGER Microcontroller GmbH & Co KG
4+
maintainer=support@segger.com
5+
sentence=Support files for JLink RTT facility.
6+
paragraph=SEGGER provided support files to enable and use the Real-Time Transfer (RTT) facility..
7+
category=Communication
8+
url=https://www.segger.com/products/debug-probes/j-link/technology/about-real-time-transfer/
9+
architectures=*
10+
includes=SEGGER_RTT.h

JLinkRTT/src/RTT_Syscalls_GCC.c

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/*********************************************************************
2+
* SEGGER MICROCONTROLLER GmbH & Co KG *
3+
* Solutions for real time microcontroller applications *
4+
**********************************************************************
5+
* *
6+
* (c) 2014 SEGGER Microcontroller GmbH & Co KG *
7+
* *
8+
* www.segger.com Support: support@segger.com *
9+
* *
10+
**********************************************************************
11+
12+
----------------------------------------------------------------------
13+
File : RTT_Syscalls.c
14+
Purpose : Low-level functions for using printf() via RTT in GCC
15+
-------- END-OF-HEADER ---------------------------------------------
16+
*/
17+
#include "SEGGER_RTT.h"
18+
19+
/*********************************************************************
20+
*
21+
* Function prototypes
22+
*
23+
**********************************************************************
24+
*/
25+
int _write(int file, char *ptr, int len);
26+
27+
/*********************************************************************
28+
*
29+
* Global functions
30+
*
31+
**********************************************************************
32+
*/
33+
34+
/*********************************************************************
35+
*
36+
* _write()
37+
*
38+
* Function description
39+
* Low-level write function.
40+
* libc subroutines will use this system routine for output to all files,
41+
* including stdout.
42+
* Write data via RTT.
43+
*/
44+
int _write(int file, char *ptr, int len) {
45+
(void) file; /* Not used, avoid warning */
46+
SEGGER_RTT_Write(0, ptr, len);
47+
return len;
48+
}
49+
50+
/****** End Of File *************************************************/

0 commit comments

Comments
 (0)