LCDView.c
上传用户:xhjmsc
上传日期:2019-09-13
资源大小:389k
文件大小:5k
源码类别:

传真(Fax)编程

开发平台:

C/C++

  1. //LCD View
  2. //new  Apr. 06, 2007
  3. //Author bryan
  4. #include "includeH.h"
  5. void ViewCommunicationTX(unsigned char ViewTimeControlWord)
  6. {
  7.      unsigned char ucGeneralCnt = 0;
  8.      /*
  9.       unsigned char ucYear=0xa1;
  10.      unsigned char ucMonth=0xa2;
  11.      unsigned char ucDate=0xa3;
  12.       unsigned char ucHour=0xa4;
  13.       unsigned char ucMinute=0xa5;
  14.       unsigned char ucSecond=0xa6;
  15.       unsigned char ucRingNum=0xa7;
  16.       unsigned char ucIcon0=0xa8;
  17.       unsigned char ucIcon1=0xa9;
  18.       unsigned char ucIcon2=0xa0;
  19.      */
  20.       __disable_interrupt();
  21.   VIEW_PORT_OUT &= ~bitVIEWCLK;
  22.   while ((VIEW_PORT_IN & bitVIEWDATASI) == bitVIEWDATASI)//wait Low
  23.      {  
  24.       if (gwTimeOverflowCount++ == 0xffff)
  25.             gucTimeOverflowCount++;
  26.         if (gucTimeOverflowCount == 10)
  27.             {gucGeneralStatus &= ~bitSendFaxSignalOK;gucTimeOverflowCount=0;gwTimeOverflowCount=0;break;}
  28.      } 
  29.   if ((VIEW_PORT_IN & bitVIEWDATASI) != bitVIEWDATASI)
  30.    {
  31.       SendOneViewData(ViewTimeControlWord);//00 10Bytes is effect
  32.                                            //01 4Bytes is effect RingNum Icon2-1
  33.       
  34.        /*
  35.        SendOneViewData(gucHour);
  36.        SendOneViewData(gucMinute);
  37.        SendOneViewData(gucSecond);
  38.        SendOneViewData(gucMonth);
  39.        SendOneViewData(gucDate);
  40.        SendOneViewData(gucYear);
  41.        SendOneViewData(gucViewRingNum);
  42.        SendOneViewData(gucViewStaticStatus);
  43.        SendOneViewData(gucViewDynamicStatus);
  44.        SendOneViewData(gucIcon2);
  45.        */
  46.        for (ucGeneralCnt=0; ucGeneralCnt<10; ucGeneralCnt++)
  47.        {
  48.            SendOneViewData(aucViewData[ucGeneralCnt]);
  49.        }
  50.        
  51.        delay1us(50);
  52.        VIEW_PORT_OUT |= bitVIEWCLK;
  53.        VIEW_PORT_OUT |= bitVIEWDATASO;
  54.    }
  55.   _EINT();
  56. }
  57. void ViewCommunicationRX(void)
  58. {
  59.   unsigned char ucGeneralCnt = 0;   
  60.   __disable_interrupt();
  61.   while ((VIEW_PORT_IN & bitVIEWDATASI) != bitVIEWDATASI)//wait Low
  62.      {  
  63.       //if ((gucGeneralStatus & bitModemActive) == bitModemActive)
  64.         //break;
  65.       if (gwTimeOverflowCount++ == 0xffff)
  66.             gucTimeOverflowCount++;
  67.         if (gucTimeOverflowCount == 10)
  68.             {gucGeneralStatus &= ~bitSendFaxSignalOK;gucTimeOverflowCount=0;gwTimeOverflowCount=0;break;}
  69.      } 
  70.   VIEW_PORT_OUT &= ~bitVIEWCLK;
  71.   while ((VIEW_PORT_IN & bitVIEWDATASI) == bitVIEWDATASI)//wait Low
  72.      {  
  73.       if ((gucGeneralStatus & bitModemActive) == bitModemActive)
  74.         break;
  75.      } 
  76.   if ((VIEW_PORT_IN & bitVIEWDATASI) != bitVIEWDATASI)
  77.    {
  78.      /*
  79.      SendOneViewData(0x80);
  80.      gucHour=ReceiveOneViewData();
  81.      gucMinute=ReceiveOneViewData();
  82.      gucSecond=ReceiveOneViewData();
  83.      gucMonth = ReceiveOneViewData();
  84.      gucDate = ReceiveOneViewData();
  85.      gucYear = ReceiveOneViewData();
  86.      gucViewRingNum=ReceiveOneViewData();
  87.      gucViewStaticStatus=ReceiveOneViewData();
  88.      gucViewDynamicStatus=ReceiveOneViewData();
  89.      gucIcon2=ReceiveOneViewData();
  90.      */
  91.      for (ucGeneralCnt=0; ucGeneralCnt<10; ucGeneralCnt++)
  92.           {
  93.               aucViewData[ucGeneralCnt]=ReceiveOneViewData();
  94.           }
  95.      delay1us(50);
  96.      VIEW_PORT_OUT |= bitVIEWCLK;
  97.    }
  98.   
  99.   _EINT();
  100.  
  101. }
  102. void SendOneViewData(unsigned char ucViewTxData)
  103. {
  104.   unsigned char ucGeneralCount=0;
  105.   for (ucGeneralCount=0;ucGeneralCount<8;ucGeneralCount++)
  106.      {
  107.         VIEW_PORT_OUT &= ~bitVIEWCLK;
  108.         delay1us(50);//
  109.         if ((ucViewTxData & BIT0) == BIT0)
  110.           {VIEW_PORT_OUT |= bitVIEWDATASO;} //set   Tx bit
  111.         else
  112.           {VIEW_PORT_OUT &= ~bitVIEWDATASO;} //reset Tx bit
  113.         ucViewTxData=ucViewTxData>>1; 
  114.         delay1us(50);//
  115.         VIEW_PORT_OUT |= bitVIEWCLK;
  116.         delay1us(100);
  117.         VIEW_PORT_OUT &= ~bitVIEWCLK;
  118.         
  119.      }
  120. }
  121. unsigned char ReceiveOneViewData(void)
  122. {
  123.   unsigned char ucGeneralCount=0;
  124.   unsigned char ucViewRxData;
  125.   for (ucGeneralCount=0;ucGeneralCount<8;ucGeneralCount++)
  126.      {
  127.         ucViewRxData=ucViewRxData>>1;
  128.         VIEW_PORT_OUT &= ~bitVIEWCLK;
  129.         delay1us(100);
  130.         VIEW_PORT_OUT |= bitVIEWCLK;
  131.         delay1us(50);
  132.         if ((VIEW_PORT_IN & bitVIEWDATASI) == bitVIEWDATASI)
  133.           {ucViewRxData |= BIT7;} //1
  134.         else
  135.           {ucViewRxData &= ~BIT7;} //0
  136.         
  137.         delay1us(50);
  138.         VIEW_PORT_OUT &= ~bitVIEWCLK;
  139.      }
  140.    return  ucViewRxData; 
  141. /*
  142.         if ((VIEW_PORT_OUT & bitVIEWCLK) == bitVIEWCLK)
  143.           {VIEW_PORT_OUT &= ~bitVIEWDATA;} //Reset CLOCK
  144.         else
  145.           {VIEW_PORT_OUT |= bitVIEWDATA;} //set CLOCK
  146. */