📄 t100.lst
字号:
253 {
254 1 uCHAR i;
255 1 if(bNTSC_PAL)//NTSC&&FULL
256 1 {
257 2 I2CWriteTbl(NTSC_FULLData);
258 2 if((!bFULL_43))//NTSC&&4:3
259 2 I2CWriteTbl(NTSC_43Data);
260 2 switch(c60HZ_Mode)
261 2 {
262 3 case 1: I2CWriteTbl(NTSC443Data);
263 3 break;
264 3 case 2: I2CWriteTbl(PAL_60Data);
265 3 break;
266 3 case 3: I2CWriteTbl(PAL_MData);
267 3 break;
268 3 }//*/
269 2
270 2 if(cSource!=5){
271 3 I2CWriteByte(TW100+4,0x03,0x00);
272 3 I2CWriteByte(TW100+4,0x00,0x00);
273 3 }
274 2 else{ I2CWriteByte(TW100+4,0x03,0x03);
275 3 I2CWriteByte(TW100+4,0x00,0x01);
276 3 }
277 2
278 2 }
279 1 else//PAL&&FULL
280 1 {
281 2 I2CWriteTbl(PAL_FULLData);
282 2 if((!bFULL_43))//PAL&&4:3
283 2 I2CWriteTbl(PAL_43Data);
284 2 // for(i=0;i<=1;i++)
285 2 {
286 3 // if(c50HZ_Mode)I2CWriteTbl(PAL_CNData);
287 3 if(cSource!=5){
288 4 I2CWriteByte(TW100+4,0x03,0x02);
289 4 I2CWriteByte(TW100+4,0x00,0x32);
290 4 }
291 3 else{
292 4 I2CWriteByte(TW100+4,0x03,0x03);
293 4 I2CWriteByte(TW100+4,0x00,0x33);
294 4 }
295 3 // Delay_ms(50);
296 3
297 3 // if(cSource!=5)I2CWriteByte(TW100+4,0x00,0x32);//PAL-N 0x36
298 3 //if((I2CReadByte(TW100+4,0x3c)&0x01))i=2;
299 3 //else c50HZ_Mode=!c50HZ_Mode;
300 3 }
301 2 }
C51 COMPILER V7.06 T100 10/30/2005 21:46:44 PAGE 6
302 1 // if(cSource==5)I2CWriteByte(TW100+4,0x0f,0x33);
303 1 }
*** WARNING C280 IN LINE 254 OF C:\WAVE6000\T100_S~1\T100.C: 'i': unreferenced local variable
304 void SetUD_LR(void)
305 {
306 1 uCHAR cTemp;
307 1 if(bUP_DOWN&bLEFT_RIGHT)
308 1 {
309 2 cTemp=UD_LR;
310 2 }
311 1 else if(bUP_DOWN&!bLEFT_RIGHT)
312 1 {
313 2 cTemp=UD_RL;
314 2 }
315 1 else if(!bUP_DOWN&bLEFT_RIGHT)
316 1 {
317 2 cTemp=DU_LR;
318 2 }
319 1 else if(!bUP_DOWN&!bLEFT_RIGHT)
320 1 {
321 2 cTemp=DU_RL;
322 2 }
323 1 I2CWriteByte(TW100,0xe1,cTemp);
324 1 }
325
326 #define Set_SDA_High SDA = 1,SDA = 1
327 #define Set_SDA_Low SDA = 0,SDA = 0
328 #define Set_SCL_High SCL = 1,SCL = 1
329 #define Set_SCL_Low SCL = 0,SCL = 0
330
331 #define SDA_High SDA!=0
332 #define SDA_Low SDA==0
333 #define SCL_High SCL!=0
334 #define SCL_Low SCL==0
335
336 #define TWD_SPEED 0x01 //value: 1 (Fastest), 2 (slower), ... N (much slower)
337 #define TWD_LONG_TIME (TWD_SPEED*8)
338 #define TWD_SHORT_TIME (TWD_SPEED*1)
339 void StartCondition(void)
340 {
341 1 uCHAR ix;
342 1 uCHAR cTWtrytime=0;
343 1 EA=0;
344 1 while(++cTWtrytime)
345 1 {
346 2 Set_SDA_High;
347 2 Set_SCL_High; /* make sure two line is release */
348 2 for(ix = 0; ix < TWD_LONG_TIME; ix++)
349 2 { }; /* Delay 12us */
350 2
351 2 Set_SDA_Low;
352 2 for(ix = 0; ix < TWD_LONG_TIME; ix++)
353 2 { }; /* Delay 12us */
354 2
355 2 if((SCL_High)&&(SDA_Low))
356 2 break;
357 2 }
358 1
359 1 for(ix = 0; ix < TWD_SHORT_TIME; ix++)
360 1 { }; /* Delay 12us */
361 1 }
362
C51 COMPILER V7.06 T100 10/30/2005 21:46:44 PAGE 7
363 //----------------------------------------
364 // P_Condition for TWD protocol
365 //----------------------------------------
366 void StopCondition(void)
367 {
368 1 uCHAR ix;
369 1 uCHAR cTWtrytime=0;
370 1
371 1 Set_SDA_Low;
372 1 Set_SCL_High;
373 1 for(ix = 0; ix < TWD_SHORT_TIME; ix++)
374 1 { }; /* delay 12us */
375 1
376 1 while(SCL_Low && ++cTWtrytime)
377 1 { };
378 1
379 1 for(ix = 0; ix < TWD_SHORT_TIME; ix++)
380 1 { }; /* delay 12us */
381 1
382 1 Set_SDA_High;
383 1 for(ix = 0; ix < TWD_SHORT_TIME; ix++)
384 1 { }; /* delay 12us */
385 1 EA=1;
386 1 }
387
388 //--------------------------------------------------
389 // Send_Byte
390 // Send a byte to master with a acknowledge bit
391 //--------------------------------------------------
392 uCHAR Send_Byte(uCHAR cData)
393 {
394 1 uCHAR ix, j, cAcknowledge;
395 1 uCHAR cTWtrytime=0;
396 1
397 1 cAcknowledge = 0;
398 1
399 1 for(ix = 0; ix < 8; ix++)
400 1 {
401 2 Set_SCL_Low;
402 2 for(j = 0; j < TWD_SHORT_TIME; j++)
403 2 { };
404 2
405 2 if(cData&0x80)Set_SDA_High;
406 2 else Set_SDA_Low;
407 2 cData<<=1;
408 2
409 2 for(j = 0; j < TWD_SHORT_TIME; j++)
410 2 { };
411 2
412 2 Set_SCL_High;
413 2 while(SCL_Low && ++cTWtrytime)
414 2 { };
415 2
416 2 for(j = 0; j < TWD_SHORT_TIME; j++)
417 2 { };
418 2 }
419 1 for(j = 0; j < TWD_SHORT_TIME; j++)
420 1 { };
421 1
422 1 Set_SCL_Low;
423 1 for(j = 0; j < TWD_SHORT_TIME; j++)
424 1 { };
C51 COMPILER V7.06 T100 10/30/2005 21:46:44 PAGE 8
425 1
426 1 Set_SDA_High; /* release data line for acknowledge */
427 1 for(j = 0; j < TWD_SHORT_TIME; j++)
428 1 { };
429 1
430 1 Set_SCL_High; /* Send a clock for Acknowledge */
431 1 while(SCL_Low)
432 1 { };
433 1 for(j = 0; j < TWD_SHORT_TIME; j++)
434 1 { };
435 1
436 1 if(SDA_High) cAcknowledge = 1; /* No Acknowledge */
437 1 Set_SCL_Low; /* Finish Acknoledge */
438 1 for(j = 0; j < TWD_SHORT_TIME; j++)
439 1 { };
440 1
441 1 return(cAcknowledge);
442 1 }
443
444 //--------------------------------------------------
445 // Read_Byte
446 // Read a byte from master with a acknowledge bit
447 //--------------------------------------------------
448 uCHAR Read_Byte(uCHAR cNum)
449 {
450 1 uCHAR ix, j;
451 1 uCHAR cRetval=0;
452 1
453 1 for(ix=0;ix<8;ix++){
454 2 Set_SCL_High;
455 2 while(SCL_Low){};
456 2 for(j=0;j<TWD_SHORT_TIME;j++){};
457 2 cRetval = (SDA_High)? (cRetval|(1<<(7-ix))):cRetval ; /* MSB First */
458 2 Set_SCL_Low;
459 2 }
460 1
461 1 if(cNum==1)
462 1 Set_SDA_High;
463 1 else
464 1 Set_SDA_Low;
465 1 //SDA = (cNum==1) 1:0;
466 1 Set_SCL_High;
467 1 while(SCL_Low){};
468 1 for(j = 0; j < TWD_SHORT_TIME; j++)
469 1 { };
470 1
471 1 Set_SCL_Low;
472 1
473 1 Set_SDA_High;
474 1 for(j = 0; j < TWD_SHORT_TIME; j++)
475 1 { };
476 1
477 1 return cRetval;
478 1 }
479 uCHAR I2CReadByte(uCHAR cAddr, uCHAR cReg)
480 {
481 1 uCHAR cTemp;
482 1
483 1 StartCondition();
484 1 Send_Byte(cAddr);
485 1 Send_Byte(cReg);
486 1 StartCondition();
C51 COMPILER V7.06 T100 10/30/2005 21:46:44 PAGE 9
487 1 Send_Byte(cAddr|0x01);
488 1 cTemp=Read_Byte(1);
489 1 StopCondition();
490 1
491 1 return cTemp;
492 1 }
493 uCHAR I2CWriteByte(uCHAR cAddr,uCHAR cReg,uCHAR cData)
494 {
495 1 StartCondition();
496 1 Send_Byte(cAddr);
497 1 Send_Byte(cReg);
498 1 Send_Byte(cData);
499 1 StopCondition();
500 1 return 0;
501 1 }
502 void I2CWriteTbl(char *pString)
503 {
504 1 uCHAR cAddr,cReg,cNum0,cNum1,cINC;
505 1 while(*pString != EOT)
506 1 {
507 2 cAddr = *pString++;
508 2 cNum0 = *pString++;
509 2 while(cNum0)
510 2 {
511 3 cReg = *pString++;
512 3 cNum1 = *pString++;
513 3 cNum0 -= (cNum1+2);
514 3 if(cNum1!=1)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -