- //LCD View
- //new Apr. 06, 2007
- //Author bryan
- #include "includeH.h"
- void ViewCommunicationTX(unsigned char ViewTimeControlWord)
- {
- unsigned char ucGeneralCnt = 0;
- /*
- unsigned char ucYear=0xa1;
- unsigned char ucMonth=0xa2;
- unsigned char ucDate=0xa3;
- unsigned char ucHour=0xa4;
- unsigned char ucMinute=0xa5;
- unsigned char ucSecond=0xa6;
- unsigned char ucRingNum=0xa7;
- unsigned char ucIcon0=0xa8;
- unsigned char ucIcon1=0xa9;
- unsigned char ucIcon2=0xa0;
- */
- __disable_interrupt();
- VIEW_PORT_OUT &= ~bitVIEWCLK;
- while ((VIEW_PORT_IN & bitVIEWDATASI) == bitVIEWDATASI)//wait Low
- {
- if (gwTimeOverflowCount++ == 0xffff)
- gucTimeOverflowCount++;
- if (gucTimeOverflowCount == 10)
- {gucGeneralStatus &= ~bitSendFaxSignalOK;gucTimeOverflowCount=0;gwTimeOverflowCount=0;break;}
- }
- if ((VIEW_PORT_IN & bitVIEWDATASI) != bitVIEWDATASI)
- {
- SendOneViewData(ViewTimeControlWord);//00 10Bytes is effect
- //01 4Bytes is effect RingNum Icon2-1
- /*
- SendOneViewData(gucHour);
- SendOneViewData(gucMinute);
- SendOneViewData(gucSecond);
- SendOneViewData(gucMonth);
- SendOneViewData(gucDate);
- SendOneViewData(gucYear);
- SendOneViewData(gucViewRingNum);
- SendOneViewData(gucViewStaticStatus);
- SendOneViewData(gucViewDynamicStatus);
- SendOneViewData(gucIcon2);
- */
- for (ucGeneralCnt=0; ucGeneralCnt<10; ucGeneralCnt++)
- {
- SendOneViewData(aucViewData[ucGeneralCnt]);
- }
- delay1us(50);
- VIEW_PORT_OUT |= bitVIEWCLK;
- VIEW_PORT_OUT |= bitVIEWDATASO;
- }
- _EINT();
- }
- void ViewCommunicationRX(void)
- {
- unsigned char ucGeneralCnt = 0;
- __disable_interrupt();
- while ((VIEW_PORT_IN & bitVIEWDATASI) != bitVIEWDATASI)//wait Low
- {
- //if ((gucGeneralStatus & bitModemActive) == bitModemActive)
- //break;
- if (gwTimeOverflowCount++ == 0xffff)
- gucTimeOverflowCount++;
- if (gucTimeOverflowCount == 10)
- {gucGeneralStatus &= ~bitSendFaxSignalOK;gucTimeOverflowCount=0;gwTimeOverflowCount=0;break;}
- }
- VIEW_PORT_OUT &= ~bitVIEWCLK;
- while ((VIEW_PORT_IN & bitVIEWDATASI) == bitVIEWDATASI)//wait Low
- {
- if ((gucGeneralStatus & bitModemActive) == bitModemActive)
- break;
- }
- if ((VIEW_PORT_IN & bitVIEWDATASI) != bitVIEWDATASI)
- {
- /*
- SendOneViewData(0x80);
- gucHour=ReceiveOneViewData();
- gucMinute=ReceiveOneViewData();
- gucSecond=ReceiveOneViewData();
- gucMonth = ReceiveOneViewData();
- gucDate = ReceiveOneViewData();
- gucYear = ReceiveOneViewData();
- gucViewRingNum=ReceiveOneViewData();
- gucViewStaticStatus=ReceiveOneViewData();
- gucViewDynamicStatus=ReceiveOneViewData();
- gucIcon2=ReceiveOneViewData();
- */
- for (ucGeneralCnt=0; ucGeneralCnt<10; ucGeneralCnt++)
- {
- aucViewData[ucGeneralCnt]=ReceiveOneViewData();
- }
- delay1us(50);
- VIEW_PORT_OUT |= bitVIEWCLK;
- }
- _EINT();
- }
- void SendOneViewData(unsigned char ucViewTxData)
- {
- unsigned char ucGeneralCount=0;
- for (ucGeneralCount=0;ucGeneralCount<8;ucGeneralCount++)
- {
- VIEW_PORT_OUT &= ~bitVIEWCLK;
- delay1us(50);//
- if ((ucViewTxData & BIT0) == BIT0)
- {VIEW_PORT_OUT |= bitVIEWDATASO;} //set Tx bit
- else
- {VIEW_PORT_OUT &= ~bitVIEWDATASO;} //reset Tx bit
- ucViewTxData=ucViewTxData>>1;
- delay1us(50);//
- VIEW_PORT_OUT |= bitVIEWCLK;
- delay1us(100);
- VIEW_PORT_OUT &= ~bitVIEWCLK;
- }
- }
- unsigned char ReceiveOneViewData(void)
- {
- unsigned char ucGeneralCount=0;
- unsigned char ucViewRxData;
- for (ucGeneralCount=0;ucGeneralCount<8;ucGeneralCount++)
- {
- ucViewRxData=ucViewRxData>>1;
- VIEW_PORT_OUT &= ~bitVIEWCLK;
- delay1us(100);
- VIEW_PORT_OUT |= bitVIEWCLK;
- delay1us(50);
- if ((VIEW_PORT_IN & bitVIEWDATASI) == bitVIEWDATASI)
- {ucViewRxData |= BIT7;} //1
- else
- {ucViewRxData &= ~BIT7;} //0
- delay1us(50);
- VIEW_PORT_OUT &= ~bitVIEWCLK;
- }
- return ucViewRxData;
- }
- /*
- if ((VIEW_PORT_OUT & bitVIEWCLK) == bitVIEWCLK)
- {VIEW_PORT_OUT &= ~bitVIEWDATA;} //Reset CLOCK
- else
- {VIEW_PORT_OUT |= bitVIEWDATA;} //set CLOCK
- */