• R/O
  • SSH
  • HTTPS

chibios: Commit


Commit MetaInfo

Revisão2915 (tree)
Hora2011-05-03 02:52:13
Autorjunior-q

Mensagem de Log

update test 338fx

Mudança Sumário

Diff

--- branches/fujitsu_dev/boards/DEMO_338FX_GEN/board.h (revision 2914)
+++ branches/fujitsu_dev/boards/DEMO_338FX_GEN/board.h (revision 2915)
@@ -35,9 +35,9 @@
3535 #define CRYSTAL_FREQ 4000000.0 // quarzo da 4M
3636 #define CRYSTAL_SUBFRQ 32768.0 // quarzo subclock da 32768Hz
3737
38-#define SYSTEM_FREQ 56000000.0 // frequenza di sistema con PLL=6x
39-#define CLKP1_FREQ 56000000.0 // frequenza periferal clock CLKP1
40-#define CLKP2_FREQ 14000000.0 // frequenza periferal clock CLKP2 -> usato per CAN & soundgen
38+#define SYSTEM_FREQ 48000000.0 // frequenza di sistema con PLL=6x
39+#define CLKP1_FREQ 16000000.0 // frequenza periferal clock CLKP1
40+#define CLKP2_FREQ 16000000.0 // frequenza periferal clock CLKP2 -> usato per CAN & soundgen
4141
4242
4343 /*
@@ -44,9 +44,10 @@
4444 * Pin definitions for the board.
4545 */
4646
47-#define PinLED_LIFE PDR00_P0
48-#define PinLED_SLOW_PLC PDR00_P1
49-#define PinLED_FAST_PLC PDR00_P2
47+#define PinLED_LIFE PDR09_P3
48+#define PinLED_SLOW_PLC PDR09_P1
49+#define PinLED_FAST_PLC PDR09_P2
50+#define PinLED_WDOG PDR09_P7
5051
5152
5253 /*
--- branches/fujitsu_dev/demos/16FX_MB96F338_FCC907/appboard.c (revision 2914)
+++ branches/fujitsu_dev/demos/16FX_MB96F338_FCC907/appboard.c (revision 2915)
@@ -54,13 +54,13 @@
5454 TMCSR0 = 0x181b; // seleziona clk = clkp1 / 32
5555
5656 irq = 56; /* RLT0 */
57- ICR = (irq << 8) | 0x02; // livello irq = 2
57+// ICR = (irq << 8) | 0x02; // livello irq = 2
5858
5959 TMRLR1 = uSEC_TO_RELTIM1(20000);
6060 TMCSR1 = 0x181b; // seleziona clk = clkp1 / 32
6161
6262 irq = 57; /* RLT1 */
63- ICR = (irq << 8) | 0x02;
63+// ICR = (irq << 8) | 0x02;
6464
6565
6666 /* init reload timer 2 & 3 per treno impulsi stepper
@@ -69,13 +69,13 @@
6969 TMCSR2 = 0x041b; // seleziona clk = clkp1 / 16
7070
7171 irq = 58; /* RLT2 */
72- ICR = (irq << 8) | 0x02; // livello irq = 2
72+// ICR = (irq << 8) | 0x02; // livello irq = 2
7373
7474 TMRLR3 = uSEC_TO_RELTIM3(10000);
7575 TMCSR3 = 0x041b; // seleziona clk = clkp1 / 16
7676
7777 irq = 59; /* RLT3 */
78- ICR = (irq << 8) | 0x02;
78+// ICR = (irq << 8) | 0x02;
7979
8080
8181 /* init reload timer 6 come tick di sistema
@@ -89,10 +89,10 @@
8989 /* init uart1 interrupt levels
9090 */
9191 irq = 96; /* UART1_RX */
92- ICR = (irq << 8) | CH_IRQ_PRIORITY; // livello irq = come richiesto
92+// ICR = (irq << 8) | CH_IRQ_PRIORITY; // livello irq = come richiesto
9393
9494 irq = 97; /* UART1_TX */
95- ICR = (irq << 8) | CH_IRQ_PRIORITY; // livello irq = come richiesto
95+// ICR = (irq << 8) | CH_IRQ_PRIORITY; // livello irq = come richiesto
9696
9797
9898 /*
@@ -128,10 +128,10 @@
128128 P07 -> AD7
129129 */
130130 /* Data register (0000-0000) */
131- PDR00 = 0x00;
131+ PDR00 = 0xFF;
132132
133- /* Direction register (0000-0000) */
134- DDR00 = 0x00;
133+ /* Direction register (1111-1111) */
134+ DDR00 = 0xFF;
135135
136136 /* Input enable register (1111-1111) */
137137 PIER00 = 0xFF;
@@ -150,10 +150,47 @@
150150
151151 /* Pull-up register (0000-0000) */
152152 PUCR00 = 0x00;
153-
154- EBAE0 = 0xFF; // abilita l'uso di P00-P07 come AD00-AD07
153+
154+//EBAE0 = 0xFF; // abilita l'uso di P00-P07 come AD00-AD07
155155
156+ // **************** PORT 9 ***********************
157+ // gpio
158+ /*
159+ P00 -> AD0
160+ P01 -> AD1
161+ P02 -> AD2
162+ P03 -> AD3
163+ P04 -> AD4
164+ P05 -> AD5
165+ P06 -> AD6
166+ P07 -> AD7
167+ */
168+ /* Data register (0000-0000) */
169+ PDR09 = 0xFF;
156170
171+ /* Direction register (1111-1111) */
172+ DDR09 = 0xFF;
173+
174+ /* Input enable register (1111-1111) */
175+ PIER09 = 0xFF;
176+
177+ /* Input level register (0000-0000) */
178+ PILR09 = 0x00;
179+
180+ /* Extended Input level register (1111-1111) tutti in pin a livello TTL */
181+ EPILR09 = 0xFF;
182+
183+ /* Output drive register (0000-0000) -> tutti in normal drive */
184+ PODR09 = 0x00;
185+
186+ /* High drive register (0000-0000) -> tutti in no-high drive */
187+// PHDR00 = 0x00;
188+
189+ /* Pull-up register (0000-0000) */
190+ PUCR09 = 0x00;
191+
192+ return;
193+
157194 // **************** PORT 1 ***********************
158195
159196 // address/data bus
--- branches/fujitsu_dev/demos/16FX_MB96F338_FCC907/main.c (revision 2914)
+++ branches/fujitsu_dev/demos/16FX_MB96F338_FCC907/main.c (revision 2915)
@@ -30,7 +30,6 @@
3030
3131 #include "appboard.h"
3232
33-
3433 /*
3534 * Red LEDs blinker thread, times are in milliseconds.
3635 */
@@ -51,7 +50,9 @@
5150
5251 int delayval;
5352
53+int plcSlowRun;
5454
55+
5556 static msg_t ThreadSlowPLC(void *arg);
5657 static msg_t ThreadFastPLC(void *arg);
5758 static msg_t ThreadWatchdog(void *arg);
@@ -85,18 +86,18 @@
8586 * Activates the serial driver 1 using the driver default configuration.
8687 */
8788
88- sdStart(&SD1, NULL);
89+// sdStart(&SD1, NULL);
8990
9091 /*
9192 * Creates the plc thread.
9293 */
94+
95+// TestThread(&SD1);
96+
9397 chThdCreateStatic(waThreadSlowPLC, sizeof(waThreadSlowPLC), NORMALPRIO+4, ThreadSlowPLC, NULL);
9498 chThdCreateStatic(waThreadFastPLC, sizeof(waThreadFastPLC), NORMALPRIO+10, ThreadFastPLC, NULL);
9599 chThdCreateStatic(waThreadWatchDog, sizeof(waThreadWatchDog), HIGHPRIO, ThreadWatchdog, NULL);
96100
97-
98- TestThread(&SD1);
99-
100101 /*
101102 * Normal main() thread activity, in this demo it does nothing except
102103 * sleeping in a loop.
@@ -103,11 +104,14 @@
103104 */
104105 while (TRUE)
105106 {
106- PinLED_LIFE = 1;
107+// PinLED_LIFE = 1;
107108
109+ PDR00++;
110+
108111 chThdSleepMilliseconds(250);
109112
110- PinLED_LIFE = 0;
113+ PDR00++;
114+// PinLED_LIFE = 0;
111115
112116 chThdSleepMilliseconds(500);
113117 }
@@ -116,16 +120,52 @@
116120 return 0;
117121 }
118122
123+static msg_t ThreadDigInp(void *arg)
124+{
125+int exit = 0;
126+int blinkDelay = 0;
119127
128+}
129+
130+
120131 static msg_t ThreadSlowPLC(void *arg)
121132 {
122133 int exit = 0;
134+int blinkDelay = 0;
123135
124136 while( !exit )
125137 {
126- chThdSleepMilliseconds(50);
127138
128- totCicliSlow++;
139+ if( plcSlowRun == 0x5544 )
140+ {
141+
142+ blinkDelay++;
143+
144+ if( blinkDelay >= 10 )
145+ {
146+ blinkDelay = 0;
147+ PinLED_SLOW_PLC = !PinLED_SLOW_PLC;
148+ }
149+
150+ chThdSleepMilliseconds(50);
151+
152+ totCicliSlow++;
153+
154+ while( totCicliSlow == 200 )
155+ {
156+ blinkDelay++;
157+
158+ if( blinkDelay >= 10000 )
159+ {
160+ blinkDelay = 0;
161+ PinLED_SLOW_PLC = !PinLED_SLOW_PLC;
162+ }
163+ }
164+ }
165+ else
166+ {
167+ chThdSleepMilliseconds(1000);
168+ }
129169 }
130170
131171 return 0;
@@ -135,12 +175,33 @@
135175
136176 static msg_t ThreadFastPLC(void *arg)
137177 {
178+int blinkDelay = 0;
138179
139180 while( TRUE )
140181 {
182+ blinkDelay++;
183+
184+ if( blinkDelay >= 10 )
185+ {
186+ blinkDelay = 0;
187+ PinLED_FAST_PLC = !PinLED_FAST_PLC;
188+ }
189+
141190 chThdSleepMilliseconds(10);
142191
143192 totCicliFast++;
193+
194+ while( totCicliFast == 600 )
195+ {
196+ blinkDelay++;
197+
198+ if( blinkDelay >= 10000 )
199+ {
200+ blinkDelay = 0;
201+ PinLED_FAST_PLC = !PinLED_FAST_PLC;
202+ }
203+ }
204+
144205 }
145206 return 0;
146207 }
@@ -150,11 +211,70 @@
150211 {
151212 long WatchTheDog;
152213
214+long precCicliSlow;
215+long precCicliFast;
216+
217+int statoCheck = 0;
218+int delayWdt;
219+
220+ precCicliSlow = totCicliSlow;
221+ precCicliFast = totCicliFast;
222+
153223 for(;;)
154224 {
225+
226+
227+ switch( statoCheck )
228+ {
229+ case 0:
230+ if( (precCicliSlow == totCicliSlow) ||
231+ (precCicliFast == totCicliFast) )
232+ {
233+ statoCheck++;
234+ }
235+ else
236+ {
237+ precCicliSlow = totCicliSlow;
238+ precCicliFast = totCicliFast;
239+ }
240+ break;
241+
242+ case 1:
243+ if( (precCicliSlow == totCicliSlow) ||
244+ (precCicliFast == totCicliFast) )
245+ {
246+ statoCheck++;
247+ delayWdt = 0;
248+ }
249+ else
250+ {
251+ precCicliSlow = totCicliSlow;
252+ precCicliFast = totCicliFast;
253+ statoCheck = 0;
254+ }
255+ break;
256+
257+ case 2:
258+
259+ delayWdt++;
260+
261+ if( delayWdt >= 20 )
262+ {
263+ totCicliSlow = 1;
264+ totCicliFast = 1;
265+
266+ precCicliSlow = totCicliSlow;
267+ precCicliFast = totCicliFast;
268+
269+ statoCheck = 0;
270+ }
271+ break;
272+ }
273+
155274 /**** Trigger the watchdog every 200 msec ****/
156275 // WDTC_WTE = 0;
157276
277+ PinLED_WDOG = !PinLED_WDOG;
158278 WatchTheDog++;
159279
160280 chThdSleepMilliseconds(200);
Show on old repository browser