Revision 234

View differences:

branch/diagne/Emb_App/SessionM32C_FoUSB_UART.hsf
1 1
[HIMDBVersion]
2 2
2.0
3 3
[DATABASE_VERSION]
4
"2.2" 
4
"2.3" 
5 5
[SESSION_DETAILS]
6 6
"" 
7 7
[INFORMATION]
......
226 226
[WINDOW_POSITION_STATE_DATA_VD3]
227 227
[WINDOW_POSITION_STATE_DATA_VD4]
228 228
[WINDOW_Z_ORDER]
229
[TARGET_NAME]
230
"M32C FoUSB/UART" "" 0 
229 231
[STATUSBAR_STATEINFO_VD1]
230 232
"MasterShowState" 1 
231 233
"ApplicationShowState" 1 
......
246 248
[STATUSBAR_DEBUGGER_PANESTATE_VD2]
247 249
[STATUSBAR_DEBUGGER_PANESTATE_VD3]
248 250
[STATUSBAR_DEBUGGER_PANESTATE_VD4]
249
[TARGET_NAME]
250
"M32C FoUSB/UART" 
251 251
[DEBUGGER_OPTIONS]
252 252
"Unknown Options" 
253 253
[DOWNLOAD_MODULES]
......
264 264
"FALSE" 
265 265
[DISABLE_MEMORY_ACCESS_DURING_EXECUTION]
266 266
"FALSE" 
267
[DEBUGGER_OPTIONS_PROPERTIES]
268
"0" 
267 269
[COMMAND_FILES]
268 270
[DEFAULT_DEBUG_FORMAT]
269 271
"IEEE695_RENESAS" 
branch/diagne/Emb_App/SessionM32C_Simulator.hsf
1 1
[HIMDBVersion]
2 2
2.0
3 3
[DATABASE_VERSION]
4
"2.2" 
4
"2.3" 
5 5
[SESSION_DETAILS]
6 6
"" 
7 7
[INFORMATION]
......
34 34
[WINDOW_POSITION_STATE_DATA_VD3]
35 35
[WINDOW_POSITION_STATE_DATA_VD4]
36 36
[WINDOW_Z_ORDER]
37
[TARGET_NAME]
38
"" "" 0 
37 39
[STATUSBAR_STATEINFO_VD1]
38 40
"MasterShowState" 1 
39 41
"ApplicationShowState" 1 
......
54 56
[STATUSBAR_DEBUGGER_PANESTATE_VD2]
55 57
[STATUSBAR_DEBUGGER_PANESTATE_VD3]
56 58
[STATUSBAR_DEBUGGER_PANESTATE_VD4]
57
[TARGET_NAME]
58
"" 
59 59
[DEBUGGER_OPTIONS]
60 60
"" 
61 61
[DOWNLOAD_MODULES]
......
71 71
"FALSE" 
72 72
[DISABLE_MEMORY_ACCESS_DURING_EXECUTION]
73 73
"FALSE" 
74
[DEBUGGER_OPTIONS_PROPERTIES]
75
"0" 
74 76
[COMMAND_FILES]
75 77
[DEFAULT_DEBUG_FORMAT]
76 78
"" 
branch/diagne/Emb_App/programme_principal_etud.c
123 123

  
124 124
short alpha;
125 125
short vitesse, longueur;
126
short pos;
126

  
127 127
void Asserv0(){	
128 128
	
129
		CanFrame req, comm;
130
		UINT flag;
131
		while (1)
132
		{
133
			req.data.id='R';
134
			req.data.rtr=1; 
135
			//requ?te de lecture
136
			periph[ADDR('R')].ev=0x01;
137
			snd_dtq(CanTx, req.msg);
129
		CanFrame req,reponse,comm;
130
		UINT flag;	
131
		while(1)
132
		{	
133
			req.data.id='R'; //lecture angle de la tourelle
134
			req.data.rtr=1; //requ?te de lecture
135
			snd_dtq(CanRx, req.msg);
138 136
			//Attente de la r?ponse
139
			wai_flg (ev_periph, 0x01, TWF_ANDW, &flag);
140
			pos=periph[ADDR('R')].val;
141
			//Lecture de la valeur
142
	
143
	 		//CanFrame demande;
144
	   		 //CanFrame reponse;
145
	 		//CanFrame comm;
137
			//rcv_dtq(CanRx, &reponse.msg);
138
			periph[ADDR('R')].ev=0x01;
139
			snd_dtq(CanTx,req.msg);
140
			wai_flg(ev_periph, 0x01, TWF_ANDW,&flag);
141
			alpha=periph[ADDR('R')].val;
142
			
143
			//Vitesse de la tourelle
146 144
			comm.data.id='T'; 
147 145
			comm.data.rtr=0;
148
	 		comm.data.val=450-pos; // Pour un gain de 1, on regule pour avoir 45degr?s
149
			snd_dtq (CanTx,comm.msg);
150
		}
151
	
146
	 		comm.data.val=450-alpha; // Pour un gain de 1, on regule pour avoir 45degr?s
147
			snd_dtq(CanTx,comm.msg);
148
			dly_tsk(100);
149
		}	
150
		
152 151
}
153 152

  
154
void distance(){
155
	CanFrame req;
156
	UINT flag;
157
	req.data.id='U';
158
	req.data.rtr=1;
159
	periph[ADDR('U')].ev=0x01;
160
	snd_dtq(CanTx, req.msg);
161
	//Attente de la r?ponse
162
	wai_flg (ev_periph, 0x01, TWF_ANDW, &flag);
163
	longueur=periph[ADDR('U')].val;
164
	
165 153

  
166
}
167

  
168

  
169 154
void regulation_roue(){
170
 CanFrame req;
171
	while(1){
172
		UINT flag;
173
		req.data.id='D';
174
		req.data.rtr=0;
175
		req.data.val=2*(longueur-737);
176
		snd_dtq(CanTx, req.msg);
177
		
178
	}
155
		CanFrame req,reponse,comm;
156
		UINT flag;	
157
		while(1)
158
		{	
159
			req.data.id='U'; //lecture angle de la tourelle
160
			req.data.rtr=1; //requ?te de lecture
161
			snd_dtq(CanRx, req.msg);
162
			//Attente de la r?ponse
163
			//rcv_dtq(CanRx, &reponse.msg);
164
			periph[ADDR('U')].ev=0x01;
165
			snd_dtq(CanTx,req.msg);
166
			wai_flg(ev_periph, 0x01, TWF_ANDW,&flag);
167
			alpha=periph[ADDR('U')].val;
168
			
169
			//Vitesse de la tourelle
170
			comm.data.id='D'; 
171
			comm.data.rtr=0;
172
	 		comm.data.val=-(450-alpha); // Pour un gain de 1, on regule pour avoir 45degr?s
173
			snd_dtq(CanTx,comm.msg);
174
			dly_tsk(100);
175
		}
179 176
}
180

  
177
	
181 178
void Avancer(){
182
	CanFrame requete;
179
	CanFrame req;
180
	dly_tsk(6000);
181
	req.data.id='V';
182
	req.data.rtr=0;
183
	req.data.val=15;
184
	snd_dtq(CanTx,req.msg);
183 185
	
184
	dly_tsk(5000);
185
	//test avec vitesse
186
  requete.data.id='V';
187
    requete.data.rtr=0; 
188
    requete.data.val=48;
189
    snd_dtq(CanTx, requete.msg);
190

  
191 186
}
187

  
192 188
	
193 189
void main()
194 190
{
195
	CanFrame requete,reponse,comm;
191
	CanFrame req,reponse,comm;
196 192
	ports_mcu();
197 193
    lcd_init();
198 194
	periph_init();
......
203 199
    clavier_init(1);
204 200
	capture_init(); 
205 201
	
202
	
203
	
206 204
	//Variables globales utlis?es par les asservissements
207 205
	
208 206
	
209 207
	sta_cyc(ID_acqui);
210
	sta_tsk(ID_periph_rx);
208
  	sta_tsk(ID_periph_rx);
211 209
	sta_tsk(ID_Asserv0);
212
	distance;
213
	regulation_roue;
214
	distance();
215
	Avancer();
210
 	sta_tsk(ID_Avancer);
211
	sta_tsk(ID_roue);
212

  
216 213
	
217 214
    while(1)
218 215
    {
......
221 218
		dly_tsk(100);
222 219
		LED_J=0;
223 220
		dly_tsk(100);
224
		
221
	    }
225 222
	
226
    }
227
	
228 223
}
229 224

  
230 225
void acqui()
branch/diagne/Emb_App/conf_noyau.cfg
67 67
	name	= ID_Asserv0;
68 68
	stack_size	= 256;
69 69
	stack_section	= stack;
70
	priority	= 9;
70
	priority	= 5;
71 71
	initial_start	= OFF;
72 72
	exinf	= 0x0;
73 73
};
74
task[]{
75
	entry_address	= Avancer();
76
	name	= ID_Avancer;
77
	stack_size	= 256;
78
	stack_section	= stack;
79
	priority	= 7;
80
	initial_start	= OFF;
81
	exinf	= 0x0;
82
};
74 83

  
84
task[]{
85
	entry_address	= regulation_roue();
86
	name	= ID_roue;
87
	stack_size	= 256;
88
	stack_section	= stack;
89
	priority	= 7;
90
	initial_start	= OFF;
91
	exinf	= 0x0;
92
};
93

  
94

  
75 95
flag[]{
76 96
	name	= ev_bus_fin_tr;
77 97
	initial_pattern	= 0x0000;

Also available in: Unified diff