FaxFrontPointerManage.c
上传用户:xhjmsc
上传日期:2019-09-13
资源大小:389k
文件大小:4k
- /***************************************
- Program: FlashManage
- Author: Bryan Cai
- Date: 2006.12.12
- ***************************************/
- #include "includeH.h"
- void WriteFaxFrontPointerTable(void)
- {
-
- unsigned char ucFlashSttsOverflowCnt=0,ucFaxPointerLenCnt=0,
- ucRxIndex=0;
-
- COMMAND_VAL=cFlashWriteCmd;
- COMMAND_LATCH_INTO();
- //ADDRESS
-
- ADDRESS_VALUE=gwColumnAddress & 0xff;//COLUMN_ADDRESS_LOW;
- ADDRESS_LATCH_INTO();
-
- ADDRESS_VALUE=(gwColumnAddress>>8) & 0XFF;//COLUMN_ADDRESS_HIGH;
- ADDRESS_LATCH_INTO();
-
- ADDRESS_VALUE=gwFrontPointerAddress & 0xff;
- ADDRESS_LATCH_INTO();
-
- ADDRESS_VALUE=(gwFrontPointerAddress>>8) & 0XFF;
- ADDRESS_LATCH_INTO();
- FLASH_CON_PORT_OUT &=~ ALE;
-
- DATA_PORT_OUT_INITIAL;
- for (ucFaxPointerLenCnt=0;ucFaxPointerLenCnt<4;ucFaxPointerLenCnt++)
- {
- FLASH_CON_PORT_OUT&=~WE;
- DATA_PORT_OUT=aucUartRxBuf[ucRxIndex++];
- FLASH_CON_PORT_OUT |= WE;
- }
-
- COMMAND_VAL=cFlashWriteInitiateCmd; //10H INITIATES PROGRAM
- COMMAND_LATCH_INTO();
-
- READ_STATUS();
- ucFlashSttsOverflowCnt=0;
- if(FLASH_STATUS==1&&(ucFlashSttsOverflowCnt++)<2)
- {;}
- }
- void ReadLastFaxFrontPointer(void)//find last fax front pointer
- {
- unsigned int wPageAddress=0, wBlockAddress=0,
- wColumnAddress=0,wNextPageAddress=0,
- wRearPntCnt=0;
- unsigned char ucRxIndex=0,
- ucRxIndex3=0,ucRxIndex2=0,
- ucRxIndex0=0,ucRxIndex1=0,
- ucGeneralCnt=0,ucFaxRearLenCnt;
-
- for (wBlockAddress=cFaxFrontPointerTableStartBlockNum;
- wBlockAddress<=cFaxFrontPointerTableOverBlockNum;wBlockAddress++)
- {
-
- for (wPageAddress=(wBlockAddress<<6);wPageAddress<((wBlockAddress<<6)+64);wPageAddress++)
- {
- do{
- wNextPageAddress=wPageAddress+64;
- wPageAddress=CalNextPageAddress(wPageAddress);
- }while(wNextPageAddress==wPageAddress);
-
- wColumnAddress=0;
- ROW_ADDRESS_LOW=wPageAddress & 0XFF;
- ROW_ADDRESS_HIGH=(wPageAddress>>8) & 0XFF;
-
- for (ucGeneralCnt=0;ucGeneralCnt<8;ucGeneralCnt++)
- {
- //COMMAND
- COMMAND_VAL=0x00; //#0X00 //00H READ1 0-2111BYTE
- COMMAND_LATCH_INTO();
- //ADDRESS
- ADDRESS_VALUE=wColumnAddress & 0xff;//COLUMN_ADDRESS_LOW;
- ADDRESS_LATCH_INTO();
-
- ADDRESS_VALUE=(wColumnAddress>>8) & 0XFF;//COLUMN_ADDRESS_HIGH;
- ADDRESS_LATCH_INTO();
-
- ADDRESS_VALUE=ROW_ADDRESS_LOW;
- ADDRESS_LATCH_INTO();
-
- ADDRESS_VALUE=ROW_ADDRESS_HIGH;
- ADDRESS_LATCH_INTO();
- FLASH_CON_PORT_OUT &=~ ALE;
-
- COMMAND_VAL=0X30;
- COMMAND_LATCH_INTO();
- //ATcmdDelay();
- while((FLASH_CON_PORT_IN & RB)==0);
- DATA_PORT_IN_INITIAL;
- for (ucFaxRearLenCnt=0;ucFaxRearLenCnt<4;ucFaxRearLenCnt++)
- {
- FLASH_CON_PORT_OUT &=~ RE; //RE IS LOW,ENABLE READ DATA
- aucUartRxBuf[ucRxIndex++]=DATA_PORT_IN;
- FLASH_CON_PORT_OUT |= RE;
- }
- wRearPntCnt++;
-
- ucRxIndex3=ucRxIndex-4;
- ucRxIndex2=ucRxIndex-3;
- ucRxIndex1=ucRxIndex-2;
- ucRxIndex0=ucRxIndex-1;
- if (0xff == aucUartRxBuf[ucRxIndex0] && 0xff == aucUartRxBuf[ucRxIndex1] &&
- 0xff == aucUartRxBuf[ucRxIndex2] && 0xff == aucUartRxBuf[ucRxIndex3])
- {
- break; //next front
- }//if
- if (ucGeneralCnt<4)
- wColumnAddress+=512;
- else
- wColumnAddress+=16;
- }//for read next front pointer
-
- if (0xff == aucUartRxBuf[ucRxIndex0] && 0xff == aucUartRxBuf[ucRxIndex1] &&
- 0xff == aucUartRxBuf[ucRxIndex2] && 0xff == aucUartRxBuf[ucRxIndex3])
- {break;}
- }//for next page
-
- if (0xff == aucUartRxBuf[ucRxIndex0] && 0xff == aucUartRxBuf[ucRxIndex1] &&
- 0xff == aucUartRxBuf[ucRxIndex2] && 0xff == aucUartRxBuf[ucRxIndex3])
- {break;}
- }//for next block
- gwFrontPointerAddress=wPageAddress; //for write Fax front pointer
- gwColumnAddress=wColumnAddress; //read next front pointer address, for write next front pointer
- if (wRearPntCnt>1)
- {
- ucRxIndex1=ucRxIndex-8;
- ucRxIndex0=ucRxIndex-7;
- wPageAddress=aucUartRxBuf[ucRxIndex0];
- gwPageAddress=(wPageAddress<<8) | aucUartRxBuf[ucRxIndex1];
- }
- else
- gwPageAddress=cstFaxContentStartPage-1;//2559;//1279;//read data start address(1280)
- }