##// END OF EJS Templates
First Init
Alexis Jeandet -
r0:aa6c4da24f03 default draft
parent child
Show More
1 NO CONTENT: new file 100644
@@ -0,0 +1,11
1 #include <LFR.h>
2
3 volatile lfr_regs_t* LFR = (lfr_regs_t*)0x80000f00;
4 volatile lfr_managment_regs_t* LFR_MANAGMENT = (lfr_managment_regs_t*)0x80000600;
5
6 void resetLFR()
7 {
8 LFR_MANAGMENT->Control.Value=7;
9 asm("nop;nop;");
10 LFR_MANAGMENT->Control.Value=0;
11 }
@@ -0,0 +1,12
1 #ifndef LFR_H_INCLUDED
2 #define LFR_H_INCLUDED
3
4 #include <stdint.h>
5 #include <grlib_regs.h>
6
7 extern volatile lfr_regs_t* LFR;
8 extern volatile lfr_managment_regs_t* LFR_MANAGMENT;
9
10 extern void resetLFR();
11
12 #endif // LFR_H_INCLUDED
@@ -0,0 +1,26
1 TEMPLATE = app
2 CONFIG += console
3 CONFIG -= app_bundle
4 CONFIG -= qt
5
6 include(sparc.pri)
7
8 INCLUDEPATH += ./
9
10 OBJECTS_DIR=obj
11 DESTDIR=bin
12
13
14
15 SOURCES += main.c \
16 wfp.c \
17 LFR.c
18
19 HEADERS += grlib_regs.h \
20 wfp.h \
21 LFR.h
22
23 OTHER_FILES += READ_ASM.py
24
25
26
@@ -0,0 +1,242
1 #ifndef GRLIB_REGS_H_INCLUDED
2 #define GRLIB_REGS_H_INCLUDED
3
4 #define NB_GPTIMER 3
5 #include <stdint.h>
6
7 struct apbuart_regs_str{
8 volatile unsigned int data;
9 volatile unsigned int status;
10 volatile unsigned int ctrl;
11 volatile unsigned int scaler;
12 volatile unsigned int fifoDebug;
13 };
14
15 struct grgpio_regs_str{
16 volatile int io_port_data_register;
17 int io_port_output_register;
18 int io_port_direction_register;
19 int interrupt_mak_register;
20 int interrupt_polarity_register;
21 int interrupt_edge_register;
22 int bypass_register;
23 int reserved;
24 // 0x20-0x3c interrupt map register(s)
25 };
26
27 typedef volatile struct {
28 int counter;
29 volatile unsigned int reload;
30 volatile unsigned int ctrl;
31 volatile unsigned int unused;
32 } timer_regs_t;
33
34 typedef volatile struct {
35 volatile unsigned int scaler_value;
36 volatile unsigned int scaler_reload;
37 volatile unsigned int conf;
38 volatile unsigned int unused0;
39 timer_regs_t timer[NB_GPTIMER];
40 } gptimer_regs_t;
41
42
43 typedef struct
44 {
45 uint32_t unused:16;
46 uint32_t Fine:16;
47 uint32_t Coarse;
48 }CUCtime_t;
49
50 struct DualBuffAddr_t
51 {
52 volatile uint32_t ADDR0;
53 volatile uint32_t ADDR1;
54 };
55
56 struct Potential_t
57 {
58 uint32_t UNUSED:16;
59 uint32_t Value:16;
60 };
61
62
63 typedef volatile struct {
64 volatile union CONFIG{
65 volatile struct {
66 uint32_t UNUSED:29; // 0x00
67 uint32_t run:1;
68 uint32_t interuptOnDoneEnable:1;
69 uint32_t interuptOnErrorEnable:1;
70 }FIELDS;
71 uint32_t Value;
72 }CONFIG;
73
74 volatile union STATUS{
75 volatile struct {
76 uint32_t UNUSED:21;
77 uint32_t FIFO_2_Full_err:1;
78 uint32_t FIFO_1_Full_err:1;
79 uint32_t FIFO_0_Full_err:1;
80 uint32_t Buffer_Full_err:1;
81 uint32_t Ready_F2_Buffer1:1;
82 uint32_t Ready_F2_Buffer0:1;
83 uint32_t Ready_F1_Buffer1:1;
84 uint32_t Ready_F1_Buffer0:1;
85 uint32_t Ready_F0_Buffer1:1;
86 uint32_t Ready_F0_Buffer0:1;
87 }FIELDS;
88 uint32_t Value;
89 }STATUS;
90
91 struct DualBuffAddr_t ADDRESS_F0;
92 struct DualBuffAddr_t ADDRESS_F1;
93 struct DualBuffAddr_t ADDRESS_F2;
94
95 CUCtime_t TIME_F0_0;
96 CUCtime_t TIME_F0_1;
97 CUCtime_t TIME_F1_0;
98 CUCtime_t TIME_F1_1;
99 CUCtime_t TIME_F2_0;
100 CUCtime_t TIME_F2_1;
101 volatile struct {
102 uint32_t Unused:6;
103 uint32_t length:26; // 0x50, length of a spectral matrix in burst (25*128) / 16 = 200 = 0xc8
104 }length;
105 } lfr_sm_regs_t;
106
107
108 typedef volatile struct {
109 volatile union DATASHAPING {
110 volatile struct {
111 uint32_t UNUSED:26; // 0x00
112 uint32_t R2:1;
113 uint32_t R1:1;
114 uint32_t R0:1;
115 uint32_t SP1:1;
116 uint32_t SP0:1;
117 uint32_t BW:1;
118 }FIELDS;
119 uint32_t Value;
120 }DATASHAPING;
121
122 volatile union {
123 volatile struct {
124 uint32_t UNUSED:25;
125 uint32_t BURST_EN_F2:1;
126 uint32_t BURST_EN_F1:1;
127 uint32_t BURST_EN_F0:1;
128 uint32_t ACQ_EN_F3:1;
129 uint32_t ACQ_EN_F2:1;
130 uint32_t ACQ_EN_F1:1;
131 uint32_t ACQ_EN_F0:1;
132 }FIELDS;
133 uint32_t Value;
134 }Control;
135
136 volatile struct DualBuffAddr_t ADDRESS_F0;
137 volatile struct DualBuffAddr_t ADDRESS_F1;
138 volatile struct DualBuffAddr_t ADDRESS_F2;
139 volatile struct DualBuffAddr_t ADDRESS_F3;
140
141 uint32_t STATUS;
142 uint32_t DeltaSnapshot;
143 uint32_t Delta_F0;
144
145 uint32_t UNUSED_Delta_F0_2:25;
146 uint32_t Delta_F0_2:7;
147 uint32_t Delta_F1;
148 uint32_t Delta_F2;
149
150 uint32_t Nb_Data_per_buff;
151 uint32_t Nb_snapshot;
152
153 uint32_t StartDate;
154
155 CUCtime_t TIME_F0_0;
156 CUCtime_t TIME_F0_1;
157 CUCtime_t TIME_F1_0;
158 CUCtime_t TIME_F1_1;
159 CUCtime_t TIME_F2_0;
160 CUCtime_t TIME_F2_1;
161 CUCtime_t TIME_F3_0;
162 CUCtime_t TIME_F3_1;
163
164 union{
165 struct {
166 uint32_t Unused_length:6;
167 uint32_t length:26;
168 }FIELDS; // 0x50, length of a spectral matrix in burst (25*128) / 16 = 200 = 0xc8
169 uint32_t Value;
170 }length;
171 struct Potential_t V;
172 struct Potential_t E1;
173 struct Potential_t E2;
174 } lfr_wfp_regs_t;
175
176 typedef struct {
177 uint32_t UNUSED:16;
178 uint32_t Value:16;
179 }lfr_hk_temp_t;
180
181 typedef struct {
182 struct {
183 uint32_t UNUSED:25;
184 uint32_t CAL_EN:1;
185 uint32_t Interleaved_EN:1;
186 uint32_t Reload_EN:1;
187 uint32_t DAC_CFG:4;
188 }Control;
189
190 uint32_t UNUSED_PRE:24;
191 uint32_t PRE:8;
192
193 uint32_t UNUSED_N:16;
194 uint32_t N:16;
195
196 uint32_t UNUSED_ADDR:24;
197 uint32_t ADDRESS:8;
198
199 uint32_t UNUSED_DATA_IN:14;
200 uint32_t DATA_IN:18;
201
202 }lfr_dac_regs_t;
203
204 typedef volatile struct {
205 union {
206 struct {
207 uint32_t UNUSED:29;
208 uint32_t SOFT_RESET:1;
209 uint32_t TIME_MANAGMENT_RESET:1;
210 uint32_t SWTick:1;}FIELDS;
211 uint32_t Value;
212 }Control;
213
214 uint32_t UNUSED_TIME_LOAD:1;
215 uint32_t TIME_LOAD:31;
216
217 uint32_t Unsynchronized:1;
218 uint32_t COARSE_TIME:31;
219
220 uint32_t UNUSED_FINE_TIME:16;
221 uint32_t FINE_TIME:16;
222
223 lfr_hk_temp_t TEMP_0;
224 lfr_hk_temp_t TEMP_1;
225 lfr_hk_temp_t TEMP_2;
226
227 lfr_dac_regs_t DAC;
228
229 }lfr_managment_regs_t;
230
231 typedef volatile struct {
232 lfr_sm_regs_t SM;
233 lfr_wfp_regs_t WFP;
234 struct {
235 uint32_t UNUSED:8;
236 uint32_t Board:8;
237 uint32_t Major:8;
238 uint32_t Minor:8;
239 }VERSION;
240 }lfr_regs_t;
241
242 #endif // GRLIB_REGS_H_INCLUDED
@@ -0,0 +1,48
1 #include <stdio.h>
2 #include <grlib_regs.h>
3 #include <stdint.h>
4 #include <LFR.h>
5 #include <wfp.h>
6
7 #define MS_Size_Int (128 * 25 * 4 / sizeof(int))
8
9 #define BUF_SZ 2688
10
11 uint16_t WF1[6 * BUF_SZ] __attribute__((aligned(0x100)));
12 uint16_t WF2[6 * BUF_SZ] __attribute__((aligned(0x100)));
13
14 volatile int todo = 0;
15 volatile int Freq = 0;
16 volatile int PerformReset = 1;
17 volatile int Major;
18 volatile int Minor;
19 volatile int Board;
20
21 int main(void) {
22 Major = LFR->VERSION.Major;
23 Minor = LFR->VERSION.Minor;
24 Board = LFR->VERSION.Board;
25 while (1)
26 {
27 do{
28 if(PerformReset)
29 resetLFR();
30 switch (Freq)
31 {
32 case 0:
33 getSnapShotsF0((uint32_t)WF1,(uint32_t)WF2,BUF_SZ,0);
34 break;
35 case 1:
36 getSnapShotsF1((uint32_t)WF1,(uint32_t)WF2,BUF_SZ,0);
37 break;
38 case 2:
39 getSnapShotsF2((uint32_t)WF1,(uint32_t)WF2,BUF_SZ,0);
40 break;
41 default:
42 break;
43 }
44 todo--;
45 }while (todo!=0);
46 }
47 return 0;
48 }
@@ -0,0 +1,72
1
2 QMAKE_CC=sparc-elf-gcc
3 message(C compiler forced to: $$QMAKE_CC)
4 QMAKE_CXX=sparc-elf-g++
5 message(C++ compiler forced to: $$QMAKE_CXX)
6 QMAKE_AR=sparc-elf-ar rcs
7 message(Archiver forced to: $$QMAKE_AR)
8 QMAKE_LINK=sparc-elf-gcc
9 message(Linker forced to: $$QMAKE_LINK)
10 QMAKE_LINK_SHLIB=sparc-elf-g++
11 QMAKE_OBJCOPY= sparc-elf-objcopy
12 QMAKE_STRIP=sparc-elf-strip
13 QMAKE_GDB=sparc-elf-gdb
14
15 QMAKE_CFLAGS_APP=""
16 QMAKE_CXXFLAGS_APP=""
17 QMAKE_CFLAGS=-mcpu=v8
18 QMAKE_CFLAGS_DEBUG= -g
19 QMAKE_CFLAGS_RELEASE=""
20 QMAKE_CXXFLAGS_DEBUG= -g
21 QMAKE_CXXFLAGS_RELEASE=""
22 QMAKE_LFLAGS_RELEASE=-mcpu=v8
23 QMAKE_LFLAGS_DEBUG= -g -mcpu=v8
24 QMAKE_CXXFLAGS_DEPS =
25 QMAKE_CXXFLAGS_WARN_ON = -Wall
26 QMAKE_CXXFLAGS_WARN_OFF = -w
27 QMAKE_CXXFLAGS_RELEASE =
28 QMAKE_CXXFLAGS_DEBUG =
29 QMAKE_CXXFLAGS_YACC =
30 QMAKE_CXXFLAGS_THREAD =
31 QMAKE_CXXFLAGS_RTTI_ON =
32 QMAKE_CXXFLAGS_RTTI_OFF =
33 QMAKE_CXXFLAGS_EXCEPTIONS_ON =
34 QMAKE_CXXFLAGS_EXCEPTIONS_OFF =
35 QMAKE_CFLAGS_WARN_ON = -Wall
36 QMAKE_CFLAGS_WARN_OFF = -w
37 QMAKE_CFLAGS_RELEASE =
38 QMAKE_CFLAGS_YACC =
39 QMAKE_LFLAGS_EXCEPTIONS_ON =
40 QMAKE_LFLAGS_EXCEPTIONS_OFF =
41 QMAKE_LFLAGS_CONSOLE =
42 QMAKE_LFLAGS_WINDOWS =
43 QMAKE_LFLAGS_DLL =
44 QMAKE_INCDIR_QT =
45 QMAKE_INCDIR =
46 QMAKE_CFLAGS_SHLIB =
47 QMAKE_CFLAGS_STATIC_LIB =
48 QMAKE_CXXFLAGS_SHLIB =
49 QMAKE_CXXFLAGS_STATIC_LIB =
50 QMAKE_LIBS=""
51 INCLUDEPATH=""
52 DEFINES=""
53
54
55 QMAKE_CFLAGS_RELEASE += -O3
56 QMAKE_CFLAGS_DEBUG += -O3
57 QMAKE_CXXFLAGS_RELEASE += -O3
58 QMAKE_CXXFLAGS_DEBUG += -O3
59
60 #QMAKE_CFLAGS_RELEASE += -O0
61 #QMAKE_CFLAGS_DEBUG += -O0
62 #QMAKE_CXXFLAGS_RELEASE += -O0
63 #QMAKE_CXXFLAGS_DEBUG += -O0
64
65
66 #QMAKE_CFLAGS_RELEASE+= -O3 -std=c99
67 #QMAKE_CFLAGS_DEBUG+= -O3 -std=c99
68 #QMAKE_CXXFLAGS_RELEASE+= -O3 -std=c99
69 #QMAKE_CXXFLAGS_DEBUG+= -O3 -std=c99
70
71
72
@@ -0,0 +1,44
1 #include <wfp.h>
2
3
4 void getSnapShotsF0(uint32_t buffer0, uint32_t buffer1,unsigned int NB_Samples, int freq)
5 {
6 LFR->WFP.Control.Value=0;
7 volatile int test = LFR->WFP.STATUS;
8 LFR->WFP.ADDRESS_F0.ADDR0 = buffer0;
9 LFR->WFP.ADDRESS_F0.ADDR1 = buffer1;
10 LFR->WFP.length.FIELDS.length=(NB_Samples*3)/16;
11 LFR->WFP.Nb_Data_per_buff= NB_Samples-1;
12 LFR->WFP.Nb_snapshot=NB_Samples;
13 LFR->WFP.StartDate=(uint32_t)LFR_MANAGMENT->COARSE_TIME + 1;
14 LFR->WFP.Control.Value = 0x11;
15 while ((LFR->WFP.STATUS&7)==0) ;
16 }
17
18 void getSnapShotsF1(uint32_t buffer0, uint32_t buffer1, unsigned int NB_Samples, int freq)
19 {
20 LFR->WFP.Control.Value=0;
21 volatile int test = LFR->WFP.STATUS;
22 LFR->WFP.ADDRESS_F1.ADDR0 = buffer0;
23 LFR->WFP.ADDRESS_F1.ADDR1 = buffer1;
24 LFR->WFP.length.FIELDS.length=(NB_Samples*3)/16;
25 LFR->WFP.Nb_Data_per_buff= NB_Samples-1;
26 LFR->WFP.Nb_snapshot=NB_Samples;
27 LFR->WFP.StartDate=(uint32_t)LFR_MANAGMENT->COARSE_TIME + 1;
28 LFR->WFP.Control.Value = 0x22;
29 while ((LFR->WFP.STATUS&7)==0) ;
30 }
31
32 void getSnapShotsF2(uint32_t buffer0, uint32_t buffer1, unsigned int NB_Samples, int freq)
33 {
34 LFR->WFP.Control.Value=0;
35 volatile int test = LFR->WFP.STATUS;
36 LFR->WFP.ADDRESS_F2.ADDR0 = buffer0;
37 LFR->WFP.ADDRESS_F2.ADDR1 = buffer1;
38 LFR->WFP.length.FIELDS.length=(NB_Samples*3)/16;
39 LFR->WFP.Nb_Data_per_buff= NB_Samples-1;
40 LFR->WFP.Nb_snapshot=NB_Samples;
41 LFR->WFP.StartDate=(uint32_t)LFR_MANAGMENT->COARSE_TIME + 1;
42 LFR->WFP.Control.Value = 0x44;
43 while ((LFR->WFP.STATUS&7)==0) ;
44 }
@@ -0,0 +1,12
1 #ifndef WFP_H_INCLUDED
2 #define WFP_H_INCLUDED
3
4 #include <stdint.h>
5 #include <grlib_regs.h>
6 #include <LFR.h>
7
8 extern void getSnapShotsF0(uint32_t buffer0, uint32_t buffer1, unsigned int NB_Samples, int freq);
9 extern void getSnapShotsF1(uint32_t buffer0, uint32_t buffer1, unsigned int NB_Samples, int freq);
10 extern void getSnapShotsF2(uint32_t buffer0, uint32_t buffer1, unsigned int NB_Samples, int freq);
11
12 #endif // WFP_H_INCLUDED
@@ -0,0 +1,153
1 .file "wfp.c"
2 .section ".text"
3 .align 4
4 .global setAddr
5 .type setAddr, #function
6 .proc 020
7 setAddr:
8 srl %o0, 24, %g2
9 sethi %hi(-2147480576), %g1
10 or %g1, 768, %g1
11 ldub [%g1+92], %g3
12 srl %o0, 16, %g3
13 stb %g2, [%g1+92]
14 and %g3, 255, %g3
15 srl %o0, 8, %g2
16 ldub [%g1+93], %g4
17 and %g2, 255, %g2
18 stb %g3, [%g1+93]
19 and %o0, 255, %o0
20 ldub [%g1+94], %g3
21 stb %g2, [%g1+94]
22 ldub [%g1+95], %g2
23 stb %o0, [%g1+95]
24 jmp %o7+8
25 nop
26 .size setAddr, .-setAddr
27 .align 4
28 .global getSnapShots
29 .type getSnapShots, #function
30 .proc 020
31 getSnapShots:
32 save %sp, -104, %sp
33 sethi %hi(-2147480576), %g1
34 or %g1, 768, %g1
35 ldub [%g1+88], %g2
36 stb %g0, [%g1+88]
37 ldub [%g1+89], %g2
38 stb %g0, [%g1+89]
39 sll %i2, 1, %g2
40 add %g2, %i2, %g2
41 ldub [%g1+90], %g3
42 stb %g0, [%g1+90]
43 sll %g2, 2, %g2
44 srl %g2, 6, %g2
45 ldub [%g1+91], %g3
46 stb %g0, [%g1+91]
47 srl %g2, 24, %o4
48 srl %g2, 16, %g4
49 ldub [%g1+124], %o2
50 ldub [%g1+125], %o3
51 ldub [%g1+126], %g3
52 ldub [%g1+127], %o5
53 sll %o2, 24, %o2
54 sll %o3, 16, %o3
55 sll %g3, 8, %g3
56 or %o3, %o2, %o3
57 or %g3, %o3, %g3
58 or %o5, %g3, %g3
59 st %g3, [%fp-4]
60 srl %g2, 8, %o7
61 and %g4, 255, %g4
62 ldub [%g1+92], %g3
63 mov 64, %g3
64 and %o7, 255, %o7
65 stb %g3, [%g1+92]
66 and %g2, 255, %g3
67 ldub [%g1+93], %g2
68 stb %g0, [%g1+93]
69 add %i2, -1, %g2
70 srl %g2, 24, %o0
71 ldub [%g1+94], %o5
72 mov 87, %o5
73 srl %g2, 16, %o1
74 and %g2, 255, %o3
75 stb %o5, [%g1+94]
76 srl %g2, 8, %g2
77 and %g2, 255, %o2
78 ldub [%g1+95], %o5
79 stb %g0, [%g1+95]
80 and %o1, 255, %o1
81 ldub [%g1+224], %o5
82 and %o5, -4, %o5
83 or %o5, %o4, %o5
84 srl %i2, 24, %o4
85 stb %o5, [%g1+224]
86 srl %i2, 16, %o5
87 and %o5, 255, %o5
88 ldub [%g1+225], %g2
89 stb %g4, [%g1+225]
90 srl %i2, 8, %g4
91 and %g4, 255, %g4
92 ldub [%g1+226], %g2
93 stb %o7, [%g1+226]
94 and %i2, 255, %i2
95 ldub [%g1+227], %g2
96 stb %g3, [%g1+227]
97 sethi %hi(-2147482624), %g3
98 or %g3, 512, %g3
99 ldub [%g1+148], %g2
100 stb %o0, [%g1+148]
101 ldub [%g1+149], %g2
102 stb %o1, [%g1+149]
103 ldub [%g1+150], %g2
104 stb %o2, [%g1+150]
105 ldub [%g1+151], %g2
106 stb %o3, [%g1+151]
107 ldub [%g1+152], %g2
108 stb %o4, [%g1+152]
109 ldub [%g1+153], %g2
110 stb %o5, [%g1+153]
111 ldub [%g1+154], %g2
112 stb %g4, [%g1+154]
113 ldub [%g1+155], %g2
114 stb %i2, [%g1+155]
115 ldub [%g3+8], %g4
116 ldub [%g3+9], %o5
117 ldub [%g3+10], %g2
118 ldub [%g3+11], %g3
119 sll %o5, 16, %o5
120 and %g4, 127, %g4
121 sll %g2, 8, %g2
122 sll %g4, 24, %g4
123 or %o5, %g4, %g4
124 or %g2, %g4, %g2
125 or %g3, %g2, %g2
126 add %g2, 3, %g2
127 srl %g2, 24, %g3
128 ldub [%g1+156], %g4
129 srl %g2, 16, %g4
130 stb %g3, [%g1+156]
131 and %g4, 255, %g4
132 srl %g2, 8, %g3
133 ldub [%g1+157], %o5
134 and %g3, 255, %g3
135 stb %g4, [%g1+157]
136 and %g2, 255, %g2
137 ldub [%g1+158], %g4
138 stb %g3, [%g1+158]
139 ldub [%g1+159], %g3
140 stb %g2, [%g1+159]
141 ldub [%g1+88], %g2
142 stb %g0, [%g1+88]
143 ldub [%g1+89], %g2
144 stb %g0, [%g1+89]
145 ldub [%g1+90], %g2
146 stb %g0, [%g1+90]
147 ldub [%g1+91], %g2
148 mov 17, %g2
149 stb %g2, [%g1+91]
150 jmp %i7+8
151 restore
152 .size getSnapShots, .-getSnapShots
153 .ident "GCC: (BCC 4.4.2 release 1.0.45) 4.4.2"
General Comments 0
You need to be logged in to leave comments. Login now