?? lt8900_receive_main.lst
字號:
255 1 PCA0MD &= ~0x40; //disable watchdog
256 1
257 1 //Port IO Init
258 1 //P0MDOUT = 0x10; //P0.4 are push-pull, others are open-drain
259 1 P0MDOUT = 0x1D; // New added by yfwen Doing Make SCK, MOSI, and NSS push-pull
260 1 PKT_FLAG = 1;
*** ERROR C202 IN LINE 260 OF LT8900_RECEIVE_MAIN.C: 'PKT_FLAG': undefined identifier
261 1 FIFO_FLAG = 1;
*** ERROR C202 IN LINE 261 OF LT8900_RECEIVE_MAIN.C: 'FIFO_FLAG': undefined identifier
262 1 // P0SKIP = 0x00; //P0 skip P0.6 and P0.7
263 1 P1MDOUT = 0x1E; //P1.1~P1.4 is push-pull, P1.0 is open-drain for input
264 1 P1SKIP = 0xE0; //P1.0 ~ P1.4 are used, P1.5 ~ P1.7 skip
265 1 RESET_N = 0; //disable LT8900
*** ERROR C202 IN LINE 265 OF LT8900_RECEIVE_MAIN.C: 'RESET_N': undefined identifier
266 1 P2MDIN &= ~0x20; //P2.5 is analog input
267 1 P2MDOUT = 0x04; //P2.2 is push-pull
268 1 P2SKIP = 0x03; //P2.0 and P2.1 are skip
269 1
270 1 XBR0 = 0x03; // Enable the SPI on the XBAR
271 1 //XBR0 = 0x01; //Enable UART
272 1 XBR1 = 0x40; //Enable Crossbar and weak pull-up
273 1
274 1 //Oscillator Init
275 1 OSCICN = 0x83; //internal HF clock, 12MHz
276 1 LED = 0;
277 1 while ( (OSCICN & 0x40) == 0);
278 1 LED = 1;
279 1 }
280
281 //-----------------------------------------------------------------------------
282 // SPI0_Init
283 //-----------------------------------------------------------------------------
284 //
285 // Return Value : None
286 // Parameters : None
287 //
288 // Configures SPI0 to use 4-wire Single Master mode. The SPI timing is
289 // configured for Mode 0,0 (data centered on first edge of clock phase and
290 // SCK line low in idle state).
291 //
292 //-----------------------------------------------------------------------------
293 void SPI0_Init()
294 {
295 1 SPI0CFG = 0x60; // Enable the SPI as a Master
296 1 // CKPHA = '0', CKPOL = '0'
297 1 SPI0CN = 0x0D; // 4-wire Single Master, SPI enabled
298 1
C51 COMPILER V7.50 LT8900_RECEIVE_MAIN 03/03/2011 16:18:51 PAGE 6
299 1 // SPI clock frequency equation from the datasheet
300 1 SPI0CKR = (SYSCLK/(2*SPI_CLOCK))-1;
301 1
302 1 //ESPI0 = 1; // Enable SPI interrupts
303 1 }
304
305 void UART0_Init (void)
306 {
307 1 // SCON0: 8-bit variable bit rate
308 1 // level of STOP bit is ignored
309 1 // RX enabled
310 1 // ninth bits are zeros
311 1 // clear RI0 and TI0 bits
312 1 SCON0 = 0x10;
313 1 CKCON = 0x08;
314 1 TH1 = 0xCC; //Using sysclk 12MHz and buad rate is 115200
315 1 TL1 = TH1; // Init Timer1
316 1 TMOD &= ~0xf0; // TMOD: timer 1 in 8-bit autoreload
317 1 TMOD |= 0x20;
318 1 TR1 = 1; // START Timer1
319 1 TI0 = 1; // Indicate TX0 ready
320 1 }
321
322 void LT8900_Init(void)
323 {
324 1 RESET_N = 0;
*** ERROR C202 IN LINE 324 OF LT8900_RECEIVE_MAIN.C: 'RESET_N': undefined identifier
325 1 delay_us(1000);
326 1 RESET_N = 1; //Enable 6210
*** ERROR C202 IN LINE 326 OF LT8900_RECEIVE_MAIN.C: 'RESET_N': undefined identifier
327 1 CLK = 0; //set SPI clock to low
*** ERROR C202 IN LINE 327 OF LT8900_RECEIVE_MAIN.C: 'CLK': undefined identifier
328 1 delay_us(50000); //delay 5ms to let LT6210 stable
329 1
330 1 #if 1 //test
331 1 LT_WriteReg(0, 0x6F, 0xE0);
332 1 LT_WriteReg(1, 0x56, 0x81);
333 1
334 1 LT_WriteReg(2, 0x66, 0x17);
335 1 LT_WriteReg(4, 0x9C, 0xC9);
336 1 LT_WriteReg(5, 0x66, 0x37);
337 1 LT_WriteReg(7, 0x00, 0x00);
338 1 LT_WriteReg(8, 0x6C, 0x90);
339 1 LT_WriteReg(9, 0x18, 0x40);
340 1 LT_WriteReg(10, 0x7F, 0xFD);
341 1 LT_WriteReg(11, 0x00, 0x08);
342 1 LT_WriteReg(12, 0x00, 0x00);
343 1 LT_WriteReg(13, 0x48, 0xBD);
344 1
345 1 LT_WriteReg(22, 0x00, 0xff);
346 1 LT_WriteReg(23, 0x80, 0x05);
347 1 LT_WriteReg(24, 0x00, 0x67);
348 1 LT_WriteReg(25, 0x16, 0x59);
349 1 LT_WriteReg(26, 0x19, 0xE0);
350 1 LT_WriteReg(27, 0x12, 0x00);
351 1 LT_WriteReg(28, 0x18, 0x00);
352 1
353 1 LT_WriteReg(32, 0x50, 0x00);
354 1 LT_WriteReg(33, 0x3f, 0xC7);
355 1 LT_WriteReg(34, 0x30, 0x00);
356 1 LT_WriteReg(35, 0x03, 0x20);
357 1 LT_WriteReg(36, 0x03, 0x80);
C51 COMPILER V7.50 LT8900_RECEIVE_MAIN 03/03/2011 16:18:51 PAGE 7
358 1 LT_WriteReg(37, 0x03, 0x80);
359 1 LT_WriteReg(38, 0x5A, 0x5A);
360 1 LT_WriteReg(39, 0x03, 0x80);
361 1 LT_WriteReg(40, 0x44, 0x01);
362 1 LT_WriteReg(41, 0xe0, 0x00);
363 1 LT_WriteReg(42, 0xFD, 0xB0);
364 1 LT_WriteReg(43, 0x00, 0x0F);
365 1 LT_WriteReg(50, 0x00, 0x00);
366 1 #endif
367 1 delay_us(2000); //delay 10ms to let LT6210 for operation
368 1
369 1 }
370 //=======================================================================
371
372 //=======================================================================
373 // SPI Routing
374 //=======================================================================
375
376 void SPI_SendFrame (void)
377 {
378 1 unsigned char j;
379 1
380 1 SS = 0;
*** ERROR C202 IN LINE 380 OF LT8900_RECEIVE_MAIN.C: 'SS': undefined identifier
381 1 for (j=0; j<tlen; j++)
382 1 RBUF[j] = SPI_SendByte(TBUF[j]);
383 1 SS = 1;
*** ERROR C202 IN LINE 383 OF LT8900_RECEIVE_MAIN.C: 'SS': undefined identifier
384 1 }
385
386 void SPI_CleanBuffer (void)
387 {
388 1 register char i;
389 1 for (i = 0; i<BUFLEN; i++) RBUF[i] = 0;
390 1 }
391
392 #if _DEBUG_SPI_
393 unsigned char SPI_SendByte(unsigned char buf)
394 {
395 1 int i = 0;
396 1 unsigned char retVal;
397 1 while (!NSSMD0); // Wait until the SPI is free, in case
398 1 // it's already busy
399 1
400 1 NSSMD0 = 0;
401 1 for(i=0;i<10;i++);
402 1 SPI0DAT = buf;
403 1 for(i=0;i<10;i++);
404 1 retVal = SPI0DAT;
405 1 for(i=0;i<10;i++);
406 1 NSSMD0 = 1;
407 1 }
408 #endif
409 //==========================================================
410 // LT8900 Routing
411 //==========================================================
412 #if 0
void LT_ReadReg(unsigned char reg)
{
int i=0;
SS = 0;
for(i=0;i<10;i++);
C51 COMPILER V7.50 LT8900_RECEIVE_MAIN 03/03/2011 16:18:51 PAGE 8
reg = SPI_SendByte(reg+0x80);
for(i=0;i<10;i++);
RegH = SPI_SendByte(0xFF);
for(i=0;i<10;i++);
RegL = SPI_SendByte(0xFF);
for(i=0;i<10;i++);
SS = 1;
}
#endif
427
428 #if _DEBUG_SPI_
429 void LT_ReadReg(unsigned char reg)
430 {
431 1 int i = 0;
432 1 while (!NSSMD0); // Wait until the SPI is free, in case
433 1 // it's already busy
434 1
435 1 NSSMD0 = 0;
436 1 for(i=0;i<10;i++);
437 1 SPI0DAT = reg+0x80;
438 1 for(i=0;i<10;i++);
439 1 SPI0DAT = 0xFF;
440 1 for(i=0;i<10;i++);
441 1 RegH = SPI0DAT;
442 1 for(i=0;i<10;i++);
443 1 SPI0DAT = 0xFF;
444 1 for(i=0;i<10;i++);
445 1 RegL = SPI0DAT;
446 1 for(i=0;i<10;i++);
447 1 NSSMD0 = 1;
448 1 }
449 #endif
450
451 #if 0
void LT_WriteReg(unsigned char reg, unsigned char H, unsigned char L)
{
int i = 0;
SS = 0;
for(i=0;i<10;i++);
reg = SPI_SendByte(reg);
for(i=0;i<10;i++);
RegH = SPI_SendByte(H);
for(i=0;i<10;i++);
RegL = SPI_SendByte(L);
for(i=0;i<10;i++);
SS = 1;
}
#endif
466
467 #if _DEBUG_SPI_
468 void LT_WriteReg(unsigned char reg, unsigned char H, unsigned char L)
469 {
470 1 int i = 0;
471 1 //SPI_Byte_Write(H);
472 1 while (!NSSMD0); // Wait until the SPI is free, in case
473 1 // it's already busy
474 1 NSSMD0 = 0;
475 1 for(i=0;i<10;i++);
476 1 SPI0DAT = reg;
477 1 for(i=0;i<10;i++);
478 1 SPI0DAT = H;
479 1 for(i=0;i<10;i++);
C51 COMPILER V7.50 LT8900_RECEIVE_MAIN 03/03/2011 16:18:51 PAGE 9
480 1 SPI0DAT = L;
481 1 for(i=0;i<10;i++);
482 1 NSSMD0 = 1;
483 1 }
484 #endif
485
486 void LT_SetSyncWord (void)
487 {
488 1 TBUF[0] = 0x24; //reg36 to reg39
489 1 TBUF[1] = SYNCWORD_0;
*** ERROR C202 IN LINE 489 OF LT8900_RECEIVE_MAIN.C: 'SYNCWORD_0': undefined identifier
490 1 TBUF[2] = SYNCWORD_1;
*** ERROR C202 IN LINE 490 OF LT8900_RECEIVE_MAIN.C: 'SYNCWORD_1': undefined identifier
491 1 TBUF[3] = SYNCWORD_2;
*** ERROR C202 IN LINE 491 OF LT8900_RECEIVE_MAIN.C: 'SYNCWORD_2': undefined identifier
492 1 TBUF[4] = SYNCWORD_3;
*** ERROR C202 IN LINE 492 OF LT8900_RECEIVE_MAIN.C: 'SYNCWORD_3': undefined identifier
493 1 TBUF[5] = SYNCWORD_4;
*** ERROR C202 IN LINE 493 OF LT8900_RECEIVE_MAIN.C: 'SYNCWORD_4': undefined identifier
494 1 TBUF[6] = SYNCWORD_5;
*** ERROR C202 IN LINE 494 OF LT8900_RECEIVE_MAIN.C: 'SYNCWORD_5': undefined identifier
495 1 TBUF[7] = SYNCWORD_6;
*** ERROR C202 IN LINE 495 OF LT8900_RECEIVE_MAIN.C: 'SYNCWORD_6': undefined identifier
496 1 TBUF[8] = SYNCWORD_7;
*** ERROR C202 IN LINE 496 OF LT8900_RECEIVE_MAIN.C: 'SYNCWORD_7': undefined identifier
497 1 tlen = 9;
498 1 SPI_SendFrame();
499 1 }
C51 COMPILATION COMPLETE. 1 WARNING(S), 17 ERROR(S)
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -