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