This directory contains a SpaceWire Distributed Time Protocol (SPWTDP) RTEMS 
example application.

The Makefile is used to build the example "make all".

When building the examples it is possible to control the behaviour by setting the following variables.

CPU         - By setting the CPU variable to one of the cpu-targets, then the hardware specific flags for that cpu-target will be added when compiling.
CFLAGS      - Override common compilation flags
CPUFLAGS    - Override the hardware specific compilation flags
MKPROMFLAGS - Override mkprom2 flags

REQUIREMENTS
============
 - RCC-1.2.15 or later.
 - At least one SpaceWire AMBA port (GRSPW1, GRSPW2)
 - SPWTDP core
 - GRSPW Router not supported
 - Initiator and Target must have the same hardware configuration
 - see example source file for more requirements
 - Initiator SpW0 connector must be connected to SpW1 connector of Target


FILES
=====

 ../grspw_pkt_lib.*     - GRSPW packet driver helper functions
 spwtdp_example.c       - RTEMS example main application


TYPICAL CONSOLE OUTPUT
======================
 This section lists a typical run with the application using a LEON3-FT AX
 system with two GRSPW2 connected to each other using one SpaceWire cable.

GRMON:

grmon2> load spwtdp_example                             
                                                        
40000000 .text                        0B              [>
40000000 .text                     24.0kB / 197.8kB   [=
40000000 .text                     48.0kB / 197.8kB   [=
40000000 .text                     72.0kB / 197.8kB   [=
40000000 .text                     96.0kB / 197.8kB   [=
40000000 .text                    120.0kB / 197.8kB   [=
40000000 .text                    144.0kB / 197.8kB   [=
40000000 .text                    168.0kB / 197.8kB   [=
40000000 .text                    192.0kB / 197.8kB   [=
40000000 .text                    197.8kB / 197.8kB   [=
                                                        
40031740 .data                        0B              [>
40031740 .data                      4.9kB /   4.9kB   [=
                                                        
40032B00 .jcr                         0B              [>
40032B00 .jcr                         4B              [=
Total size: 202.75kB (1.46Mbit/s)                       
Entry point 0x40000000                                  
Image /home/anandhavel/spacewire_docs/final_update_rtems
                                                        
grmon2> run                                             
 Initializing SpaceWire device 0                        
 After Link Start: 5                                    
 Initializing SpaceWire device 1                        
 After Link Start: 1                                    
 Initializing SpaceWire device 2                        
 After Link Start: 0                                    
                                                        
                                                        
Starting SpW DMA channels                               
Starting GRSPW0: DMA Started Successfully               
Starting GRSPW1: DMA Started Successfully               
Starting GRSPW2: DMA Started Successfully               
using SPWTDP at 0x80100400                              
Started link control task                               
GRSPW0: link state entering run-state                   
Started DMA control task                                
Coarse precision: 32 bits                               
Fine precision:   24 bits                               
Target Coarse precision: 32 bits                        
Target Fine precision:   24 bits                        
successful init                                         
Start latency calculation for 128 samples               
0: R 0x00 0x00 0x00 0x00 0x00 0x00 0xba 0x00 0x00       
1: R 0x00 0x00 0x00 0x00 0x00 0x00 0xba 0x00 0x00       
2: R 0x00 0x00 0x00 0x00 0x00 0x00 0xa9 0x00 0x00       
3: R 0x00 0x00 0x00 0x00 0x00 0x00 0xa9 0x00 0x00       
4: R 0x00 0x00 0x00 0x00 0x00 0x00 0xba 0x00 0x00       
5: R 0x00 0x00 0x00 0x00 0x00 0x00 0xa9 0x00 0x00       
6: R 0x00 0x00 0x00 0x00 0x00 0x00 0xba 0x00 0x00       
7: R 0x00 0x00 0x00 0x00 0x00 0x00 0xa9 0x00 0x00       
8: R 0x00 0x00 0x00 0x00 0x00 0x00 0xba 0x00 0x00       
9: R 0x00 0x00 0x00 0x00 0x00 0x00 0xba 0x00 0x00       
10: R 0x00 0x00 0x00 0x00 0x00 0x00 0xba 0x00 0x00      
11: R 0x00 0x00 0x00 0x00 0x00 0x00 0xa8 0x00 0x00      
12: R 0x00 0x00 0x00 0x00 0x00 0x00 0xb9 0x00 0x00      
13: R 0x00 0x00 0x00 0x00 0x00 0x00 0xa8 0x00 0x00      
14: R 0x00 0x00 0x00 0x00 0x00 0x00 0xb9 0x00 0x00      
15: R 0x00 0x00 0x00 0x00 0x00 0x00 0xb9 0x00 0x00      
16: R 0x00 0x00 0x00 0x00 0x00 0x00 0xb9 0x00 0x00      
17: R 0x00 0x00 0x00 0x00 0x00 0x00 0xa8 0x00 0x00      
18: R 0x00 0x00 0x00 0x00 0x00 0x00 0xa8 0x00 0x00      
19: R 0x00 0x00 0x00 0x00 0x00 0x00 0xa8 0x00 0x00      
20: R 0x00 0x00 0x00 0x00 0x00 0x00 0xb8 0x00 0x00      
21: R 0x00 0x00 0x00 0x00 0x00 0x00 0xb8 0x00 0x00      
22: R 0x00 0x00 0x00 0x00 0x00 0x00 0xb8 0x00 0x00      
23: R 0x00 0x00 0x00 0x00 0x00 0x00 0xa7 0x00 0x00      
24: R 0x00 0x00 0x00 0x00 0x00 0x00 0xc9 0x00 0x00      
25: R 0x00 0x00 0x00 0x00 0x00 0x00 0xb8 0x00 0x00      
26: R 0x00 0x00 0x00 0x00 0x00 0x00 0xb8 0x00 0x00      
27: R 0x00 0x00 0x00 0x00 0x00 0x00 0xb8 0x00 0x00      
28: R 0x00 0x00 0x00 0x00 0x00 0x00 0xb8 0x00 0x00      
29: R 0x00 0x00 0x00 0x00 0x00 0x00 0xa7 0x00 0x00      
30: R 0x00 0x00 0x00 0x00 0x00 0x00 0xb8 0x00 0x00      
31: R 0x00 0x00 0x00 0x00 0x00 0x00 0xb7 0x00 0x00      
32: R 0x00 0x00 0x00 0x00 0x00 0x00 0xb7 0x00 0x00      
33: R 0x00 0x00 0x00 0x00 0x00 0x00 0xb7 0x00 0x00      
34: R 0x00 0x00 0x00 0x00 0x00 0x00 0xb7 0x00 0x00      
35: R 0x00 0x00 0x00 0x00 0x00 0x00 0xb7 0x00 0x00      
36: R 0x00 0x00 0x00 0x00 0x00 0x00 0xb7 0x00 0x00      
37: R 0x00 0x00 0x00 0x00 0x00 0x00 0xb7 0x00 0x00      
38: R 0x00 0x00 0x00 0x00 0x00 0x00 0xa6 0x00 0x00      
39: R 0x00 0x00 0x00 0x00 0x00 0x00 0xb7 0x00 0x00      
40: R 0x00 0x00 0x00 0x00 0x00 0x00 0xa6 0x00 0x00      
41: R 0x00 0x00 0x00 0x00 0x00 0x00 0xb7 0x00 0x00      
42: R 0x00 0x00 0x00 0x00 0x00 0x00 0xb6 0x00 0x00      
43: R 0x00 0x00 0x00 0x00 0x00 0x00 0xb6 0x00 0x00      
44: R 0x00 0x00 0x00 0x00 0x00 0x00 0xb6 0x00 0x00      
45: R 0x00 0x00 0x00 0x00 0x00 0x00 0xb6 0x00 0x00      
46: R 0x00 0x00 0x00 0x00 0x00 0x00 0xa5 0x00 0x00      
47: R 0x00 0x00 0x00 0x00 0x00 0x00 0xb6 0x00 0x00      
48: R 0x00 0x00 0x00 0x00 0x00 0x00 0xb6 0x00 0x00      
49: R 0x00 0x00 0x00 0x00 0x00 0x00 0xb6 0x00 0x00      
50: R 0x00 0x00 0x00 0x00 0x00 0x00 0xa5 0x00 0x00      
51: R 0x00 0x00 0x00 0x00 0x00 0x00 0xa5 0x00 0x00      
52: R 0x00 0x00 0x00 0x00 0x00 0x00 0xb6 0x00 0x00      
53: R 0x00 0x00 0x00 0x00 0x00 0x00 0xb5 0x00 0x00      
54: R 0x00 0x00 0x00 0x00 0x00 0x00 0xb5 0x00 0x00      
55: R 0x00 0x00 0x00 0x00 0x00 0x00 0xb5 0x00 0x00      
56: R 0x00 0x00 0x00 0x00 0x00 0x00 0xa5 0x00 0x00      
57: R 0x00 0x00 0x00 0x00 0x00 0x00 0xc6 0x00 0x00      
58: R 0x00 0x00 0x00 0x00 0x00 0x00 0xb5 0x00 0x00      
59: R 0x00 0x00 0x00 0x00 0x00 0x00 0xb5 0x00 0x00      
60: R 0x00 0x00 0x00 0x00 0x00 0x00 0xb5 0x00 0x00      
61: R 0x00 0x00 0x00 0x00 0x00 0x00 0xa4 0x00 0x00      
62: R 0x00 0x00 0x00 0x00 0x00 0x00 0xa4 0x00 0x00      
63: R 0x00 0x00 0x00 0x00 0x00 0x00 0xc6 0x00 0x00      
64: R 0x00 0x00 0x00 0x00 0x00 0x00 0xc5 0x00 0x00      
65: R 0x00 0x00 0x00 0x00 0x00 0x00 0xb4 0x00 0x00      
66: R 0x00 0x00 0x00 0x00 0x00 0x00 0xb4 0x00 0x00      
67: R 0x00 0x00 0x00 0x00 0x00 0x00 0xa3 0x00 0x00      
68: R 0x00 0x00 0x00 0x00 0x00 0x00 0xc5 0x00 0x00      
69: R 0x00 0x00 0x00 0x00 0x00 0x00 0xc5 0x00 0x00      
70: R 0x00 0x00 0x00 0x00 0x00 0x00 0xc5 0x00 0x00      
71: R 0x00 0x00 0x00 0x00 0x00 0x00 0xc5 0x00 0x00      
72: R 0x00 0x00 0x00 0x00 0x00 0x00 0xd5 0x00 0x00      
73: R 0x00 0x00 0x00 0x00 0x00 0x00 0xb4 0x00 0x00      
74: R 0x00 0x00 0x00 0x00 0x00 0x00 0xb4 0x00 0x00      
75: R 0x00 0x00 0x00 0x00 0x00 0x00 0xb3 0x00 0x00      
76: R 0x00 0x00 0x00 0x00 0x00 0x00 0xb3 0x00 0x00      
77: R 0x00 0x00 0x00 0x00 0x00 0x00 0xc4 0x00 0x00      
78: R 0x00 0x00 0x00 0x00 0x00 0x00 0xb3 0x00 0x00      
79: R 0x00 0x00 0x00 0x00 0x00 0x00 0xc4 0x00 0x00      
80: R 0x00 0x00 0x00 0x00 0x00 0x00 0xb3 0x00 0x00      
81: R 0x00 0x00 0x00 0x00 0x00 0x00 0xb3 0x00 0x00      
82: R 0x00 0x00 0x00 0x00 0x00 0x00 0xb3 0x00 0x00      
83: R 0x00 0x00 0x00 0x00 0x00 0x00 0xb3 0x00 0x00      
84: R 0x00 0x00 0x00 0x00 0x00 0x00 0xa2 0x00 0x00      
85: R 0x00 0x00 0x00 0x00 0x00 0x00 0xc3 0x00 0x00      
86: R 0x00 0x00 0x00 0x00 0x00 0x00 0xb2 0x00 0x00      
87: R 0x00 0x00 0x00 0x00 0x00 0x00 0xc3 0x00 0x00      
88: R 0x00 0x00 0x00 0x00 0x00 0x00 0xb2 0x00 0x00      
89: R 0x00 0x00 0x00 0x00 0x00 0x00 0xa1 0x00 0x00      
90: R 0x00 0x00 0x00 0x00 0x00 0x00 0xb2 0x00 0x00      
91: R 0x00 0x00 0x00 0x00 0x00 0x00 0xb2 0x00 0x00      
92: R 0x00 0x00 0x00 0x00 0x00 0x00 0xb2 0x00 0x00      
93: R 0x00 0x00 0x00 0x00 0x00 0x00 0xc3 0x00 0x00      
94: R 0x00 0x00 0x00 0x00 0x00 0x00 0xb2 0x00 0x00      
95: R 0x00 0x00 0x00 0x00 0x00 0x00 0xc3 0x00 0x00      
96: R 0x00 0x00 0x00 0x00 0x00 0x00 0xb1 0x00 0x00      
97: R 0x00 0x00 0x00 0x00 0x00 0x00 0xa1 0x00 0x00      
98: R 0x00 0x00 0x00 0x00 0x00 0x00 0xb1 0x00 0x00      
99: R 0x00 0x00 0x00 0x00 0x00 0x00 0xb1 0x00 0x00      
100: R 0x00 0x00 0x00 0x00 0x00 0x00 0xa0 0x00 0x00     
101: R 0x00 0x00 0x00 0x00 0x00 0x00 0xc2 0x00 0x00     
102: R 0x00 0x00 0x00 0x00 0x00 0x00 0xb1 0x00 0x00     
103: R 0x00 0x00 0x00 0x00 0x00 0x00 0xc2 0x00 0x00     
104: R 0x00 0x00 0x00 0x00 0x00 0x00 0xc2 0x00 0x00     
105: R 0x00 0x00 0x00 0x00 0x00 0x00 0xc2 0x00 0x00     
106: R 0x00 0x00 0x00 0x00 0x00 0x00 0xb1 0x00 0x00     
107: R 0x00 0x00 0x00 0x00 0x00 0x00 0xb0 0x00 0x00     
108: R 0x00 0x00 0x00 0x00 0x00 0x00 0xb0 0x00 0x00     
109: R 0x00 0x00 0x00 0x00 0x00 0x00 0xc1 0x00 0x00     
110: R 0x00 0x00 0x00 0x00 0x00 0x00 0xc1 0x00 0x00     
111: R 0x00 0x00 0x00 0x00 0x00 0x00 0xc1 0x00 0x00     
112: R 0x00 0x00 0x00 0x00 0x00 0x00 0xb0 0x00 0x00     
113: R 0x00 0x00 0x00 0x00 0x00 0x00 0x9f 0x00 0x00     
114: R 0x00 0x00 0x00 0x00 0x00 0x00 0xb0 0x00 0x00     
115: R 0x00 0x00 0x00 0x00 0x00 0x00 0x9f 0x00 0x00     
116: R 0x00 0x00 0x00 0x00 0x00 0x00 0xb0 0x00 0x00     
117: R 0x00 0x00 0x00 0x00 0x00 0x00 0xc0 0x00 0x00     
118: R 0x00 0x00 0x00 0x00 0x00 0x00 0xc0 0x00 0x00     
119: R 0x00 0x00 0x00 0x00 0x00 0x00 0xc0 0x00 0x00     
120: R 0x00 0x00 0x00 0x00 0x00 0x00 0xc0 0x00 0x00     
121: R 0x00 0x00 0x00 0x00 0x00 0x00 0xaf 0x00 0x00     
122: R 0x00 0x00 0x00 0x00 0x00 0x00 0xaf 0x00 0x00     
123: R 0x00 0x00 0x00 0x00 0x00 0x00 0xaf 0x00 0x00     
124: R 0x00 0x00 0x00 0x00 0x00 0x00 0xaf 0x00 0x00     
125: R 0x00 0x00 0x00 0x00 0x00 0x00 0xbf 0x00 0x00     
126: R 0x00 0x00 0x00 0x00 0x00 0x00 0xbf 0x00 0x00     
127: R 0x00 0x00 0x00 0x00 0x00 0x00 0xbf 0x00 0x00     
TOTAL:      0x00 0x00 0x00 0x00 0x00 0x5a 0x7f 0x00 0x00
MIN SAMPLE: 0x00 0x00 0x00 0x00 0x00 0x00 0x9f 0x00 0x00
MAX SAMPLE: 0x00 0x00 0x00 0x00 0x00 0x00 0xd5 0x00 0x00
AVERAGE FINE TIME LATENCY: 180                          
AVERAGE FINE TIME LATENCY / 2: 90                       
Writing the latency 90 to target registers              
Example successfully completed                          
