FaxProcess.c
上传用户:xhjmsc
上传日期:2019-09-13
资源大小:389k
文件大小:25k
- #include "includeH.h"
- //**************************************************************************
- void FaxRXProcess(void)
- {
- unsigned char ucFlashSttsOverflowCnt = 0;
- unsigned char ucGeneralCount = 0;
- unsigned char ucGeneralCnt = 0;
- unsigned char ucRxIndex3 = 0;
- unsigned char ucRxIndex2 = 0;
- unsigned char ucRxIndex1 = 0;
- unsigned char ucRxIndex0 = 0;
-
- unsigned int wNextPageAddress = 0;
- unsigned int wPageAddress = 0;
- unsigned int wGeneralCount = 0;
- unsigned int wDataRearCount = 0;
- FaxRxInit();
- /***************************************************************************/
- //ATA
-
- SendATcmdATA(); //Connect
- while (1) //CONNECT(54) 0D 0A
- {
- ucRxIndex1 = gucUartRxCnt-3;//get array index
- ucRxIndex0 = gucUartRxCnt-2;//get array index
- if ((0x0d == aucUartRxBuf[ucRxIndex0]) && (0x54 == aucUartRxBuf[ucRxIndex1]))
- break;
- //if check time>min. 5S, Receive Fax error, program should be quit
- RxFaxTimeOverflowErrorQuit();
- }
-
- Delay1500ms(); // delay 1.5S minimun 1 second
-
- SendATdataFTHCSI(); //If the final bit is 0, the modem will generates CONNECT message.
- while (1) //CONNECT(54) 0D 0A
- {
- ucRxIndex1 = gucUartRxCnt-3;
- ucRxIndex0 = gucUartRxCnt-2;
- if ((0x0d == aucUartRxBuf[ucRxIndex0]) && (0x54 == aucUartRxBuf[ucRxIndex1]))
- break;
- //if check time>min. 5S, Receive Fax error, progra should be quit
- RxFaxTimeOverflowErrorQuit();
- }
-
- for (ucGeneralCount = 0; ucGeneralCount < 50; ucGeneralCount++)// delay 1.5S minimun 1 second
- {
- ATcmdDelay(); //50ms
- }
- SendATdataFTHDIS();//SendATdataFTHTSI(sizeof (FTHDIS)); a bug of Sep.18
-
- while (1) //O K 0D 0A
- {
- ucRxIndex1 = gucUartRxCnt-3;
- ucRxIndex0 = gucUartRxCnt-2;
- if ((0x0d == aucUartRxBuf[ucRxIndex0]) && (0x4B == aucUartRxBuf[ucRxIndex1])) //K ==0x4b
- break;
- //if check time>min. 5S, Receive Fax error, progra should be quit
- RxFaxTimeOverflowErrorQuit();
- }
-
- //*
- //FRH TSI (transmitting subscriber identification)
- SendATcmdFRH();
- while (1) //Connect data.....OK 0D 0A
- {
- ucRxIndex1 = gucUartRxCnt-3;
- ucRxIndex0 = gucUartRxCnt-2;
- if ((0x0d == aucUartRxBuf[ucRxIndex0]) && (0x54 == aucUartRxBuf[ucRxIndex1])) //Connect
- break;
- if ((0x0d == aucUartRxBuf[ucRxIndex0]) && (0x52 == aucUartRxBuf[ucRxIndex1])) //No Carrier
- break;
- //if ((0x0d==aucUartRxBuf[ucRxIndex0])&&(0x4b==aucUartRxBuf[ucRxIndex1]))
- //{ucFrhErrorStatus=0x03;break;}
- //if check time>min. 5S, Receive Fax error, progra should be quit
- RxFaxTimeOverflowErrorQuit();
- }//while
-
- for (ucGeneralCnt = 0;ucGeneralCnt < 5;ucGeneralCnt++)
- {
- if (gucFrhErrorStatus == 0x03 || (0x0d == aucUartRxBuf[ucRxIndex0]) && (0x52 == aucUartRxBuf[ucRxIndex1]))
- {
- SendATcmdSuffix();
- ATcmdDelay();
- ATcmdDelay();
- ATcmdDelay();
- SendATcmdPrefix();
- ATcmdDelay();
- SendATcmdSuffix();
- ATcmdDelay();
- ATcmdDelay();
- ATcmdDelay();
- Delay2000ms();//add at Jan. 16, 2007
- FthCsiDis();
- SendATcmdFRH();
- while (1) //Connect data.....OK 0D 0A
- {
- ucRxIndex1 = gucUartRxCnt-3;
- ucRxIndex0 = gucUartRxCnt-2;
- if ((0x0d == aucUartRxBuf[ucRxIndex0]) && (0x54 == aucUartRxBuf[ucRxIndex1]))
- break;
- if ((0x0d == aucUartRxBuf[ucRxIndex0]) && (0x52 == aucUartRxBuf[ucRxIndex1]))
- break;
- //if check time>min. 5S, Receive Fax error, progra should be quit
- RxFaxTimeOverflowErrorQuit();
- }//while
- }//if
- if ((0x0d == aucUartRxBuf[ucRxIndex0]) && (0x54 == aucUartRxBuf[ucRxIndex1]))
- {
- while (1)
- {
- ucRxIndex1 = gucUartRxCnt-3;
- ucRxIndex0 = gucUartRxCnt-2;
- if ((0x0d == aucUartRxBuf[ucRxIndex0]) && (0x4B == aucUartRxBuf[ucRxIndex1]))
- break;
- if ((0x0d == aucUartRxBuf[ucRxIndex0]) && (0x52 == aucUartRxBuf[ucRxIndex1]))
- break;
- if ((0x13 == aucUartRxBuf[ucRxIndex0]) && (0xff == aucUartRxBuf[ucRxIndex1]))
- {gucFrhErrorStatus=CNGFthOnlySendOneNSF;}
- //if check time>min. 5S, Receive Fax error, progra should be quit
- RxFaxTimeOverflowErrorQuit();
- }//while
- if ((0x0d == aucUartRxBuf[ucRxIndex0]) && (0x52 == aucUartRxBuf[ucRxIndex1]))
- continue;//Response is not OK, but NO Carrier. should Re FTH CSI and DIS
- else
- break;//break for cycle
- }//if
- }//for
- ucRxIndex0 = gucUartRxCnt-25;
- for (ucGeneralCnt = 0;ucGeneralCnt < 25;ucGeneralCnt++)
- {FRHTSI[ucRxIndex1++] = aucUartRxBuf[ucRxIndex0++];}
-
- //FRH DCS (digital command signal)
- if (gucFrhErrorStatus != CNGFthOnlySendOneNSF)
- {
- SendATcmdFRH();
- while (1)
- {
- ucRxIndex1 = gucUartRxCnt-3;
- ucRxIndex0 = gucUartRxCnt-2;
- if ((0x0d == aucUartRxBuf[ucRxIndex0]) && (0x54 == aucUartRxBuf[ucRxIndex1]))
- break;
- //if check time>min. 5S, Receive Fax error, progra should be quit
- RxFaxTimeOverflowErrorQuit();
- }//while
- if (gucFrhErrorStatus == 0x03) return; //add at Mar. 16, 2007.
-
- while (1)
- {
- ucRxIndex1 = gucUartRxCnt-3;
- ucRxIndex0 = gucUartRxCnt-2;
- if ((0x0d == aucUartRxBuf[ucRxIndex0]) && (0x4B == aucUartRxBuf[ucRxIndex1]))
- break;
- //if check time>min. 5S, Receive Fax error, progra should be quit
- RxFaxTimeOverflowErrorQuit();
- }//while
- if (gucFrhErrorStatus == 0x03) return; //add at Mar. 16, 2007.
- }//if
-
- //if (ucFrhErrorStatus==03) return; //add at Mar. 16, 2007.
- //*/
- //FRM TCF (training check)
- SendATcmdFRM();
- while (1)
- {
- ucRxIndex1 = gucUartRxCnt-3;
- ucRxIndex0 = gucUartRxCnt-2;
- if ((0x0d == aucUartRxBuf[ucRxIndex0]) && (0x54 == aucUartRxBuf[ucRxIndex1]))
- break;
- //if check time>min. 5S, Receive Fax error, progra should be quit
- RxFaxTimeOverflowErrorQuit();
- }
- if (gucFrhErrorStatus == 0x03) return;
- //Carrier==Training check
- ///* //add the No carrier check a bug of Dec.25,2006
- while (1)
- {
- ucRxIndex1 = gucUartRxCnt-3;
- ucRxIndex0 = gucUartRxCnt-2;
- if ((aucUartRxBuf[ucRxIndex0] == 0x0d)&&(aucUartRxBuf[ucRxIndex1] == 0x52))//4B Result code is not OK, but No carrier
- break;
- //if check time>min. 5S, Receive Fax error, progra should be quit
- RxFaxTimeOverflowErrorQuit();
- }
- if (gucFrhErrorStatus == 0x03) return;
- //*/
- //Training check over
- //FTHCFR (confirmation to receive)
- SendATcmdFTH();
- while (1) //Connect
- {
- ucRxIndex1=gucUartRxCnt-3;
- ucRxIndex0=gucUartRxCnt-2;
- if ((0x0d==aucUartRxBuf[ucRxIndex0])&&(0x54==aucUartRxBuf[ucRxIndex1]))
- break;
- //if check time>min. 5S, Receive Fax error, progra should be quit
- RxFaxTimeOverflowErrorQuit();
- }
- if (gucFrhErrorStatus==0x03) return;
-
- for (ucGeneralCount=0; ucGeneralCount<30; ucGeneralCount++)// delay 1.5S minimun 1 second
- {
- ATcmdDelay(); //50ms
- }
-
- SendATdataFTHCFR();
- while (1)
- {
- ucRxIndex1=gucUartRxCnt-3;
- ucRxIndex0=gucUartRxCnt-2;
- if ((0x0d==aucUartRxBuf[ucRxIndex0])&&(0x4B==aucUartRxBuf[ucRxIndex1]))
- break;
- //if check time>min. 5S, Receive Fax error, progra should be quit
- RxFaxTimeOverflowErrorQuit();
- }
- if (gucFrhErrorStatus==0x03) return;
-
- //FRM pageimage
- //SendATcmdFRM146();
- SendATcmdFRM();
-
- wGeneralCount=0;//63;
- ucGeneralCnt=0;//28;
- //wPageAddress=0;
- gucFrhErrorStatus=0;
- gucUartRxCnt=0;
- gpucQueueRear=0;
- gpucQueueFront=0;
- gdwRxQueueRearCnt=0;
- gdwRxQueueFrontCnt=0;
- //ZERO_ADDRESS();
- wPageAddress=cstFaxRxBufStartPage;//+1;//Block 19 Modify at Jan. 6, 2007
-
- do{
- wNextPageAddress=wPageAddress+64;
- wPageAddress=CalNextPageAddress(wPageAddress);
- }while(wNextPageAddress==wPageAddress);
- //erase next block
- if (wPageAddress%64==0)
- {
- ROW_ADDRESS_LOW=wPageAddress & 0XFF;
- ROW_ADDRESS_HIGH=(wPageAddress>>8) & 0XFF;
- ERASE_ONE_BLOCK();
- }
- wPageAddress=cstFaxRxBufStartPage+1;
- //COMMAND
- //Flash_Reset();
- COMMAND_VAL=0X80;
- COMMAND_LATCH_INTO();
-
- //ADDRESS
- ADDRESS_VALUE=0;//COLUMN_ADDRESS_HIGH; //#0X00
- ADDRESS_LATCH_INTO();
-
- ADDRESS_VALUE=0;//COLUMN_ADDRESS_HIGH; //#0X00
- ADDRESS_LATCH_INTO();
-
- ADDRESS_VALUE=wPageAddress & 0xff; //#0X00
- ADDRESS_LATCH_INTO();
-
- ADDRESS_VALUE=(wPageAddress>>8) & 0xff; //#0X00
- ADDRESS_LATCH_INTO();
-
- FLASH_CON_PORT_OUT &=~ ALE;
- //CALL DELAY_100US
- //for(i=0;i<0xff;i++);
- DATA_PORT_OUT_INITIAL; //MCU OUTPUT,MCU WRITE A DATA TO FLASH
- //Pageimage
- while (1)
- {
- //if ((0x10 == aucUartRxBuf[ucRxIndex1]) && (0x03 == aucUartRxBuf[ucRxIndex0]))//terminate stream 10 03
- //if ((0x10 == aucUartRxBuf[gucUartRxCnt-1]) && (0x03 == aucUartRxBuf[gucUartRxCnt]))//terminate stream 10 03
- //break;
- //if check time>min. 5S, Receive Fax error, progra should be quit
- RxFaxTimeOverflowErrorQuit();
- ucRxIndex1=gucUartRxCnt-3;
- ucRxIndex0=gucUartRxCnt-2;
- if ((aucUartRxBuf[ucRxIndex0]==0x0d)&&(aucUartRxBuf[ucRxIndex1]==0x52))//4B Result code is not OK, but No carrier
- {
-
- PageImageEndProcess();
-
- if (gucFrhErrorStatus==0x03) break; //add at Mar. 16, 2007.
-
- //More than two pages process //add at Dec.27,2006
- ucRxIndex3=gucUartRxCnt-38;
- ucRxIndex2=gucUartRxCnt-37;
- ucRxIndex1=gucUartRxCnt-36;
- ucRxIndex0=gucUartRxCnt-35;
- if ((aucUartRxBuf[ucRxIndex0]==0x05)&&(aucUartRxBuf[ucRxIndex1]==0x35)&&
- (aucUartRxBuf[ucRxIndex2]==0x4f)&&(aucUartRxBuf[ucRxIndex3]==0x13))
- {
- SendATcmdFRM();
- }
- // multi pages over flag
- if ((aucUartRxBuf[ucRxIndex0]==0x66)&&(aucUartRxBuf[ucRxIndex1]==0x33)&&
- (aucUartRxBuf[ucRxIndex2]==0x2f)&&(aucUartRxBuf[ucRxIndex3]==0x13))
- {
- break;
- }
- // one page over flag
- if ((aucUartRxBuf[ucRxIndex0]==0x2f)&&(aucUartRxBuf[ucRxIndex1]==0x13))
- {
- break;
- }
- }
- if (gdwRxQueueRearCnt-gdwRxQueueFrontCnt>32)
- {
- if (gdwRxQueueRearCnt-gdwRxQueueFrontCnt>254) // if data num is more than the buffer space, error happan.
- {
- while (1);//gucGeneralStatus |= FAXRXERROR;
- }
- if (wGeneralCount++<64) // 32*64=2048
- {
- for (ucGeneralCnt=0;ucGeneralCnt<32;ucGeneralCnt++)
- {
- FLASH_CON_PORT_OUT&=~WE;
- DATA_PORT_OUT=aucUartRxBuf[gpucQueueFront++];
- gdwRxQueueFrontCnt++; //The total num that is writed to flash
- FLASH_CON_PORT_OUT |= WE;
- }
- //ucGeneralCnt=0;
- }
- else
- {
- wGeneralCount=0;
-
- COMMAND_VAL=0X10; //10H INITIATES PROGRAM
- COMMAND_LATCH_INTO();
-
- READ_STATUS();
- ucFlashSttsOverflowCnt=0;
- while (FLASH_STATUS==1&&(ucFlashSttsOverflowCnt++)<2)
- {
- ;//ERASE_ONE_BLOCK();
- //PROGRAM_ONE_PAGE();
- }
- if (wPageAddress<2559) wPageAddress++; //add at Jan. 18, 2007
- do{
- wNextPageAddress=wPageAddress+64;
- wPageAddress=CalNextPageAddress(wPageAddress);
- }while(wNextPageAddress==wPageAddress);
- if (wPageAddress%64==0)
- {
- ROW_ADDRESS_LOW=wPageAddress & 0XFF;
- ROW_ADDRESS_HIGH=(wPageAddress>>8) & 0XFF;
- ERASE_ONE_BLOCK();
- }
- //Flash_Reset();
- COMMAND_VAL=0X80;
- COMMAND_LATCH_INTO();
-
- //ADDRESS
- ADDRESS_VALUE=0;//COLUMN_ADDRESS_HIGH; //#0X00
- ADDRESS_LATCH_INTO();
-
- ADDRESS_VALUE=0;//COLUMN_ADDRESS_HIGH; //#0X00
- ADDRESS_LATCH_INTO();
-
- ADDRESS_VALUE=wPageAddress & 0xff; //#0X00
- ADDRESS_LATCH_INTO();
-
- ADDRESS_VALUE=(wPageAddress>>8) & 0xff; //#0X00
- ADDRESS_LATCH_INTO();
-
- FLASH_CON_PORT_OUT &=~ ALE;
- //CALL DELAY_100US
- //for(i=0;i<0xff;i++);
- DATA_PORT_OUT_INITIAL; //MCU OUTPUT,MCU WRITE A DATA TO FLASH
-
- }//else
- }//if
- }//while
-
- if (gucFrhErrorStatus==0x03) return; //add at Mar. 16, 2007.
- //FRH DNC (disconnect) //Modity at Dec. 28,2006. DNC is the over flag
- SendATcmdFRH();
-
- while (1)
- {
- ucRxIndex1=gucUartRxCnt-3;
- ucRxIndex0=gucUartRxCnt-2;
- if ((0x0d==aucUartRxBuf[ucRxIndex0])&&(0x54==aucUartRxBuf[ucRxIndex1]))
- break;
- //if check time>min. 5S, Receive Fax error, progra should be quit
- RxFaxTimeOverflowErrorQuit();
- }
-
- if (gucFrhErrorStatus==0x03) return; //add at Mar. 16, 2007.
-
- while (1)
- {
- ucRxIndex1=gucUartRxCnt-3;
- ucRxIndex0=gucUartRxCnt-2;
- if ((0x0d==aucUartRxBuf[ucRxIndex0])&&(0x4B==aucUartRxBuf[ucRxIndex1]))
- break;
- //if check time>min. 5S, Receive Fax error, progra should be quit
- RxFaxTimeOverflowErrorQuit();
- }
-
- if (gucFrhErrorStatus==0x03) return; //add at Mar. 16, 2007.
-
- //FaxRearDataProcess
- while (gdwRxQueueRearCnt-gdwRxQueueFrontCnt>=32)
- {
- if (gdwRxQueueRearCnt-gdwRxQueueFrontCnt>254) // if data num is more than the buffer space, error happan.
- {
- gucGeneralStatus |= FAXRXERROR;
- }
- if (wGeneralCount++<64) // 32*64=2048
- {
- for (ucGeneralCnt=0;ucGeneralCnt<32;ucGeneralCnt++)
- {
- FLASH_CON_PORT_OUT&=~WE;
- DATA_PORT_OUT=aucUartRxBuf[gpucQueueFront++];
- gdwRxQueueFrontCnt++; //The total num that is writed to flash
- FLASH_CON_PORT_OUT |= WE;
- }
- }
- else
- {
- wGeneralCount=0;
-
- COMMAND_VAL=0X10; //10H INITIATES PROGRAM
- COMMAND_LATCH_INTO();
-
- READ_STATUS();
- ucFlashSttsOverflowCnt=0;
- while (FLASH_STATUS==1&&(ucFlashSttsOverflowCnt++)<2)
- {
- ;//ERASE_ONE_BLOCK();
- //PROGRAM_ONE_PAGE();
- }
- if (wPageAddress<2559) wPageAddress++;//add at Jan. 18, 2007
- do{
- wNextPageAddress=wPageAddress+64;
- wPageAddress=CalNextPageAddress(wPageAddress);
- }while(wNextPageAddress==wPageAddress);
- if (wPageAddress%64==0)
- {
- ROW_ADDRESS_LOW=wPageAddress & 0XFF;
- ROW_ADDRESS_HIGH=(wPageAddress>>8) & 0XFF;
- ERASE_ONE_BLOCK();
- }
- COMMAND_VAL=0X80;
- COMMAND_LATCH_INTO();
-
- //ADDRESS
- ADDRESS_VALUE=0;//COLUMN_ADDRESS_LOW; //#0X00
- ADDRESS_LATCH_INTO();
-
- ADDRESS_VALUE=0;//COLUMN_ADDRESS_LOW; //#0X00
- ADDRESS_LATCH_INTO();
-
- ADDRESS_VALUE=wPageAddress & 0xff; //#0X00
- ADDRESS_LATCH_INTO();
-
- ADDRESS_VALUE=(wPageAddress>>8) & 0xff; //#0X00
- ADDRESS_LATCH_INTO();
-
- FLASH_CON_PORT_OUT &=~ ALE;
- //CALL DELAY_100US
- //for(i=0;i<0xff;i++);
- DATA_PORT_OUT_INITIAL; //MCU OUTPUT,MCU WRITE A DATA TO FLASH
-
- }//else
- }//while
- //***************************************
- wDataRearCount=gdwRxQueueRearCnt-gdwRxQueueFrontCnt;
- if (wDataRearCount)//wDataRearCount<2048-wGeneralCount*ucGeneralCnt)
- {
- //for (ucGeneralCnt=0;ucGeneralCnt<wGeneralCount;ucGeneralCnt++)
- for (ucGeneralCnt=0;ucGeneralCnt<wDataRearCount;ucGeneralCnt++)
- {
- FLASH_CON_PORT_OUT&=~WE;
- DATA_PORT_OUT=aucUartRxBuf[gpucQueueFront++];
- gdwRxQueueFrontCnt++;
- FLASH_CON_PORT_OUT |= WE;
- }
-
- wGeneralCount=0;
- COMMAND_VAL=0X10; //10H INITIATES PROGRAM
- COMMAND_LATCH_INTO();
-
- READ_STATUS();
- ucFlashSttsOverflowCnt=0;
- if(FLASH_STATUS==1&&(ucFlashSttsOverflowCnt++)<2)
- {
- ;//ERASE_ONE_BLOCK();
- //PROGRAM_ONE_PAGE();
- }
- }//if
-
-
-
-
- SendATcmdH0();
-
- while (1)
- {
- ucRxIndex1=gucUartRxCnt-3;
- ucRxIndex0=gucUartRxCnt-2;
- if ((0x0d==aucUartRxBuf[ucRxIndex0])&&(0x4B==aucUartRxBuf[ucRxIndex1]))
- break;
- //if check time>min. 5S, Receive Fax error, progra should be quit
- RxFaxTimeOverflowErrorQuit();
- }
-
- if (gucFrhErrorStatus==0x03) return; //add at Mar. 16, 2007.
- ATcmdDelay();
- ATcmdDelay();
- ATcmdDelay();
- ATcmdDelay();
-
- SendATcmdH0();
-
- while (1)
- {
- ucRxIndex1=gucUartRxCnt-3;
- ucRxIndex0=gucUartRxCnt-2;
- if ((0x0d==aucUartRxBuf[ucRxIndex0])&&(0x4B==aucUartRxBuf[ucRxIndex1]))
- break;
- //if check time>min. 5S, Receive Fax error, progra should be quit
- RxFaxTimeOverflowErrorQuit();
- }
- if (gucFrhErrorStatus==0x03) return; //add at Mar. 16, 2007.
- ATcmdDelay();
- ATcmdDelay();
- ATcmdDelay();
- ATcmdDelay();
- ATcmdDelay();
- ATcmdDelay();
- ATcmdDelay();
- ATcmdDelay();
- //AT Fclass0
-
- SendATcmdFCLASS0();
- ATcmdDelay();
- ATcmdDelay();
- ATcmdDelay();
- ATcmdDelay();
- //AT
- SendATcmdPrefix();
- ATcmdDelay();
- SendATcmdSuffix();
- ATcmdDelay();
- ATcmdDelay();
- ATcmdDelay();
- //AT
- SendATcmdPrefix();
- ATcmdDelay();
- SendATcmdSuffix();
- ATcmdDelay();
- ATcmdDelay();
- ATcmdDelay();
- //AT
- SendATcmdPrefix();
- ATcmdDelay();
- SendATcmdSuffix();
- ATcmdDelay();
- ATcmdDelay();
- ATcmdDelay();
-
- SendATconfigFE0EndofRX();
- ATcmdDelay();
- ATcmdDelay();
- ATcmdDelay();
- ATcmdDelay();
-
- SendATconfigS7RX();
- ATcmdDelay();
- ATcmdDelay();
- ATcmdDelay();
- ATcmdDelay();
-
- SendATconfigS0RX();
- ATcmdDelay();
- ATcmdDelay();
- ATcmdDelay();
- ATcmdDelay();
-
-
-
- //***************************************/
- //gucRxTxFlag = DTERX;// set Rx Tx flag
- _NOP();
- gwPageAddress = wPageAddress;
- /*
- while (1)
- {
- SendATcmdModemSoftReset();
- ATcmdDelay();
- ATcmdDelay();
-
- ucRxIndex1=gucUartRxCnt-3;
- ucRxIndex0=gucUartRxCnt-2;
- if ((0x0d==aucUartRxBuf[ucRxIndex0])&&(0x4B==aucUartRxBuf[ucRxIndex1]))
- {break;}
- }//while
- */
-
- }//FaxRXProcess
- void FaxRxInit(void)
- {
- SendATconfigFS0();
- ATcmdDelay();
- ATcmdDelay();
- ATcmdDelay();
- //AT
- SendATcmdPrefix();
- ATcmdDelay();
- SendATcmdSuffix();
- ATcmdDelay();
- ATcmdDelay();
- ATcmdDelay();
-
- SendATconfigS7();
- ATcmdDelay();
- ATcmdDelay();
- ATcmdDelay();
-
- SendATconfigX4M1();
- ATcmdDelay();
- ATcmdDelay();
- ATcmdDelay();
-
- SendATcmdFCLASS();
- ATcmdDelay();
- ATcmdDelay();
- ATcmdDelay();
- //AT
- SendATcmdPrefix();
- ATcmdDelay();
- SendATcmdSuffix();
- ATcmdDelay();
- ATcmdDelay();
- ATcmdDelay();
-
- SendATcmdFCLASS();
- ATcmdDelay();
- ATcmdDelay();
- ATcmdDelay();
- //AT
- SendATcmdPrefix();
- ATcmdDelay();
- SendATcmdSuffix();
- ATcmdDelay();
- ATcmdDelay();
- ATcmdDelay();
- }
- void PageImageEndProcess(void)
- {
- unsigned char ucRxIndex1=0,ucRxIndex0=0;
- //FRHEOP (end of procedure)
- SendATcmdFRH();
- //ATcmdDelay();
-
- while (1)
- {
- ucRxIndex1=gucUartRxCnt-3;
- ucRxIndex0=gucUartRxCnt-2;
- if ((0x0d==aucUartRxBuf[ucRxIndex0])&&(0x54==aucUartRxBuf[ucRxIndex1]))
- break;
- //if check time>min. 5S, Receive Fax error, progra should be quit
- RxFaxTimeOverflowErrorQuit();
- }//while
-
- if (gucFrhErrorStatus==0x03) return; //add at Mar. 16, 2007.
-
- while (1)
- {
- ucRxIndex1=gucUartRxCnt-3;
- ucRxIndex0=gucUartRxCnt-2;
- if ((0x0d==aucUartRxBuf[ucRxIndex0])&&(0x4B==aucUartRxBuf[ucRxIndex1]))
- break;
- //if check time>min. 5S, Receive Fax error, progra should be quit
- RxFaxTimeOverflowErrorQuit();
- }
-
- if (gucFrhErrorStatus==0x03) return; //add at Mar. 16, 2007.
-
- //FTHMCF (message confirmation)
- SendATcmdFTH();
- while (1)
- {
- ucRxIndex1=gucUartRxCnt-3;
- ucRxIndex0=gucUartRxCnt-2;
- if ((0x0d==aucUartRxBuf[ucRxIndex0])&&(0x54==aucUartRxBuf[ucRxIndex1]))
- break;
- //if check time>min. 5S, Receive Fax error, progra should be quit
- RxFaxTimeOverflowErrorQuit();
- }
-
- if (gucFrhErrorStatus == 0x03) return; //add at Mar. 16, 2007.
-
- Delay1500ms(); // delay 1.5S minimun 1 second
- SendATdataFTHMCF();
- while (1)
- {
- ucRxIndex1=gucUartRxCnt-3;
- ucRxIndex0=gucUartRxCnt-2;
- if ((0x0d==aucUartRxBuf[ucRxIndex0])&&(0x4B==aucUartRxBuf[ucRxIndex1]))
- break;
- //if check time>min. 5S, Receive Fax error, progra should be quit
- RxFaxTimeOverflowErrorQuit();
- }
-
- if (gucFrhErrorStatus==0x03) return; //add at Mar. 16, 2007.
- }
- void FRHDncProcess(void)
- {
- ;
- }
- void FthCsiDis(void)
- {
- unsigned char ucRxIndex1=0,ucRxIndex0=0,
- ucGeneralCount=0;
- //FTH
- SendATcmdFTH();
- while (1) //CONNECT(54) 0D 0A
- {
- ucRxIndex1=gucUartRxCnt-3;
- ucRxIndex0=gucUartRxCnt-2;
- if ((0x0d==aucUartRxBuf[ucRxIndex0])&&(0x54==aucUartRxBuf[ucRxIndex1]))
- break;
- //if check time>min. 5S, Receive Fax error, progra should be quit
- RxFaxTimeOverflowErrorQuit();
- }
- if (gucFrhErrorStatus==0x03) return; //add at Mar. 16, 2007.
-
- Delay1500ms(); // delay 1.5S minimun 1 second
-
- SendATdataFTHCSI(); //The final bit is 0. The modem will generates CONNECT message.
- while (1) //CONNECT(54) 0D 0A
- {
- ucRxIndex1=gucUartRxCnt-3;
- ucRxIndex0=gucUartRxCnt-2;
- if ((0x0d==aucUartRxBuf[ucRxIndex0])&&(0x54==aucUartRxBuf[ucRxIndex1]))
- break;
- //if check time>min. 5S, Receive Fax error, progra should be quit
- RxFaxTimeOverflowErrorQuit();
- }
- if (gucFrhErrorStatus==0x03) return; //add at Mar. 16, 2007.
-
- for (ucGeneralCount=0; ucGeneralCount<50; ucGeneralCount++)// delay 1.5S minimun 1 second
- {
- ATcmdDelay(); //50ms
- }
- SendATdataFTHDIS();//SendATdataFTHTSI(sizeof (FTHDIS)); a bug of Sep.18
-
- while (1) //O K 0D 0A
- {
- ucRxIndex1=gucUartRxCnt-3;
- ucRxIndex0=gucUartRxCnt-2;
- if ((0x0d==aucUartRxBuf[ucRxIndex0])&&(0x4B==aucUartRxBuf[ucRxIndex1])) //K ==0x4b
- break;
- //if check time>min. 5S, Receive Fax error, progra should be quit
- RxFaxTimeOverflowErrorQuit();
- }
-
- if (gucFrhErrorStatus==0x03) return; //add at Mar. 16, 2007.
- }