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

传真(Fax)编程

开发平台:

C/C++

  1.         NAME main
  2.         RTMODEL "__double_size", "32"
  3.         RTMODEL "__pic", "no"
  4.         RTMODEL "__reg_r4", "free"
  5.         RTMODEL "__reg_r5", "free"
  6.         RTMODEL "__rt_version", "1"
  7.         RSEG CSTACK:DATA:SORT:NOROOT(1)
  8.         EXTERN ?Epilogue8
  9.         EXTERN IoInitial
  10.         FUNCTION IoInitial,0202H
  11.         EXTERN InitUART
  12.         FUNCTION InitUART,0202H
  13.         EXTERN Flash_Reset
  14.         FUNCTION Flash_Reset,0202H
  15.         EXTERN FLASH_READ_ID
  16.         FUNCTION FLASH_READ_ID,0202H
  17.         EXTERN Delay2000ms
  18.         FUNCTION Delay2000ms,0202H
  19.         EXTERN ReadLast16BytesFromFlashMemoryArea
  20.         FUNCTION ReadLast16BytesFromFlashMemoryArea,0202H
  21.         EXTERN gucUartRxCnt
  22.         EXTERN gucGeneralStatus
  23.         EXTERN aucUartRxBuf
  24.         EXTERN aucViewData
  25.         EXTERN ViewCommunicationTX
  26.         FUNCTION ViewCommunicationTX,0202H
  27.         EXTERN ATcmdDelay
  28.         FUNCTION ATcmdDelay,0202H
  29.         EXTERN SendATcmd
  30.         FUNCTION SendATcmd,0202H
  31.         EXTERN SendATcmdModemSoftReset
  32.         FUNCTION SendATcmdModemSoftReset,0202H
  33.         EXTERN KeyScan
  34.         FUNCTION KeyScan,0202H
  35.         EXTERN gwTimeOverflowCount
  36.         EXTERN gucTimeOverflowCount
  37.         EXTERN gucFrhErrorStatus
  38.         EXTERN FaxRXProcess
  39.         FUNCTION FaxRXProcess,0202H
  40.         EXTERN FaxRxBufRawdata2PCFromSoftUart
  41.         FUNCTION FaxRxBufRawdata2PCFromSoftUart,0202H
  42.         EXTERN FaxRxBufRawdata2Flash
  43.         FUNCTION FaxRxBufRawdata2Flash,0202H
  44.         EXTERN ReadAndWriteViewDataMemory
  45.         FUNCTION ReadAndWriteViewDataMemory,0202H
  46.         EXTERN gucSoftUartRxCnt
  47.         EXTERN SoftUartRxOneFrame
  48.         FUNCTION SoftUartRxOneFrame,0202H
  49.         EXTERN aucSoftUartRxBuf
  50.         EXTERN DteGetModemBus
  51.         FUNCTION DteGetModemBus,0202H
  52.         EXTERN SoftUartTxOneFrame
  53.         FUNCTION SoftUartTxOneFrame,0202H
  54.         EXTERN DteReturnModemBus
  55.         FUNCTION DteReturnModemBus,0202H
  56.         EXTERN DteGetFaxList
  57.         FUNCTION DteGetFaxList,0202H
  58.         EXTERN DteGetOneFax
  59.         FUNCTION DteGetOneFax,0202H
  60.         EXTERN FlashFormat
  61.         FUNCTION FlashFormat,0202H
  62.         EXTERN CheckInvalidBlock
  63.         FUNCTION CheckInvalidBlock,0202H
  64.         EXTERN SetCSIandDIS
  65.         FUNCTION SetCSIandDIS,0202H
  66.         EXTERN DceResponsePc
  67.         FUNCTION DceResponsePc,0202H
  68.         EXTERN ?longjmp_r4
  69.         EXTERN ?longjmp_r5
  70.         EXTERN ?setjmp_r4
  71.         EXTERN ?setjmp_r5
  72.         PUBWEAK ?setjmp_save_r4
  73.         PUBWEAK ?setjmp_save_r5
  74.         PUBWEAK P1DIR
  75.         PUBWEAK P1IN
  76.         PUBWEAK P1OUT
  77.         PUBWEAK P6DIR
  78.         PUBWEAK WDTCTL
  79.         PUBLIC main
  80.         FUNCTION main,021a03H
  81.         LOCFRAME CSTACK, 32, STACK
  82.         
  83.         CFI Names cfiNames0
  84.         CFI StackFrame CFA SP DATA
  85.         CFI Resource PC:16, SP:16, SR:16, R4:16, R5:16, R6:16, R7:16, R8:16
  86.         CFI Resource R9:16, R10:16, R11:16, R12:16, R13:16, R14:16, R15:16
  87.         CFI EndNames cfiNames0
  88.         
  89.         CFI Common cfiCommon0 Using cfiNames0
  90.         CFI CodeAlign 2
  91.         CFI DataAlign 2
  92.         CFI ReturnAddress PC CODE
  93.         CFI CFA SP+2
  94.         CFI PC Frame(CFA, -2)
  95.         CFI SR Undefined
  96.         CFI R4 SameValue
  97.         CFI R5 SameValue
  98.         CFI R6 SameValue
  99.         CFI R7 SameValue
  100.         CFI R8 SameValue
  101.         CFI R9 SameValue
  102.         CFI R10 SameValue
  103.         CFI R11 SameValue
  104.         CFI R12 Undefined
  105.         CFI R13 Undefined
  106.         CFI R14 Undefined
  107.         CFI R15 Undefined
  108.         CFI EndCommon cfiCommon0
  109.         
  110. // E:projectFaxProgramVson_Bryan_Fax_Conexant_070423filesmain.c
  111. //    1 /************************************************
  112. //    2 Network 3G Fax
  113. //    3 Copyright 2006 by Vson. All rights reserved.
  114. //    4 Author:      Bryan Cai
  115. //    5 Date:        2006.09.04
  116. //    6 Description: Carry out a Network 3G Fax with Conexant CX06833.
  117. //    7 Note:
  118. //    8 Identifier abbreviation: 
  119. //    9                          c-const
  120. //   10                          a-array
  121. //   11                          p-pointer
  122. //   12                          g-global
  123. //   13                          uc-unsigned char
  124. //   14                          w-unsigned int
  125. //   15                          cnt-count
  126. //   16                          pnt-point
  127. //   17 Update:
  128. //   18       2007.04.12  Bryan      Concise the FaxManager program
  129. //   19       2007.03.20  Bryan      Complete all DTE command function
  130. //   20       2007.03.16  Bryan      Fast exit RxProcess when error occur.
  131. //   21       2007.01.03  Bryan      Add Modem RX parameter set
  132. //   22       2006.12.27  Bryan      add RX multi imagepages
  133. //   23       2006.12.22  Bryan      Flash I/O changed
  134. //   24       2006.11.02  Bryan      program header
  135. //   25 
  136. //   26 ************************************************/
  137. //   27 
  138. //   28 
  139. //   29 #include "includeH.h"
  140.         ASEGN DATA16_AN:DATA:NOROOT,0120H
  141. // unsigned short volatile __data WDTCTL
  142. WDTCTL:
  143.         DS8 2
  144.         ASEGN DATA16_AN:DATA:NOROOT,020H
  145. // unsigned char const volatile __data P1IN
  146. P1IN:
  147.         DS8 1
  148.         ASEGN DATA16_AN:DATA:NOROOT,021H
  149. // unsigned char volatile __data P1OUT
  150. P1OUT:
  151.         DS8 1
  152.         ASEGN DATA16_AN:DATA:NOROOT,022H
  153. // unsigned char volatile __data P1DIR
  154. P1DIR:
  155.         DS8 1
  156.         ASEGN DATA16_AN:DATA:NOROOT,036H
  157. // unsigned char volatile __data P6DIR
  158. P6DIR:
  159.         DS8 1
  160. //   30 
  161. //   31 
  162. //   32 
  163. //   33 //interrupt [USART0TX_VECTOR] void intUartTx(void);
  164. //   34 //interrupt [USART0RX_VECTOR] void intUartRx(void);
  165. //   35 
  166. //   36 /* AT command Set
  167. //   37 unsigned char  ATcmdPrefix[]={0x41,0x54}, ATcmdSuffix[]={0x0D},
  168. //   38                 //ATFS0[]={0x26,0x46,0x53,0x30,0x3d,0x30,0x45,0x31,0x56,0x31,0x51,0x30},
  169. //   39                 //ATS7[]={0x53,0x37,0x3d,0x36,0x30,0x26,0x44,0x33,0x26,0x4b,0x34},
  170. //   40                 //ATX4M1L0[]={0x58,0x34,0x4d,0x31,0x4c,0x30},
  171. //   41                 //FCLASS[]={0x2b,0x46,0x43,0x4c,0x41,0x53,0x53,0x3d,0x31},
  172. //   42                 //FCLASS0[]={0x2b,0x46,0x43,0x4c,0x41,0x53,0x53,0x3d,0x30},
  173. //   43                 
  174. //   44                 
  175. //   45                 ATS0RX[]={0x53,0x30,0x3d,0x30},                
  176. //   46                 DT[]={0x44,0x54,0x39,0x36,0x31,0x31,0x33,0x39,0x35,0x30,0x39},
  177. //   47                 A[]={0x41},
  178. //   48                 //DT[]={0x44,0x54,0x39,0x30,0x37,0x39,0x37,0x36,0x39,0x30,0x35,0x31,0x39,0x31},     
  179. //   49                 FRH[]={0x2b,0x46,0x52,0x48,0x3d,0x33,0x0d},  
  180. //   50                 FTH[]={0x2b,0x46,0x54,0x48,0x3d,0x33,0x0d},
  181. //   51                 //FTHNSF[]={0xff,0x03,0x54,0x47,0x46,0x33,0x36,0x36,0x43,0x00,0x77,0x9C,0x10,0x03},
  182. //   52         //for TX 
  183. //   53                 FTHTSI[]={0xff,0x03,0x43,0x78,0x61,0x46,0x10,0x03},
  184. //   54                 FTHDCS[]={0xff,0x13,0x83,0x00,0x46,0x78,0x10,0x03},//for TX
  185. //   55         //for RX
  186. //   56                 //FTHCSI[]={0xff,0x03,0x40,0x78,0x61,0x46,0x10,0x03},//@Fax
  187. //   57                 FTHCSI[]={0xff,0x03,0x40,0x36,0x33,0x38,0x10,0x03},//@836
  188. //   58                 FTHDIS[]={0xff,0x13,0x80,0x00,0xee,0x78,0x10,0x03},//for RX ee 78
  189. //   59                 //FTHDIS[]={0xff,0x13,0x80,0x00,0x46,0x70,0x10,0x03},//for RX ee 78
  190. //   60                 //FTHCSI[]={0xff,0x03,0x40,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x36,0x33,0x38,0x10,0x03},//@Fax
  191. //   61                 //FTHDIS[]={0xff,0x13,0x80,0x00,0xee,0x78,0x10,0x03},//for RX ee 78
  192. //   62                 FTHCFR[]={0xff,0x13,0x84,0x10,0x03},// Confirmation to receive  MSB 21H LSB 83H
  193. //   63                 FTHMCF[]={0xff,0x13,0x8C,0x10,0x03},// Message Confirmation MSB 31H LSB 8CH
  194. //   64                 FTHEOP[]={0xff,0x13,0x2f,0x10,0x03},
  195. //   65                 FTHDNC[]={0xff,0x13,0xfb,0x10,0x03},
  196. //   66                 FTHEOM[]={0xff,0x03,0x43,0x78,0x61,0x46,0x10,0x03},
  197. //   67                 FTS[]={0x2b,0x46,0x54,0x53,0x3d,0x38},  
  198. //   68                 FTM[]={0x2b,0x46,0x54,0x4d,0x3d,0x39,0x36},
  199. //   69                 //FRM[]={0x2b,0x46,0x52,0x4d,0x3d,0x31,0x34,0x35},
  200. //   70                 FRM[]={0x2b,0x46,0x52,0x4d,0x3d,0x39,0x36},  
  201. //   71                 H0[]={0x48,0x00}, 
  202. //   72                 TerminalFlag[]={0x10,0x03};
  203. //   73 */
  204. //   74 
  205. //   75 
  206. //   76 
  207.         RSEG CODE:CODE:NOROOT(1)
  208. //   77 void main(void)
  209. main:
  210.         CFI Block cfiBlock0 Using cfiCommon0
  211.         CFI Function main
  212. //   78 {     
  213.         FUNCALL main, IoInitial
  214.         LOCFRAME CSTACK, 30, STACK
  215.         FUNCALL main, InitUART
  216.         LOCFRAME CSTACK, 30, STACK
  217.         FUNCALL main, Flash_Reset
  218.         LOCFRAME CSTACK, 30, STACK
  219.         FUNCALL main, FLASH_READ_ID
  220.         LOCFRAME CSTACK, 30, STACK
  221.         FUNCALL main, Delay2000ms
  222.         LOCFRAME CSTACK, 30, STACK
  223.         FUNCALL main, ReadLast16BytesFromFlashMemoryArea
  224.         LOCFRAME CSTACK, 30, STACK
  225.         FUNCALL main, ViewCommunicationTX
  226.         LOCFRAME CSTACK, 30, STACK
  227.         FUNCALL main, ATcmdDelay
  228.         LOCFRAME CSTACK, 30, STACK
  229.         FUNCALL main, ATcmdDelay
  230.         LOCFRAME CSTACK, 30, STACK
  231.         FUNCALL main, SendATcmd
  232.         LOCFRAME CSTACK, 30, STACK
  233.         FUNCALL main, ATcmdDelay
  234.         LOCFRAME CSTACK, 30, STACK
  235.         FUNCALL main, ATcmdDelay
  236.         LOCFRAME CSTACK, 30, STACK
  237.         FUNCALL main, SendATcmdModemSoftReset
  238.         LOCFRAME CSTACK, 30, STACK
  239.         FUNCALL main, ATcmdDelay
  240.         LOCFRAME CSTACK, 30, STACK
  241.         FUNCALL main, ATcmdDelay
  242.         LOCFRAME CSTACK, 30, STACK
  243.         FUNCALL main, ATcmdDelay
  244.         LOCFRAME CSTACK, 30, STACK
  245.         FUNCALL main, SendATcmd
  246.         LOCFRAME CSTACK, 30, STACK
  247.         FUNCALL main, ATcmdDelay
  248.         LOCFRAME CSTACK, 30, STACK
  249.         FUNCALL main, ATcmdDelay
  250.         LOCFRAME CSTACK, 30, STACK
  251.         FUNCALL main, SendATcmdModemSoftReset
  252.         LOCFRAME CSTACK, 30, STACK
  253.         FUNCALL main, ATcmdDelay
  254.         LOCFRAME CSTACK, 30, STACK
  255.         FUNCALL main, ATcmdDelay
  256.         LOCFRAME CSTACK, 30, STACK
  257.         FUNCALL main, KeyScan
  258.         LOCFRAME CSTACK, 30, STACK
  259.         FUNCALL main, ViewCommunicationTX
  260.         LOCFRAME CSTACK, 30, STACK
  261.         FUNCALL main, FaxRXProcess
  262.         LOCFRAME CSTACK, 30, STACK
  263.         FUNCALL main, ViewCommunicationTX
  264.         LOCFRAME CSTACK, 30, STACK
  265.         FUNCALL main, FaxRxBufRawdata2PCFromSoftUart
  266.         LOCFRAME CSTACK, 30, STACK
  267.         FUNCALL main, FaxRxBufRawdata2Flash
  268.         LOCFRAME CSTACK, 30, STACK
  269.         FUNCALL main, ViewCommunicationTX
  270.         LOCFRAME CSTACK, 30, STACK
  271.         FUNCALL main, ReadAndWriteViewDataMemory
  272.         LOCFRAME CSTACK, 30, STACK
  273.         FUNCALL main, ATcmdDelay
  274.         LOCFRAME CSTACK, 30, STACK
  275.         FUNCALL main, SendATcmdModemSoftReset
  276.         LOCFRAME CSTACK, 30, STACK
  277.         FUNCALL main, ATcmdDelay
  278.         LOCFRAME CSTACK, 30, STACK
  279.         FUNCALL main, ATcmdDelay
  280.         LOCFRAME CSTACK, 30, STACK
  281.         FUNCALL main, SoftUartRxOneFrame
  282.         LOCFRAME CSTACK, 32, STACK
  283.         FUNCALL main, DteGetModemBus
  284.         LOCFRAME CSTACK, 30, STACK
  285.         FUNCALL main, SoftUartTxOneFrame
  286.         LOCFRAME CSTACK, 30, STACK
  287.         FUNCALL main, DteReturnModemBus
  288.         LOCFRAME CSTACK, 30, STACK
  289.         FUNCALL main, SoftUartTxOneFrame
  290.         LOCFRAME CSTACK, 30, STACK
  291.         FUNCALL main, DteGetFaxList
  292.         LOCFRAME CSTACK, 30, STACK
  293.         FUNCALL main, DteGetOneFax
  294.         LOCFRAME CSTACK, 30, STACK
  295.         FUNCALL main, ViewCommunicationTX
  296.         LOCFRAME CSTACK, 30, STACK
  297.         FUNCALL main, ReadAndWriteViewDataMemory
  298.         LOCFRAME CSTACK, 30, STACK
  299.         FUNCALL main, ViewCommunicationTX
  300.         LOCFRAME CSTACK, 30, STACK
  301.         FUNCALL main, FlashFormat
  302.         LOCFRAME CSTACK, 30, STACK
  303.         FUNCALL main, CheckInvalidBlock
  304.         LOCFRAME CSTACK, 30, STACK
  305.         FUNCALL main, SoftUartTxOneFrame
  306.         LOCFRAME CSTACK, 30, STACK
  307.         FUNCALL main, SetCSIandDIS
  308.         LOCFRAME CSTACK, 30, STACK
  309.         FUNCALL main, DceResponsePc
  310.         LOCFRAME CSTACK, 30, STACK
  311. PUSH.W R10
  312.         CFI R10 Frame(CFA, -4)
  313.         CFI CFA SP+4
  314. PUSH.W R11
  315.         CFI R11 Frame(CFA, -6)
  316.         CFI CFA SP+6
  317. PUSH.W R8
  318.         CFI R8 Frame(CFA, -8)
  319.         CFI CFA SP+8
  320. PUSH.W R9
  321.         CFI R9 Frame(CFA, -10)
  322.         CFI CFA SP+10
  323. PUSH.W R6
  324.         CFI R6 Frame(CFA, -12)
  325.         CFI CFA SP+12
  326. PUSH.W R7
  327.         CFI R7 Frame(CFA, -14)
  328.         CFI CFA SP+14
  329. PUSH.W R4
  330.         CFI R4 Frame(CFA, -16)
  331.         CFI CFA SP+16
  332. PUSH.W R5
  333.         CFI R5 Frame(CFA, -18)
  334.         CFI CFA SP+18
  335. SUB.W #0xc, SP
  336.         CFI CFA SP+30
  337. //   79 
  338. //   80         
  339. //   81       unsigned int wGeneralCount = 0, 
  340. MOV.W #0x0, 0x0(SP)
  341. //   82                    wOKcount=0, 
  342. MOV.W #0x0, 0x8(SP)
  343. //   83                    wNotOKcount=0, 
  344. MOV.W #0x0, 0xa(SP)
  345. //   84                    wOneFaxHead=0, 
  346. MOV.W #0x0, 0x2(SP)
  347. //   85                    wOneFaxRear=0,
  348. MOV.W #0x0, 0x4(SP)
  349. //   86                    wGeneralVar=0;
  350. MOV.W #0x0, R10
  351. //   87       unsigned char
  352. //   88                     ucRxIndex3=0,ucRxIndex2=0,
  353. MOV.B #0x0, R5
  354. MOV.B #0x0, R4
  355. //   89                     ucRxIndex1=0,ucRxIndex0=0,
  356. MOV.B #0x0, R11
  357. MOV.B #0x0, R8
  358. //   90                     ucSoftUartRxCnt=0;
  359. MOV.B #0x0, R6
  360. //   91       //unsigned char ucGeneralCount=1;
  361. //   92       unsigned char ucGeneralCnt=0;
  362. MOV.B #0x0, 0x6(SP)
  363. //   93       unsigned char ucRingNum=0;
  364. MOV.B #0x0, R7
  365. //   94       unsigned char ucRxIndex=0;
  366. MOV.B #0x0, R9
  367. //   95       //unsigned char ucSoftUartRxData=0;
  368. //   96       //unsigned char ucFlashWriteData;
  369. //   97       //unsigned char ucFlashColumnAddCnt;
  370. //   98       //unsigned int wGeneralCnt;
  371. //   99       //unsigned int wBlockAddress=0,wPageAddress=0;
  372. //  100       WDTCTL=WDTPW+WDTHOLD;              //close watch dog
  373. MOV.W #0x5a80, &0x120
  374. //  101       
  375. //  102 /*
  376. //  103       FLASH_CON_PORT_OUT |= CE; //COMMAND_LATCH_INTO_INITAIL all control disable
  377. //  104        FLASH_CON_PORT_OUT &= ~CE;
  378. //  105       FLASH_CON_PORT_OUT |= WE;
  379. //  106        FLASH_CON_PORT_OUT &= ~WE;
  380. //  107       FLASH_CON_PORT_OUT |= RE;
  381. //  108        FLASH_CON_PORT_OUT &= ~RE;
  382. //  109         FLASH_CON_PORT_OUT |= CLE;
  383. //  110       FLASH_CON_PORT_OUT &= ~CLE;
  384. //  111        FLASH_CON_PORT_OUT |= ALE;
  385. //  112       FLASH_CON_PORT_OUT &= ~ALE;
  386. //  113 */
  387. //  114       //while (1) _NOP(); 
  388. //  115       IoInitial();
  389. CALL #IoInitial
  390. //  116       InitUART();
  391. CALL #InitUART
  392. //  117       Flash_Reset();
  393. CALL #Flash_Reset
  394. //  118       FLASH_READ_ID();
  395. CALL #FLASH_READ_ID
  396. //  119       //while (0) aucUartRxBuf[ucRxIndex++]=SoftUartRxOneFrame();
  397. //  120       SOFTUART_PORT_DIRECTION |= bitSOFTUARTTX;
  398. BIS.B #0x1, &0x36
  399. //  121 /*
  400. //  122       while (0)
  401. //  123       {
  402. //  124       SOFTUART_PORT_OUT |= bitSOFTUARTTX;
  403. //  125       delay1us(20);
  404. //  126       SOFTUART_PORT_OUT &= ~bitSOFTUARTTX;
  405. //  127       delay1us(8);
  406. //  128       SOFTUART_PORT_OUT |= bitSOFTUARTTX;
  407. //  129       for (ucGeneralCnt=0;ucGeneralCnt<8;ucGeneralCnt++)
  408. //  130      {
  409. //  131         delay1us(2);//SoftUartDelayHalf();
  410. //  132         ucSoftUartRxData=ucSoftUartRxData>>1;
  411. //  133         //if ((SOFTUART_PORT_IN & bitSOFTUARTRX) == bitSOFTUARTRX)
  412. //  134           //ucSoftUartRxData |= BIT7;//BIT7;//(1<<ucGeneralCount);//set   Rx bit
  413. //  135         //else
  414. //  136           //{ucSoftUartRxData &= ~BIT7;__no_operation();__no_operation();__no_operation();}//~BIT7;//~(1<<ucGeneralCount);//set   Rx bit
  415. //  137         if ((SOFTUART_PORT_OUT & bitSOFTUARTTX) != bitSOFTUARTTX)
  416. //  138           {SOFTUART_PORT_OUT |= bitSOFTUARTTX;} //set   Tx bit
  417. //  139         else
  418. //  140           {SOFTUART_PORT_OUT &= ~bitSOFTUARTTX;__no_operation();__no_operation();}
  419. //  141         delay1us(2);//SoftUartDelayHalf();
  420. //  142         __no_operation();
  421. //  143         __no_operation();
  422. //  144         __no_operation();
  423. //  145         __no_operation();
  424. //  146         __no_operation();
  425. //  147           
  426. //  148       }
  427. //  149       
  428. //  150       SOFTUART_PORT_OUT &= ~bitSOFTUARTTX;
  429. //  151       delay1us(8);
  430. //  152       SOFTUART_PORT_OUT |= bitSOFTUARTTX;
  431. //  153      }
  432. //  154      */
  433. //  155       Delay2000ms();
  434. CALL #Delay2000ms
  435. //  156       
  436. //  157       ReadLastViewData();
  437. MOV.B #0x29, R14
  438. MOV.B #0x28, R12
  439. CALL #ReadLast16BytesFromFlashMemoryArea
  440. //  158       //ReadLast16BytesFromFlashMemoryArea(cstViewDataAreaStartBlockNum,cstViewDataAreaOverBlockNum);
  441. //  159        
  442. //  160       ucRxIndex=gucUartRxCnt;
  443. MOV.B &gucUartRxCnt, R9
  444. //  161       if ((gucGeneralStatus & bitReadFlashMemoryOK) == bitReadFlashMemoryOK)
  445. BIT.B #0x20, &gucGeneralStatus
  446. JNC ??main_10
  447. //  162       {
  448. //  163        gucViewRingNum = aucUartRxBuf[ucRxIndex++];
  449. MOV.B R9, R14
  450. AND.W #0xff, R14
  451. MOV.B aucUartRxBuf(R14), &aucViewData + 0x6
  452. ADD.B #0x1, R9
  453. //  164        gucViewStaticStatus = aucUartRxBuf[ucRxIndex++];
  454. MOV.B R9, R14
  455. AND.W #0xff, R14
  456. MOV.B aucUartRxBuf(R14), &aucViewData + 0x7
  457. ADD.B #0x1, R9
  458. //  165        gucViewDynamicStatus = aucUartRxBuf[ucRxIndex++];
  459. MOV.B R9, R14
  460. AND.W #0xff, R14
  461. MOV.B aucUartRxBuf(R14), &aucViewData + 0x8
  462. ADD.B #0x1, R9
  463. //  166        gucViewDceNewFaxNum = aucUartRxBuf[ucRxIndex++];
  464. MOV.B R9, R14
  465. AND.W #0xff, R14
  466. MOV.B aucUartRxBuf(R14), &aucViewData + 0x9
  467. ADD.B #0x1, R9
  468. //  167       }
  469. //  168       ViewCommunicationTX(0);
  470. ??main_10:
  471. MOV.B #0x0, R12
  472. CALL #ViewCommunicationTX
  473. //  169       
  474. //  170       //while (1) wGeneralCount = gwGeneralPageAddress>>6;
  475. //  171       //while (1) _NOP();
  476. //  172 /*
  477. //  173       while (1) 
  478. //  174       {
  479. //  175        ViewCommunicationTX(1); 
  480. //  176        ViewCommunicationRX();
  481. //  177       }
  482. //  178 */
  483. //  179 
  484. //  180  
  485. //  181 
  486. //  182    
  487. //  183      
  488. //  184      //while (1)
  489. //  185      //{
  490. //  186      //Initial Device  Reset Modem
  491. //  187       ModemResetPortDir |= bitModemHardwareReset;
  492. BIS.B #0x40, &0x22
  493. //  188       ModemResetCon &= ~bitModemHardwareReset;
  494. BIC.B #0x40, &0x21
  495. //  189       ATcmdDelay();
  496. CALL #ATcmdDelay
  497. //  190       ModemResetPortDir &= ~bitModemHardwareReset;
  498. BIC.B #0x40, &0x22
  499. //  191       ModemResetCon |= bitModemHardwareReset;
  500. BIS.B #0x40, &0x21
  501. //  192      while (1)
  502. //  193      {
  503. //  194            
  504. //  195         ATcmdDelay();
  505. ??main_0:
  506. CALL #ATcmdDelay
  507. //  196         SendATcmd();          
  508. CALL #SendATcmd
  509. //  197         ATcmdDelay();
  510. CALL #ATcmdDelay
  511. //  198         ATcmdDelay();
  512. CALL #ATcmdDelay
  513. //  199         if ((0x0d!=aucUartRxBuf[ucRxIndex0])&&(0x4B!=aucUartRxBuf[ucRxIndex1]))
  514. MOV.B R8, R14
  515. AND.W #0xff, R14
  516. CMP.B #0xd, aucUartRxBuf(R14)
  517. JEQ ??main_0
  518. MOV.B R11, R14
  519. AND.W #0xff, R14
  520. CMP.B #0x4b, aucUartRxBuf(R14)
  521. JEQ ??main_0
  522. //  200         {
  523. //  201         SendATcmdModemSoftReset();
  524. CALL #SendATcmdModemSoftReset
  525. //  202         ATcmdDelay();
  526. CALL #ATcmdDelay
  527. //  203         ATcmdDelay();
  528. CALL #ATcmdDelay
  529. //  204       
  530. //  205         ucRxIndex1=gucUartRxCnt-3;
  531. MOV.B #0xfd, R14
  532. ADD.B &gucUartRxCnt, R14
  533. MOV.B R14, R11
  534. //  206         ucRxIndex0=gucUartRxCnt-2;
  535. MOV.B #0xfe, R14
  536. ADD.B &gucUartRxCnt, R14
  537. MOV.B R14, R8
  538. //  207         if ((0x0d==aucUartRxBuf[ucRxIndex0])&&(0x4B==aucUartRxBuf[ucRxIndex1]))
  539. MOV.B R8, R14
  540. AND.W #0xff, R14
  541. CMP.B #0xd, aucUartRxBuf(R14)
  542. JNE ??main_0
  543. MOV.B R11, R14
  544. AND.W #0xff, R14
  545. CMP.B #0x4b, aucUartRxBuf(R14)
  546. JNE ??main_0
  547. //  208           {break;}
  548. //  209         }
  549. //  210      }//while
  550. //  211      while (1)
  551. //  212      {
  552. //  213       ATcmdDelay();
  553. ??main_2:
  554. CALL #ATcmdDelay
  555. //  214       SendATcmd();          //a bug of Sep.22 If this AT is not added, the ring can't receive sometimes.
  556. CALL #SendATcmd
  557. //  215       ATcmdDelay();
  558. CALL #ATcmdDelay
  559. //  216       ATcmdDelay();
  560. CALL #ATcmdDelay
  561. //  217     
  562. //  218       while (wGeneralCount++<0xffff)
  563. ??main_1:
  564. MOV.W 0x0(SP), R14
  565. MOV.W #0x1, R15
  566. ADD.W R14, R15
  567. MOV.W R15, 0x0(SP)
  568. CMP.W #0xffff, R14
  569. JEQ ??main_11
  570. //  219       {
  571. //  220        ucRxIndex1=gucUartRxCnt-3;
  572. MOV.B #0xfd, R14
  573. ADD.B &gucUartRxCnt, R14
  574. MOV.B R14, R11
  575. //  221        ucRxIndex0=gucUartRxCnt-2;
  576. MOV.B #0xfe, R14
  577. ADD.B &gucUartRxCnt, R14
  578. MOV.B R14, R8
  579. //  222        if ((0x0d==aucUartRxBuf[ucRxIndex0])&&(0x4B==aucUartRxBuf[ucRxIndex1]))
  580. AND.W #0xff, R8
  581. CMP.B #0xd, aucUartRxBuf(R8)
  582. JNE ??main_12
  583. AND.W #0xff, R11
  584. CMP.B #0x4b, aucUartRxBuf(R11)
  585. JNE ??main_12
  586. //  223         {wOKcount++;break;}
  587. ADD.W #0x1, 0x8(SP)
  588. JMP ??main_11
  589. //  224        if (wGeneralCount==0xffff)
  590. ??main_12:
  591. CMP.W #0xffff, 0x0(SP)
  592. JNE ??main_1
  593. //  225        {    
  594. //  226         //wGeneralCount=0;
  595. //  227         wNotOKcount++;
  596. ADD.W #0x1, 0xa(SP)
  597. //  228         SendATcmdModemSoftReset();
  598. CALL #SendATcmdModemSoftReset
  599. //  229         ATcmdDelay();
  600. CALL #ATcmdDelay
  601. //  230         ATcmdDelay();
  602. CALL #ATcmdDelay
  603. JMP ??main_1
  604. //  231        }//if
  605. //  232       }//while
  606. //  233       ucRxIndex1=gucUartRxCnt-3;
  607. ??main_11:
  608. MOV.B #0xfd, R14
  609. ADD.B &gucUartRxCnt, R14
  610. MOV.B R14, R11
  611. //  234       ucRxIndex0=gucUartRxCnt-2;
  612. MOV.B #0xfe, R14
  613. ADD.B &gucUartRxCnt, R14
  614. MOV.B R14, R8
  615. //  235       if ((0x0d==aucUartRxBuf[ucRxIndex0])&&(0x4B==aucUartRxBuf[ucRxIndex1]))
  616. AND.W #0xff, R8
  617. CMP.B #0xd, aucUartRxBuf(R8)
  618. JNE ??main_2
  619. AND.W #0xff, R11
  620. CMP.B #0x4b, aucUartRxBuf(R11)
  621. JNE ??main_2
  622. //  236         {wOKcount++;break;}
  623. ADD.W #0x1, 0x8(SP)
  624. //  237      }//while
  625. //  238 
  626. //  239      _NOP();
  627. NOP
  628. //  240      gucGeneralStatus &= ~bitModemActive;
  629. BIC.B #0x2, &gucGeneralStatus
  630. //  241      
  631. //  242      //gucUartRxCnt++;
  632. //  243      //}//while
  633. //  244       
  634. //  245      //Main Circle
  635. //  246      while (1)
  636. //  247      {     
  637. //  248       //Key Scan and Set Parameters
  638. //  249       
  639. //  250       KeyScan();
  640. ??main_7:
  641. CALL #KeyScan
  642. //  251       //}// test keyscan
  643. //  252       //while (1)//test keyscan
  644. //  253       //{//test keyscan
  645. //  254       
  646. //  255       //if Modem active(bitModemActive=0X0002)
  647. //  256          //detect modem
  648. //  257       //else
  649. //  258         //detect PC command through SoftUart
  650. //  259       ucRingNum=0;
  651. MOV.B #0x0, R7
  652. //  260       if ((gucGeneralStatus & bitModemActive) == bitModemActive)
  653. BIT.B #0x2, &gucGeneralStatus
  654. JNC ??main_13
  655. //  261       {             
  656. //  262             while (wGeneralCount++<0xffff)    
  657. ??main_3:
  658. MOV.W 0x0(SP), R14
  659. MOV.W #0x1, R15
  660. ADD.W R14, R15
  661. MOV.W R15, 0x0(SP)
  662. CMP.W #0xffff, R14
  663. JEQ ??main_14
  664. //  263             { 
  665. //  264               ucRxIndex3=gucUartRxCnt-6;
  666. MOV.B #0xfa, R14
  667. ADD.B &gucUartRxCnt, R14
  668. MOV.B R14, R5
  669. //  265               ucRxIndex2=gucUartRxCnt-5;
  670. MOV.B #0xfb, R14
  671. ADD.B &gucUartRxCnt, R14
  672. MOV.B R14, R4
  673. //  266               ucRxIndex1=gucUartRxCnt-4;
  674. MOV.B #0xfc, R14
  675. ADD.B &gucUartRxCnt, R14
  676. MOV.B R14, R11
  677. //  267               ucRxIndex0=gucUartRxCnt-3;
  678. MOV.B #0xfd, R14
  679. ADD.B &gucUartRxCnt, R14
  680. MOV.B R14, R8
  681. //  268               if ((aucUartRxBuf[ucRxIndex0]==0x47)&&(aucUartRxBuf[ucRxIndex1]==0x4e)&&
  682. //  269                   (aucUartRxBuf[ucRxIndex2]==0x49)&&(aucUartRxBuf[ucRxIndex3]==0x52))
  683. AND.W #0xff, R8
  684. CMP.B #0x47, aucUartRxBuf(R8)
  685. JNE ??main_3
  686. AND.W #0xff, R11
  687. CMP.B #0x4e, aucUartRxBuf(R11)
  688. JNE ??main_3
  689. AND.W #0xff, R4
  690. CMP.B #0x49, aucUartRxBuf(R4)
  691. JNE ??main_3
  692. AND.W #0xff, R5
  693. CMP.B #0x52, aucUartRxBuf(R5)
  694. JNE ??main_3
  695. //  270               {
  696. //  271                 gucUartRxCnt+=1;
  697. ADD.B #0x1, &gucUartRxCnt
  698. //  272                 ucRingNum++;
  699. ADD.B #0x1, R7
  700. //  273                 //if AutoMode
  701. //  274                 //{
  702. //  275                 //if Ring Num < Ring Num Max
  703. //  276                     //gucUartRxCnt++; RingNumCnt++;
  704. //  277                 //else
  705. //  278                     //break;
  706. //  279                 //}
  707. //  280                 //else (Manual Mode)
  708. //  281                   //if Receive Start Key Switch On
  709. //  282                   //   break;
  710. //  283                 if ((gucViewStaticStatus & bitViewAutoMode) == bitViewAutoMode) //auto mode
  711. BIT.B #0x10, &aucViewData + 0x7
  712. JNC ??main_5
  713. //  284                  {
  714. //  285                    while (1)
  715. //  286                     {
  716. //  287                    
  717. //  288                       ucRxIndex3=gucUartRxCnt-6;
  718. ??main_4:
  719. MOV.B #0xfa, R14
  720. ADD.B &gucUartRxCnt, R14
  721. MOV.B R14, R5
  722. //  289                         ucRxIndex2=gucUartRxCnt-5;
  723. MOV.B #0xfb, R14
  724. ADD.B &gucUartRxCnt, R14
  725. MOV.B R14, R4
  726. //  290                         ucRxIndex1=gucUartRxCnt-4;
  727. MOV.B #0xfc, R14
  728. ADD.B &gucUartRxCnt, R14
  729. MOV.B R14, R11
  730. //  291                         ucRxIndex0=gucUartRxCnt-3;
  731. MOV.B #0xfd, R14
  732. ADD.B &gucUartRxCnt, R14
  733. MOV.B R14, R8
  734. //  292                         if ((aucUartRxBuf[ucRxIndex0]==0x47)&&(aucUartRxBuf[ucRxIndex1]==0x4e)&&
  735. //  293                             (aucUartRxBuf[ucRxIndex2]==0x49)&&(aucUartRxBuf[ucRxIndex3]==0x52))
  736. AND.W #0xff, R8
  737. CMP.B #0x47, aucUartRxBuf(R8)
  738. JNE ??main_15
  739. AND.W #0xff, R11
  740. CMP.B #0x4e, aucUartRxBuf(R11)
  741. JNE ??main_15
  742. AND.W #0xff, R4
  743. CMP.B #0x49, aucUartRxBuf(R4)
  744. JNE ??main_15
  745. AND.W #0xff, R5
  746. CMP.B #0x52, aucUartRxBuf(R5)
  747. JNE ??main_15
  748. //  294                              {ucRingNum++;gucUartRxCnt++;}// pointer to next imcoming RING
  749. ADD.B #0x1, R7
  750. ADD.B #0x1, &gucUartRxCnt
  751. //  295                         if (ucRingNum>=gucViewRingNum) 
  752. ??main_15:
  753. CMP.B &aucViewData + 0x6, R7
  754. JNC ??main_16
  755. //  296                          {gucGeneralStatus |= bitSendFaxSignalOK;break;}//OK
  756. BIS.B #0x10, &gucGeneralStatus
  757. JMP ??main_14
  758. //  297                         //time overflow quit
  759. //  298                         if (gwTimeOverflowCount++ == 0xffff)
  760. ??main_16:
  761. MOV.W &gwTimeOverflowCount, R14
  762. MOV.W #0x1, R15
  763. ADD.W R14, R15
  764. MOV.W R15, &gwTimeOverflowCount
  765. CMP.W #0xffff, R14
  766. JNE ??main_17
  767. //  299                              gucTimeOverflowCount++;
  768. ADD.B #0x1, &gucTimeOverflowCount
  769. //  300                         if (gucTimeOverflowCount == 20)
  770. ??main_17:
  771. CMP.B #0x14, &gucTimeOverflowCount
  772. JNE ??main_4
  773. //  301                         {gucGeneralStatus &= ~bitSendFaxSignalOK;gucTimeOverflowCount=0;gwTimeOverflowCount=0;break;}
  774. BIC.B #0x10, &gucGeneralStatus
  775. MOV.B #0x0, &gucTimeOverflowCount
  776. MOV.W #0x0, &gwTimeOverflowCount
  777. JMP ??main_14
  778. //  302                     }
  779. //  303                    
  780. //  304                  }//if auto mode end
  781. //  305                 else //manual mode
  782. //  306                  {
  783. //  307                    while (1)
  784. //  308                    {
  785. //  309                      gucUartRxCnt++;// pointer to next imcoming RING
  786. ??main_5:
  787. ADD.B #0x1, &gucUartRxCnt
  788. //  310                      ucRxIndex3=gucUartRxCnt-6;
  789. MOV.B #0xfa, R14
  790. ADD.B &gucUartRxCnt, R14
  791. MOV.B R14, R5
  792. //  311                       ucRxIndex2=gucUartRxCnt-5;
  793. MOV.B #0xfb, R14
  794. ADD.B &gucUartRxCnt, R14
  795. MOV.B R14, R4
  796. //  312                       ucRxIndex1=gucUartRxCnt-4;
  797. MOV.B #0xfc, R14
  798. ADD.B &gucUartRxCnt, R14
  799. MOV.B R14, R11
  800. //  313                       ucRxIndex0=gucUartRxCnt-3;
  801. MOV.B #0xfd, R14
  802. ADD.B &gucUartRxCnt, R14
  803. MOV.B R14, R8
  804. //  314                       if ((aucUartRxBuf[ucRxIndex0]==0x47)&&(aucUartRxBuf[ucRxIndex1]==0x4e)&&
  805. //  315                           (aucUartRxBuf[ucRxIndex2]==0x49)&&(aucUartRxBuf[ucRxIndex3]==0x52))
  806. AND.W #0xff, R8
  807. CMP.B #0x47, aucUartRxBuf(R8)
  808. JNE ??main_18
  809. AND.W #0xff, R11
  810. CMP.B #0x4e, aucUartRxBuf(R11)
  811. JNE ??main_18
  812. AND.W #0xff, R4
  813. CMP.B #0x49, aucUartRxBuf(R4)
  814. JNE ??main_18
  815. AND.W #0xff, R5
  816. CMP.B #0x52, aucUartRxBuf(R5)
  817. JNE ??main_18
  818. //  316                           ucRingNum++;
  819. ADD.B #0x1, R7
  820. //  317                       if (ucRingNum>10)//if RING is over 10, error
  821. ??main_18:
  822. CMP.B #0xb, R7
  823. JNC ??main_19
  824. //  318                       {gucGeneralStatus &= ~bitSendFaxSignalOK;break;}//Not OK
  825. BIC.B #0x10, &gucGeneralStatus
  826. JMP ??main_14
  827. //  319                      if ((KEY_PORT_IN & bitKeySendFaxSignal) != bitKeySendFaxSignal)
  828. ??main_19:
  829. BIT.B #0x10, &0x20
  830. JC ??main_5
  831. //  320                       {gucGeneralStatus |= bitSendFaxSignalOK;break;}//OK      
  832. BIS.B #0x10, &gucGeneralStatus
  833. //  321                    }
  834. //  322                  }//else manual mode end
  835. //  323                 break;
  836. //  324               }//if 
  837. //  325             }//while
  838. //  326             
  839. //  327 
  840. //  328               //receive fax
  841. //  329               if ((gucGeneralStatus & bitSendFaxSignalOK) == bitSendFaxSignalOK)
  842. ??main_14:
  843. BIT.B #0x10, &gucGeneralStatus
  844. JNC ??main_20
  845. //  330                 {
  846. //  331                   gucGeneralStatus &= ~bitSendFaxSignalOK;
  847. BIC.B #0x10, &gucGeneralStatus
  848. //  332                   //Driver Screen Flash Receiving
  849. //  333                   
  850. //  334                   gucViewDynamicStatus |= bitViewReceiving;
  851. BIS.B #0x1, &aucViewData + 0x8
  852. //  335    
  853. //  336                   ViewCommunicationTX(0x01);
  854. MOV.B #0x1, R12
  855. CALL #ViewCommunicationTX
  856. //  337                   //ViewCommunicationRX();
  857. //  338 
  858. //  339                   
  859. //  340                   gucUartRxCnt=0;//
  860. MOV.B #0x0, &gucUartRxCnt
  861. //  341                   gucFrhErrorStatus=0x00;
  862. MOV.B #0x0, &gucFrhErrorStatus
  863. //  342                   FaxRXProcess();
  864. CALL #FaxRXProcess
  865. //  343                   
  866. //  344                   //Off Screen Flash Receiving
  867. //  345                   gucViewDynamicStatus &= ~bitViewReceiving;
  868. BIC.B #0x1, &aucViewData + 0x8
  869. //  346                   ViewCommunicationTX(0x01);
  870. MOV.B #0x1, R12
  871. CALL #ViewCommunicationTX
  872. //  347                   //if receive is OK
  873. //  348                       //write data to flash
  874. //  349                   //FaxRawDataBuf2Flash();
  875. //  350                   //gucRxTxFlag = DTERX;
  876. //  351                   
  877. //  352                   
  878. //  353                   if (gucFrhErrorStatus!=3)
  879. CMP.B #0x3, &gucFrhErrorStatus
  880. JEQ ??main_21
  881. //  354                   {
  882. //  355                     FaxRxBufRawdata2PCFromSoftUart();
  883. CALL #FaxRxBufRawdata2PCFromSoftUart
  884. //  356                     //FaxRxBufRawdata2PCFromUart();
  885. //  357                     FaxRxBufRawdata2Flash();
  886. CALL #FaxRxBufRawdata2Flash
  887. //  358                     //FaxData2PCFromSoftUart();
  888. //  359                     gucViewStaticStatus |= bitViewNewFax;
  889. BIS.B #0x4, &aucViewData + 0x7
  890. //  360                     gucViewDynamicStatus |= bitViewNewFax;
  891. BIS.B #0x4, &aucViewData + 0x8
  892. //  361                     gucViewDceNewFaxNum++;
  893. ADD.B #0x1, &aucViewData + 0x9
  894. //  362                     ViewCommunicationTX(0x01);
  895. MOV.B #0x1, R12
  896. CALL #ViewCommunicationTX
  897. //  363                     ReadAndWriteViewDataMemory();
  898. CALL #ReadAndWriteViewDataMemory
  899. JMP ??main_20
  900. //  364                     
  901. //  365                   }//if
  902. //  366                   else
  903. //  367                    { 
  904. //  368                      ModemResetPortDir |= bitModemHardwareReset;
  905. ??main_21:
  906. BIS.B #0x40, &0x22
  907. //  369                      ModemResetCon &= ~bitModemHardwareReset;
  908. BIC.B #0x40, &0x21
  909. //  370                      ATcmdDelay();
  910. CALL #ATcmdDelay
  911. //  371                      ModemResetPortDir &= ~bitModemHardwareReset;
  912. BIC.B #0x40, &0x22
  913. //  372                      ModemResetCon |= bitModemHardwareReset;
  914. BIS.B #0x40, &0x21
  915. //  373                      //InitUART();
  916. //  374                      while (1) //add at Apr. 13, 2007 can't receive RS232 Data
  917. //  375                      {
  918. //  376                       SendATcmdModemSoftReset();
  919. ??main_6:
  920. CALL #SendATcmdModemSoftReset
  921. //  377                       ATcmdDelay();
  922. CALL #ATcmdDelay
  923. //  378                       ATcmdDelay();
  924. CALL #ATcmdDelay
  925. //  379       
  926. //  380                       ucRxIndex1=gucUartRxCnt-3;
  927. MOV.B #0xfd, R14
  928. ADD.B &gucUartRxCnt, R14
  929. MOV.B R14, R11
  930. //  381                       ucRxIndex0=gucUartRxCnt-2;
  931. MOV.B #0xfe, R14
  932. ADD.B &gucUartRxCnt, R14
  933. MOV.B R14, R8
  934. //  382                       if ((0x0d==aucUartRxBuf[ucRxIndex0])&&(0x4B==aucUartRxBuf[ucRxIndex1]))
  935. AND.W #0xff, R8
  936. CMP.B #0xd, aucUartRxBuf(R8)
  937. JNE ??main_6
  938. AND.W #0xff, R11
  939. CMP.B #0x4b, aucUartRxBuf(R11)
  940. JNE ??main_6
  941. //  383                          {break;}
  942. //  384                      }
  943. //  385                     }//else Rx error
  944. //  386                   //break; //Cant's delete it should be over this while circle //break; //delete at Mar. 16, 2007
  945. //  387                 }//if fax receive end
  946. //  388 
  947. //  389         //Fax receive over, reset bitModemActive for PC detect the new fax
  948. //  390         gucGeneralStatus &= ~bitModemActive;  //fax receiving over 
  949. ??main_20:
  950. BIC.B #0x2, &gucGeneralStatus
  951. JMP ??main_7
  952. //  391       }//if modem active end
  953. //  392       else
  954. //  393       {
  955. //  394         //receive data from SoftUart
  956. //  395         ucSoftUartRxCnt=0;
  957. ??main_13:
  958. MOV.B #0x0, R6
  959. //  396         gucSoftUartRxCnt=0;
  960. MOV.B #0x0, &gucSoftUartRxCnt
  961. //  397         //ucGeneralCnt=0;
  962. //  398         while (1)
  963. //  399         {
  964. //  400            aucSoftUartRxBuf[ucSoftUartRxCnt++]=SoftUartRxOneFrame();//receive one Byte Data
  965. ??main_8:
  966. MOV.B R6, R14
  967. AND.W #0xff, R14
  968. PUSH.W R14
  969.         CFI CFA SP+32
  970. CALL #SoftUartRxOneFrame
  971. POP.W R14
  972.         CFI CFA SP+30
  973. MOV.B R12, aucSoftUartRxBuf(R14)
  974. ADD.B #0x1, R6
  975. //  401            if (ucSoftUartRxCnt>19)//17)//
  976. CMP.B #0x14, R6
  977. JNC ??main_22
  978. //  402              ucSoftUartRxCnt=0;//gucSoftUartRxCnt=0; 2-2=0
  979. MOV.B #0x0, R6
  980. //  403            if (aucSoftUartRxBuf[ucSoftUartRxCnt-1]==0x03 && aucSoftUartRxBuf[ucSoftUartRxCnt-2]==0x10)
  981. ??main_22:
  982. MOV.W #aucSoftUartRxBuf, R14
  983. MOV.B R6, R15
  984. AND.W #0xff, R15
  985. ADD.W R15, R14
  986. CMP.B #0x3, 0xffff(R14)
  987. JNE ??main_23
  988. MOV.W #aucSoftUartRxBuf, R14
  989. MOV.B R6, R15
  990. AND.W #0xff, R15
  991. ADD.W R15, R14
  992. CMP.B #0x10, 0xfffe(R14)
  993. JNE ??main_23
  994. //  404              {gucSoftUartRxCnt=ucSoftUartRxCnt;ucSoftUartRxCnt=0; break;}//{gucSoftUartRxCnt=0; break;} //bug of Apr. 03, 20007
  995. MOV.B R6, &gucSoftUartRxCnt
  996. MOV.B #0x0, R6
  997. JMP ??main_24
  998. //  405            if ((gucGeneralStatus & bitModemActive) == bitModemActive)//if modem active, over this while function
  999. ??main_23:
  1000. BIT.B #0x2, &gucGeneralStatus
  1001. JC ??main_24
  1002. //  406              break;
  1003. //  407          if (((KEY_PORT_IN & bitKeyRingNumDec) != bitKeyRingNumDec) || 
  1004. //  408         ((KEY_PORT_IN & bitKeyRingNumAdd) != bitKeyRingNumAdd) ||
  1005. //  409         ((KEY_PORT_IN & bitKeyAutoMode) != bitKeyAutoMode) ||
  1006. //  410         ((KEY_PORT_IN & bitKeyManualMode) != bitKeyManualMode)) //||
  1007. BIT.B #0x1, &0x20
  1008. JNC ??main_24
  1009. BIT.B #0x2, &0x20
  1010. JNC ??main_24
  1011. BIT.B #0x4, &0x20
  1012. JNC ??main_24
  1013. BIT.B #0x8, &0x20
  1014. JC ??main_8
  1015. //  411         //((KEY_PORT_IN & bitKeySendFaxSignal) != bitKeySendFaxSignal))
  1016. //  412         break;
  1017. //  413         }
  1018. //  414       
  1019. //  415       //Judge the received data
  1020. //  416       
  1021. //  417       //PC get Modem Bus command:ba 23 00 01 10 03
  1022. //  418         if ((aucSoftUartRxBuf[gucSoftUartRxCnt-1]==0x03) && (aucSoftUartRxBuf[gucSoftUartRxCnt-2]==0x10)&&
  1023. //  419             (aucSoftUartRxBuf[gucSoftUartRxCnt-3]==0x01) && (aucSoftUartRxBuf[gucSoftUartRxCnt-4]==0x00)&&
  1024. //  420             (aucSoftUartRxBuf[gucSoftUartRxCnt-5]==0x23) && (aucSoftUartRxBuf[gucSoftUartRxCnt-6]==0xba))
  1025. ??main_24:
  1026. MOV.W #aucSoftUartRxBuf, R15
  1027. MOV.B &gucSoftUartRxCnt, R14
  1028. AND.W #0xff, R14
  1029. ADD.W R14, R15
  1030. CMP.B #0x3, 0xffff(R15)
  1031. JNE ??main_25
  1032. MOV.W #aucSoftUartRxBuf, R15
  1033. MOV.B &gucSoftUartRxCnt, R14
  1034. AND.W #0xff, R14
  1035. ADD.W R14, R15
  1036. CMP.B #0x10, 0xfffe(R15)
  1037. JNE ??main_25
  1038. MOV.W #aucSoftUartRxBuf, R15
  1039. MOV.B &gucSoftUartRxCnt, R14
  1040. AND.W #0xff, R14
  1041. ADD.W R14, R15
  1042. CMP.B #0x1, 0xfffd(R15)
  1043. JNE ??main_25
  1044. MOV.W #aucSoftUartRxBuf, R15
  1045. MOV.B &gucSoftUartRxCnt, R14
  1046. AND.W #0xff, R14
  1047. ADD.W R14, R15
  1048. CMP.B #0x0, 0xfffc(R15)
  1049. JNE ??main_25
  1050. MOV.W #aucSoftUartRxBuf, R15
  1051. MOV.B &gucSoftUartRxCnt, R14
  1052. AND.W #0xff, R14
  1053. ADD.W R14, R15
  1054. CMP.B #0x23, 0xfffb(R15)
  1055. JNE ??main_25
  1056. MOV.W #aucSoftUartRxBuf, R15
  1057. MOV.B &gucSoftUartRxCnt, R14
  1058. AND.W #0xff, R14
  1059. ADD.W R14, R15
  1060. CMP.B #0xba, 0xfffa(R15)
  1061. JNE ??main_25
  1062. //  421         {
  1063. //  422            DteGetModemBus();
  1064. CALL #DteGetModemBus
  1065. //  423            SoftUartTxOneFrame(0xff); 
  1066. MOV.B #0xff, R12
  1067. CALL #SoftUartTxOneFrame
  1068. //  424         }
  1069. //  425       
  1070. //  426       //PC return Modem Bus command:ba 23 00 02 10 03
  1071. //  427         if ((aucSoftUartRxBuf[gucSoftUartRxCnt-1]==0x03) && (aucSoftUartRxBuf[gucSoftUartRxCnt-2]==0x10)&&
  1072. //  428             (aucSoftUartRxBuf[gucSoftUartRxCnt-3]==0x02) && (aucSoftUartRxBuf[gucSoftUartRxCnt-4]==0x00)&&
  1073. //  429             (aucSoftUartRxBuf[gucSoftUartRxCnt-5]==0x23) && (aucSoftUartRxBuf[gucSoftUartRxCnt-6]==0xba))
  1074. ??main_25:
  1075. MOV.W #aucSoftUartRxBuf, R15
  1076. MOV.B &gucSoftUartRxCnt, R14
  1077. AND.W #0xff, R14
  1078. ADD.W R14, R15
  1079. CMP.B #0x3, 0xffff(R15)
  1080. JNE ??main_26
  1081. MOV.W #aucSoftUartRxBuf, R15
  1082. MOV.B &gucSoftUartRxCnt, R14
  1083. AND.W #0xff, R14
  1084. ADD.W R14, R15
  1085. CMP.B #0x10, 0xfffe(R15)
  1086. JNE ??main_26
  1087. MOV.W #aucSoftUartRxBuf, R15
  1088. MOV.B &gucSoftUartRxCnt, R14
  1089. AND.W #0xff, R14
  1090. ADD.W R14, R15
  1091. CMP.B #0x2, 0xfffd(R15)
  1092. JNE ??main_26
  1093. MOV.W #aucSoftUartRxBuf, R15
  1094. MOV.B &gucSoftUartRxCnt, R14
  1095. AND.W #0xff, R14
  1096. ADD.W R14, R15
  1097. CMP.B #0x0, 0xfffc(R15)
  1098. JNE ??main_26
  1099. MOV.W #aucSoftUartRxBuf, R15
  1100. MOV.B &gucSoftUartRxCnt, R14
  1101. AND.W #0xff, R14
  1102. ADD.W R14, R15
  1103. CMP.B #0x23, 0xfffb(R15)
  1104. JNE ??main_26
  1105. MOV.W #aucSoftUartRxBuf, R15
  1106. MOV.B &gucSoftUartRxCnt, R14
  1107. AND.W #0xff, R14
  1108. ADD.W R14, R15
  1109. CMP.B #0xba, 0xfffa(R15)
  1110. JNE ??main_26
  1111. //  430         {
  1112. //  431            DteReturnModemBus();
  1113. CALL #DteReturnModemBus
  1114. //  432            SoftUartTxOneFrame(0xff);
  1115. MOV.B #0xff, R12
  1116. CALL #SoftUartTxOneFrame
  1117. //  433         }
  1118. //  434       
  1119. //  435       //PC get Fax List command:ba 23 00 03 10 03
  1120. //  436         if ((aucSoftUartRxBuf[gucSoftUartRxCnt-1]==0x03)&&(aucSoftUartRxBuf[gucSoftUartRxCnt-2]==0x10)&&
  1121. //  437             (aucSoftUartRxBuf[gucSoftUartRxCnt-3]==0x03)&&(aucSoftUartRxBuf[gucSoftUartRxCnt-4]==0x00)&&
  1122. //  438             (aucSoftUartRxBuf[gucSoftUartRxCnt-5]==0x23)&&(aucSoftUartRxBuf[gucSoftUartRxCnt-6]==0xba))
  1123. ??main_26:
  1124. MOV.W #aucSoftUartRxBuf, R15
  1125. MOV.B &gucSoftUartRxCnt, R14
  1126. AND.W #0xff, R14
  1127. ADD.W R14, R15
  1128. CMP.B #0x3, 0xffff(R15)
  1129. JNE ??main_27
  1130. MOV.W #aucSoftUartRxBuf, R15
  1131. MOV.B &gucSoftUartRxCnt, R14
  1132. AND.W #0xff, R14
  1133. ADD.W R14, R15
  1134. CMP.B #0x10, 0xfffe(R15)
  1135. JNE ??main_27
  1136. MOV.W #aucSoftUartRxBuf, R15
  1137. MOV.B &gucSoftUartRxCnt, R14
  1138. AND.W #0xff, R14
  1139. ADD.W R14, R15
  1140. CMP.B #0x3, 0xfffd(R15)
  1141. JNE ??main_27
  1142. MOV.W #aucSoftUartRxBuf, R15
  1143. MOV.B &gucSoftUartRxCnt, R14
  1144. AND.W #0xff, R14
  1145. ADD.W R14, R15
  1146. CMP.B #0x0, 0xfffc(R15)
  1147. JNE ??main_27
  1148. MOV.W #aucSoftUartRxBuf, R15
  1149. MOV.B &gucSoftUartRxCnt, R14
  1150. AND.W #0xff, R14
  1151. ADD.W R14, R15
  1152. CMP.B #0x23, 0xfffb(R15)
  1153. JNE ??main_27
  1154. MOV.W #aucSoftUartRxBuf, R15
  1155. MOV.B &gucSoftUartRxCnt, R14
  1156. AND.W #0xff, R14
  1157. ADD.W R14, R15
  1158. CMP.B #0xba, 0xfffa(R15)
  1159. JNE ??main_27
  1160. //  439         {
  1161. //  440            DteGetFaxList();
  1162. CALL #DteGetFaxList
  1163. //  441         }
  1164. //  442       
  1165. //  443       //PC get One Fax command:ba 23 00 04 HeadLow HeadHigh RearLow RearHigh 10 03
  1166. //  444         if ((aucSoftUartRxBuf[gucSoftUartRxCnt-1]==0x03)&&(aucSoftUartRxBuf[gucSoftUartRxCnt-2]==0x10)&&
  1167. //  445             (aucSoftUartRxBuf[gucSoftUartRxCnt-7]==0x04)&&(aucSoftUartRxBuf[gucSoftUartRxCnt-8]==0x00)&&
  1168. //  446             (aucSoftUartRxBuf[gucSoftUartRxCnt-9]==0x23)&&(aucSoftUartRxBuf[gucSoftUartRxCnt-10]==0xba))
  1169. ??main_27:
  1170. MOV.W #aucSoftUartRxBuf, R15
  1171. MOV.B &gucSoftUartRxCnt, R14
  1172. AND.W #0xff, R14
  1173. ADD.W R14, R15
  1174. CMP.B #0x3, 0xffff(R15)
  1175. JNE ??main_28
  1176. MOV.W #aucSoftUartRxBuf, R15
  1177. MOV.B &gucSoftUartRxCnt, R14
  1178. AND.W #0xff, R14
  1179. ADD.W R14, R15
  1180. CMP.B #0x10, 0xfffe(R15)
  1181. JNE ??main_28
  1182. MOV.W #aucSoftUartRxBuf, R15
  1183. MOV.B &gucSoftUartRxCnt, R14
  1184. AND.W #0xff, R14
  1185. ADD.W R14, R15
  1186. CMP.B #0x4, 0xfff9(R15)
  1187. JNE ??main_28
  1188. MOV.W #aucSoftUartRxBuf, R15
  1189. MOV.B &gucSoftUartRxCnt, R14
  1190. AND.W #0xff, R14
  1191. ADD.W R14, R15
  1192. CMP.B #0x0, 0xfff8(R15)
  1193. JNE ??main_28
  1194. MOV.W #aucSoftUartRxBuf, R15
  1195. MOV.B &gucSoftUartRxCnt, R14
  1196. AND.W #0xff, R14
  1197. ADD.W R14, R15
  1198. CMP.B #0x23, 0xfff7(R15)
  1199. JNE ??main_28
  1200. MOV.W #aucSoftUartRxBuf, R15
  1201. MOV.B &gucSoftUartRxCnt, R14
  1202. AND.W #0xff, R14
  1203. ADD.W R14, R15
  1204. CMP.B #0xba, 0xfff6(R15)
  1205. JNE ??main_28
  1206. //  447         {
  1207. //  448          
  1208. //  449            if (gucFrhErrorStatus==0)
  1209. CMP.B #0x0, &gucFrhErrorStatus
  1210. JNE ??main_28
  1211. //  450            {
  1212. //  451              ucRxIndex1=gucSoftUartRxCnt-6;//Low  Byte
  1213. MOV.B #0xfa, R14
  1214. ADD.B &gucSoftUartRxCnt, R14
  1215. MOV.B R14, R11
  1216. //  452              ucRxIndex0=gucSoftUartRxCnt-5;//High Byte
  1217. MOV.B #0xfb, R14
  1218. ADD.B &gucSoftUartRxCnt, R14
  1219. MOV.B R14, R8
  1220. //  453              wGeneralVar=aucSoftUartRxBuf[ucRxIndex0];
  1221. MOV.B R8, R14
  1222. AND.W #0xff, R14
  1223. MOV.B aucSoftUartRxBuf(R14), R14
  1224. AND.W #0xff, R14
  1225. MOV.W R14, R10
  1226. //  454              wOneFaxHead=(wGeneralVar<<8) | aucSoftUartRxBuf[ucRxIndex1];
  1227. MOV.W R10, R15
  1228. AND.W #0xff, R15
  1229. SWPB R15
  1230. MOV.B R11, R14
  1231. AND.W #0xff, R14
  1232. MOV.B aucSoftUartRxBuf(R14), R14
  1233. AND.W #0xff, R14
  1234. BIS.W R14, R15
  1235. MOV.W R15, 0x2(SP)
  1236. //  455            
  1237. //  456              ucRxIndex1=gucSoftUartRxCnt-4;//Low  Byte
  1238. MOV.B #0xfc, R14
  1239. ADD.B &gucSoftUartRxCnt, R14
  1240. MOV.B R14, R11
  1241. //  457              ucRxIndex0=gucSoftUartRxCnt-3;//High Byte
  1242. MOV.B #0xfd, R14
  1243. ADD.B &gucSoftUartRxCnt, R14
  1244. MOV.B R14, R8
  1245. //  458              wGeneralVar=aucSoftUartRxBuf[ucRxIndex0];
  1246. MOV.B R8, R14
  1247. AND.W #0xff, R14
  1248. MOV.B aucSoftUartRxBuf(R14), R14
  1249. AND.W #0xff, R14
  1250. MOV.W R14, R10
  1251. //  459              wOneFaxRear=(wGeneralVar<<8) | aucSoftUartRxBuf[ucRxIndex1];
  1252. MOV.W R10, R15
  1253. AND.W #0xff, R15
  1254. SWPB R15
  1255. MOV.B R11, R14
  1256. AND.W #0xff, R14
  1257. MOV.B aucSoftUartRxBuf(R14), R14
  1258. AND.W #0xff, R14
  1259. BIS.W R14, R15
  1260. MOV.W R15, 0x4(SP)
  1261. //  460            
  1262. //  461              DteGetOneFax(wOneFaxHead, wOneFaxRear);
  1263. MOV.W 0x4(SP), R14
  1264. MOV.W 0x2(SP), R12
  1265. CALL #DteGetOneFax
  1266. //  462              if (gucViewDceNewFaxNum>0) 
  1267. CMP.B #0x1, &aucViewData + 0x9
  1268. JNC ??main_29
  1269. //  463               {
  1270. //  464               gucViewDceNewFaxNum--;// for DCE check the new fax
  1271. ADD.B #0xff, &aucViewData + 0x9
  1272. //  465                 gucViewStaticStatus |= bitViewNewFax;
  1273. BIS.B #0x4, &aucViewData + 0x7
  1274. //  466                 gucViewDynamicStatus |= bitViewNewFax;
  1275. BIS.B #0x4, &aucViewData + 0x8
  1276. JMP ??main_30
  1277. //  467               }
  1278. //  468              else
  1279. //  469               {gucViewStaticStatus &= ~bitViewNewFax;}
  1280. ??main_29:
  1281. BIC.B #0x4, &aucViewData + 0x7
  1282. //  470              
  1283. //  471              ViewCommunicationTX(0x01);
  1284. ??main_30:
  1285. MOV.B #0x1, R12
  1286. CALL #ViewCommunicationTX
  1287. //  472              ReadAndWriteViewDataMemory();
  1288. CALL #ReadAndWriteViewDataMemory
  1289. //  473            }
  1290. //  474         }
  1291. //  475         
  1292. //  476       //PC delete One Fax command:ba 23 00 05 HeadLow HeadHigh RearLow RearHigh 10 03
  1293. //  477         if ((aucSoftUartRxBuf[gucSoftUartRxCnt-1]==0x03)&&(aucSoftUartRxBuf[gucSoftUartRxCnt-2]==0x10)&&
  1294. //  478             (aucSoftUartRxBuf[gucSoftUartRxCnt-7]==0x05)&&(aucSoftUartRxBuf[gucSoftUartRxCnt-8]==0x00)&&
  1295. //  479             (aucSoftUartRxBuf[gucSoftUartRxCnt-9]==0x23)&&(aucSoftUartRxBuf[gucSoftUartRxCnt-10]==0xba))
  1296. ??main_28:
  1297. MOV.W #aucSoftUartRxBuf, R15
  1298. MOV.B &gucSoftUartRxCnt, R14
  1299. AND.W #0xff, R14
  1300. ADD.W R14, R15
  1301. CMP.B #0x3, 0xffff(R15)
  1302. JNE ??main_31
  1303. MOV.W #aucSoftUartRxBuf, R15
  1304. MOV.B &gucSoftUartRxCnt, R14
  1305. AND.W #0xff, R14
  1306. ADD.W R14, R15
  1307. CMP.B #0x10, 0xfffe(R15)
  1308. JNE ??main_31
  1309. MOV.W #aucSoftUartRxBuf, R15
  1310. MOV.B &gucSoftUartRxCnt, R14
  1311. AND.W #0xff, R14
  1312. ADD.W R14, R15
  1313. CMP.B #0x5, 0xfff9(R15)
  1314. JNE ??main_31
  1315. MOV.W #aucSoftUartRxBuf, R15
  1316. MOV.B &gucSoftUartRxCnt, R14
  1317. AND.W #0xff, R14
  1318. ADD.W R14, R15
  1319. CMP.B #0x0, 0xfff8(R15)
  1320. JNE ??main_31
  1321. MOV.W #aucSoftUartRxBuf, R15
  1322. MOV.B &gucSoftUartRxCnt, R14
  1323. AND.W #0xff, R14
  1324. ADD.W R14, R15
  1325. CMP.B #0x23, 0xfff7(R15)
  1326. JNE ??main_31
  1327. MOV.W #aucSoftUartRxBuf, R15
  1328. MOV.B &gucSoftUartRxCnt, R14
  1329. AND.W #0xff, R14
  1330. ADD.W R14, R15
  1331. CMP.B #0xba, 0xfff6(R15)
  1332. JNE ??main_31
  1333. //  480         {
  1334. //  481          
  1335. //  482            if (gucFrhErrorStatus==0)
  1336. CMP.B #0x0, &gucFrhErrorStatus
  1337. JNE ??main_31
  1338. //  483            {
  1339. //  484              ucRxIndex1=gucSoftUartRxCnt-6;//Low  Byte
  1340. MOV.B #0xfa, R14
  1341. ADD.B &gucSoftUartRxCnt, R14
  1342. MOV.B R14, R11
  1343. //  485              ucRxIndex0=gucSoftUartRxCnt-5;//High Byte
  1344. MOV.B #0xfb, R14
  1345. ADD.B &gucSoftUartRxCnt, R14
  1346. MOV.B R14, R8
  1347. //  486              wGeneralVar=aucSoftUartRxBuf[ucRxIndex0];
  1348. MOV.B R8, R14
  1349. AND.W #0xff, R14
  1350. MOV.B aucSoftUartRxBuf(R14), R14
  1351. AND.W #0xff, R14
  1352. MOV.W R14, R10
  1353. //  487              wOneFaxHead=(wGeneralVar<<8) | aucSoftUartRxBuf[ucRxIndex1];
  1354. MOV.W R10, R15
  1355. AND.W #0xff, R15
  1356. SWPB R15
  1357. MOV.B R11, R14
  1358. AND.W #0xff, R14
  1359. MOV.B aucSoftUartRxBuf(R14), R14
  1360. AND.W #0xff, R14
  1361. BIS.W R14, R15
  1362. MOV.W R15, 0x2(SP)
  1363. //  488            
  1364. //  489              ucRxIndex1=gucSoftUartRxCnt-4;//Low  Byte
  1365. MOV.B #0xfc, R14
  1366. ADD.B &gucSoftUartRxCnt, R14
  1367. MOV.B R14, R11
  1368. //  490              ucRxIndex0=gucSoftUartRxCnt-3;//High Byte
  1369. MOV.B #0xfd, R14
  1370. ADD.B &gucSoftUartRxCnt, R14
  1371. MOV.B R14, R8
  1372. //  491              wGeneralVar=aucSoftUartRxBuf[ucRxIndex0];
  1373. MOV.B R8, R14
  1374. AND.W #0xff, R14
  1375. MOV.B aucSoftUartRxBuf(R14), R14
  1376. AND.W #0xff, R14
  1377. MOV.W R14, R10
  1378. //  492              wOneFaxRear=(wGeneralVar<<8) | aucSoftUartRxBuf[ucRxIndex1];
  1379. AND.W #0xff, R10
  1380. SWPB R10
  1381. AND.W #0xff, R11
  1382. MOV.B aucSoftUartRxBuf(R11), R14
  1383. AND.W #0xff, R14
  1384. BIS.W R14, R10
  1385. MOV.W R10, 0x4(SP)
  1386. //  493            
  1387. //  494              //DteDelOneFax(wOneFaxHead, wOneFaxRear);
  1388. //  495            }
  1389. //  496         }
  1390. //  497         
  1391. //  498       //PC delete all fax command:ba 23 00 05 10 03
  1392. //  499         if ((aucSoftUartRxBuf[gucSoftUartRxCnt-1]==0x03)&&(aucSoftUartRxBuf[gucSoftUartRxCnt-2]==0x10)&&
  1393. //  500             (aucSoftUartRxBuf[gucSoftUartRxCnt-3]==0x06)&&(aucSoftUartRxBuf[gucSoftUartRxCnt-4]==0x00)&&
  1394. //  501             (aucSoftUartRxBuf[gucSoftUartRxCnt-5]==0x23)&&(aucSoftUartRxBuf[gucSoftUartRxCnt-6]==0xba))
  1395. //  502         {
  1396. //  503            ;//DteDelAllFax();
  1397. //  504         }
  1398. //  505       
  1399. //  506       //PC send the system time to Dce command:ba 23 00 0b YearLow YearHigh Month Day Hour Minute Second 10 03
  1400. //  507         if ((aucSoftUartRxBuf[gucSoftUartRxCnt-1]==0x03)&&(aucSoftUartRxBuf[gucSoftUartRxCnt-2]==0x10)&&
  1401. //  508             (aucSoftUartRxBuf[gucSoftUartRxCnt-10]==0x0b)&&(aucSoftUartRxBuf[gucSoftUartRxCnt-11]==0x00)&&
  1402. //  509             (aucSoftUartRxBuf[gucSoftUartRxCnt-12]==0x23)&&(aucSoftUartRxBuf[gucSoftUartRxCnt-13]==0xba))
  1403. ??main_31:
  1404. MOV.W #aucSoftUartRxBuf, R15
  1405. MOV.B &gucSoftUartRxCnt, R14
  1406. AND.W #0xff, R14
  1407. ADD.W R14, R15
  1408. CMP.B #0x3, 0xffff(R15)
  1409. JNE ??main_32
  1410. MOV.W #aucSoftUartRxBuf, R15
  1411. MOV.B &gucSoftUartRxCnt, R14
  1412. AND.W #0xff, R14
  1413. ADD.W R14, R15
  1414. CMP.B #0x10, 0xfffe(R15)
  1415. JNE ??main_32
  1416. MOV.W #aucSoftUartRxBuf, R15
  1417. MOV.B &gucSoftUartRxCnt, R14
  1418. AND.W #0xff, R14
  1419. ADD.W R14, R15
  1420. CMP.B #0xb, 0xfff6(R15)
  1421. JNE ??main_32
  1422. MOV.W #aucSoftUartRxBuf, R15
  1423. MOV.B &gucSoftUartRxCnt, R14
  1424. AND.W #0xff, R14
  1425. ADD.W R14, R15
  1426. CMP.B #0x0, 0xfff5(R15)
  1427. JNE ??main_32
  1428. MOV.W #aucSoftUartRxBuf, R15
  1429. MOV.B &gucSoftUartRxCnt, R14
  1430. AND.W #0xff, R14
  1431. ADD.W R14, R15
  1432. CMP.B #0x23, 0xfff4(R15)
  1433. JNE ??main_32
  1434. MOV.W #aucSoftUartRxBuf, R15
  1435. MOV.B &gucSoftUartRxCnt, R14
  1436. AND.W #0xff, R14
  1437. ADD.W R14, R15
  1438. CMP.B #0xba, 0xfff3(R15)
  1439. JNE ??main_32
  1440. //  510         {
  1441. //  511          
  1442. //  512            if (gucFrhErrorStatus==0)
  1443. CMP.B #0x0, &gucFrhErrorStatus
  1444. JNE ??main_32
  1445. //  513            {
  1446. //  514              /*
  1447. //  515              SetSystemTime(aucSoftUartRxBuf[gucSoftUartRxCnt-9], aucSoftUartRxBuf[gucSoftUartRxCnt-8],
  1448. //  516                            aucSoftUartRxBuf[gucSoftUartRxCnt-7], aucSoftUartRxBuf[gucSoftUartRxCnt-6],
  1449. //  517                            aucSoftUartRxBuf[gucSoftUartRxCnt-5], aucSoftUartRxBuf[gucSoftUartRxCnt-4],
  1450. //  518                            aucSoftUartRxBuf[gucSoftUartRxCnt-3]);
  1451. //  519              */
  1452. //  520              ucRxIndex=gucSoftUartRxCnt-8;
  1453. MOV.B #0xf8, R14
  1454. ADD.B &gucSoftUartRxCnt, R14
  1455. MOV.B R14, R9
  1456. //  521              for (ucGeneralCnt = 0; ucGeneralCnt < 6; ucGeneralCnt++)
  1457. MOV.B #0x0, 0x6(SP)
  1458. ??main_9:
  1459. CMP.B #0x6, 0x6(SP)
  1460. JC ??main_33
  1461. //  522              {
  1462. //  523                  aucViewData[cstViewSecondIndex] = aucUartRxBuf[ucRxIndex++];//second
  1463. MOV.B R9, R14
  1464. AND.W #0xff, R14
  1465. MOV.B aucUartRxBuf(R14), &aucViewData + 0x2
  1466. ADD.B #0x1, R9
  1467. //  524                  aucViewData[cstViewMinuteIndex] = aucUartRxBuf[ucRxIndex++];//minute
  1468. MOV.B R9, R14
  1469. AND.W #0xff, R14
  1470. MOV.B aucUartRxBuf(R14), &aucViewData + 0x1
  1471. ADD.B #0x1, R9
  1472. //  525                  aucViewData[cstViewHourIndex] = aucUartRxBuf[ucRxIndex++];//hour
  1473. MOV.B R9, R14
  1474. AND.W #0xff, R14
  1475. MOV.B aucUartRxBuf(R14), &aucViewData
  1476. ADD.B #0x1, R9
  1477. //  526                  aucViewData[cstViewDateIndex] = aucUartRxBuf[ucRxIndex++];//date
  1478. MOV.B R9, R14
  1479. AND.W #0xff, R14
  1480. MOV.B aucUartRxBuf(R14), &aucViewData + 0x4
  1481. ADD.B #0x1, R9
  1482. //  527                  aucViewData[cstViewMonthIndex] = aucUartRxBuf[ucRxIndex++];//month
  1483. MOV.B R9, R14
  1484. AND.W #0xff, R14
  1485. MOV.B aucUartRxBuf(R14), &aucViewData + 0x3
  1486. ADD.B #0x1, R9
  1487. //  528                  aucViewData[cstViewYearIndex] = aucUartRxBuf[ucRxIndex++];//Year
  1488. MOV.B R9, R14
  1489. AND.W #0xff, R14
  1490. MOV.B aucUartRxBuf(R14), &aucViewData + 0x5
  1491. ADD.B #0x1, R9
  1492. //  529              }
  1493. ADD.B #0x1, 0x6(SP)
  1494. JMP ??main_9
  1495. //  530              ViewCommunicationTX(0x00);
  1496. ??main_33:
  1497. MOV.B #0x0, R12
  1498. CALL #ViewCommunicationTX
  1499. //  531            }
  1500. //  532         }
  1501. //  533           
  1502. //  534       //format flash
  1503. //  535         if ((aucSoftUartRxBuf[gucSoftUartRxCnt-1]==0x03)&&(aucSoftUartRxBuf[gucSoftUartRxCnt-2]==0x10)&&
  1504. //  536             (aucSoftUartRxBuf[gucSoftUartRxCnt-3]==0x0c)&&(aucSoftUartRxBuf[gucSoftUartRxCnt-4]==0x00)&&
  1505. //  537             (aucSoftUartRxBuf[gucSoftUartRxCnt-5]==0x23)&&(aucSoftUartRxBuf[gucSoftUartRxCnt-6]==0xba))
  1506. ??main_32:
  1507. MOV.W #aucSoftUartRxBuf, R15
  1508. MOV.B &gucSoftUartRxCnt, R14
  1509. AND.W #0xff, R14
  1510. ADD.W R14, R15
  1511. CMP.B #0x3, 0xffff(R15)
  1512. JNE ??main_34
  1513. MOV.W #aucSoftUartRxBuf, R15
  1514. MOV.B &gucSoftUartRxCnt, R14
  1515. AND.W #0xff, R14
  1516. ADD.W R14, R15
  1517. CMP.B #0x10, 0xfffe(R15)
  1518. JNE ??main_34
  1519. MOV.W #aucSoftUartRxBuf, R15
  1520. MOV.B &gucSoftUartRxCnt, R14
  1521. AND.W #0xff, R14
  1522. ADD.W R14, R15
  1523. CMP.B #0xc, 0xfffd(R15)
  1524. JNE ??main_34
  1525. MOV.W #aucSoftUartRxBuf, R15
  1526. MOV.B &gucSoftUartRxCnt, R14
  1527. AND.W #0xff, R14
  1528. ADD.W R14, R15
  1529. CMP.B #0x0, 0xfffc(R15)
  1530. JNE ??main_34
  1531. MOV.W #aucSoftUartRxBuf, R15
  1532. MOV.B &gucSoftUartRxCnt, R14
  1533. AND.W #0xff, R14
  1534. ADD.W R14, R15
  1535. CMP.B #0x23, 0xfffb(R15)
  1536. JNE ??main_34
  1537. MOV.W #aucSoftUartRxBuf, R15
  1538. MOV.B &gucSoftUartRxCnt, R14
  1539. AND.W #0xff, R14
  1540. ADD.W R14, R15
  1541. CMP.B #0xba, 0xfffa(R15)
  1542. JNE ??main_34
  1543. //  538         {
  1544. //  539          FlashFormat();
  1545. CALL #FlashFormat
  1546. //  540         }
  1547. //  541         
  1548. //  542       //Flash bad block process
  1549. //  543         if ((aucSoftUartRxBuf[gucSoftUartRxCnt-1]==0x03)&&(aucSoftUartRxBuf[gucSoftUartRxCnt-2]==0x10)&&
  1550. //  544             (aucSoftUartRxBuf[gucSoftUartRxCnt-3]==0x0d)&&(aucSoftUartRxBuf[gucSoftUartRxCnt-4]==0x00)&&
  1551. //  545             (aucSoftUartRxBuf[gucSoftUartRxCnt-5]==0x23)&&(aucSoftUartRxBuf[gucSoftUartRxCnt-6]==0xba))
  1552. ??main_34:
  1553. MOV.W #aucSoftUartRxBuf, R15
  1554. MOV.B &gucSoftUartRxCnt, R14
  1555. AND.W #0xff, R14
  1556. ADD.W R14, R15
  1557. CMP.B #0x3, 0xffff(R15)
  1558. JNE ??main_35
  1559. MOV.W #aucSoftUartRxBuf, R15
  1560. MOV.B &gucSoftUartRxCnt, R14
  1561. AND.W #0xff, R14
  1562. ADD.W R14, R15
  1563. CMP.B #0x10, 0xfffe(R15)
  1564. JNE ??main_35
  1565. MOV.W #aucSoftUartRxBuf, R15
  1566. MOV.B &gucSoftUartRxCnt, R14
  1567. AND.W #0xff, R14
  1568. ADD.W R14, R15
  1569. CMP.B #0xd, 0xfffd(R15)
  1570. JNE ??main_35
  1571. MOV.W #aucSoftUartRxBuf, R15
  1572. MOV.B &gucSoftUartRxCnt, R14
  1573. AND.W #0xff, R14
  1574. ADD.W R14, R15
  1575. CMP.B #0x0, 0xfffc(R15)
  1576. JNE ??main_35
  1577. MOV.W #aucSoftUartRxBuf, R15
  1578. MOV.B &gucSoftUartRxCnt, R14
  1579. AND.W #0xff, R14
  1580. ADD.W R14, R15
  1581. CMP.B #0x23, 0xfffb(R15)
  1582. JNE ??main_35
  1583. MOV.W #aucSoftUartRxBuf, R15
  1584. MOV.B &gucSoftUartRxCnt, R14
  1585. AND.W #0xff, R14
  1586. ADD.W R14, R15
  1587. CMP.B #0xba, 0xfffa(R15)
  1588. JNE ??main_35
  1589. //  546         {
  1590. //  547          CheckInvalidBlock();
  1591. CALL #CheckInvalidBlock
  1592. //  548          SoftUartTxOneFrame(0xff);
  1593. MOV.B #0xff, R12
  1594. CALL #SoftUartTxOneFrame
  1595. //  549         }
  1596. //  550         
  1597. //  551       //PC set CSI and DIS
  1598. //  552         if ((aucSoftUartRxBuf[gucSoftUartRxCnt-1]==0x03)&&(aucSoftUartRxBuf[gucSoftUartRxCnt-2]==0x10)&&
  1599. //  553             (aucSoftUartRxBuf[gucSoftUartRxCnt-7]==0x0e)&&(aucSoftUartRxBuf[gucSoftUartRxCnt-8]==0x00)&&
  1600. //  554             (aucSoftUartRxBuf[gucSoftUartRxCnt-9]==0x23)&&(aucSoftUartRxBuf[gucSoftUartRxCnt-10]==0xba))
  1601. ??main_35:
  1602. MOV.W #aucSoftUartRxBuf, R15
  1603. MOV.B &gucSoftUartRxCnt, R14
  1604. AND.W #0xff, R14
  1605. ADD.W R14, R15
  1606. CMP.B #0x3, 0xffff(R15)
  1607. JEQ $+6
  1608. BR #??main_7
  1609. MOV.W #aucSoftUartRxBuf, R15
  1610. MOV.B &gucSoftUartRxCnt, R14
  1611. AND.W #0xff, R14
  1612. ADD.W R14, R15
  1613. CMP.B #0x10, 0xfffe(R15)
  1614. JEQ $+6
  1615. BR #??main_7
  1616. MOV.W #aucSoftUartRxBuf, R15
  1617. MOV.B &gucSoftUartRxCnt, R14
  1618. AND.W #0xff, R14
  1619. ADD.W R14, R15
  1620. CMP.B #0xe, 0xfff9(R15)
  1621. JEQ $+6
  1622. BR #??main_7
  1623. MOV.W #aucSoftUartRxBuf, R15
  1624. MOV.B &gucSoftUartRxCnt, R14
  1625. AND.W #0xff, R14
  1626. ADD.W R14, R15
  1627. CMP.B #0x0, 0xfff8(R15)
  1628. JEQ $+6
  1629. BR #??main_7
  1630. MOV.W #aucSoftUartRxBuf, R15
  1631. MOV.B &gucSoftUartRxCnt, R14
  1632. AND.W #0xff, R14
  1633. ADD.W R14, R15
  1634. CMP.B #0x23, 0xfff7(R15)
  1635. JEQ $+6
  1636. BR #??main_7
  1637. MOV.W #aucSoftUartRxBuf, R15
  1638. MOV.B &gucSoftUartRxCnt, R14
  1639. AND.W #0xff, R14
  1640. ADD.W R14, R15
  1641. CMP.B #0xba, 0xfff6(R15)
  1642. JEQ $+6
  1643. BR #??main_7
  1644. //  555         {
  1645. //  556            SetCSIandDIS();
  1646. CALL #SetCSIandDIS
  1647. //  557            DceResponsePc();
  1648. CALL #DceResponsePc
  1649. BR #??main_7
  1650.         CFI EndBlock cfiBlock0
  1651. //  558          
  1652. //  559         }
  1653. //  560       /* get new fax
  1654. //  561         if ((aucUartRxBuf[gucUartRxCnt-1]==0x03)&&(aucUartRxBuf[gucUartRxCnt-2]==0x10)&&
  1655. //  562             (aucUartRxBuf[gucUartRxCnt-3]==0x01)&&(aucUartRxBuf[gucUartRxCnt-4]==0x00)&&
  1656. //  563             (aucUartRxBuf[gucUartRxCnt-5]==0x23)&&(aucUartRxBuf[gucUartRxCnt-6]==0xba))
  1657. //  564             //;
  1658. //  565         //if (gucRxTxFlag == DTERX)
  1659. //  566         {
  1660. //  567           FaxData2PCFromSoftUart();//FaxRXProcess();//FaxData2PC();   //FaxTXProcess();
  1661. //  568           gucRxTxFlag = DTETX;
  1662. //  569         }
  1663. //  570       */
  1664. //  571        }//else over Modem active not active 
  1665. //  572     }//while end Main circle over
  1666. //  573 }//main function over
  1667.         RSEG CODE:CODE:NOROOT(1)
  1668. ?setjmp_save_r4:
  1669. REQUIRE ?setjmp_r4
  1670. REQUIRE ?longjmp_r4
  1671.         RSEG CODE:CODE:NOROOT(1)
  1672. ?setjmp_save_r5:
  1673. REQUIRE ?setjmp_r5
  1674. REQUIRE ?longjmp_r5
  1675.         END
  1676. //  574  
  1677. //  575 /***************************************************************************
  1678. //  576      
  1679. //  577 ***************************************************************************/
  1680. //  578 /***************************************************************************/
  1681. //  579 
  1682. //  580 /*
  1683. //  581 #include "KeyScan.c"
  1684. //  582 #include "ViewData2Flash.c"
  1685. //  583 #include "LCDView.c"
  1686. //  584 #include "DTEcmdProcess.c"
  1687. //  585 #include "FaxRxBuf2Flash.c"   
  1688. //  586 #include "IoInitial.c"
  1689. //  587 #include "Uart.c"
  1690. //  588 #include "SoftUart.c"
  1691. //  589 #include "ParameterSet.c"
  1692. //  590 #include "ATcmdSet.c"
  1693. //  591 #include "Flash.c"
  1694. //  592 #include "FaxPropertyTableManage.c"
  1695. //  593 #include "FaxFrontPointerManage.c"
  1696. //  594 #include "FaxRearPointerManage.c"
  1697. //  595 #include "FlashBadBlockProcess.c"
  1698. //  596 #include "FaxProcess.c"
  1699. //  597 //#include "FaxData2pc.c"
  1700. //  598 //#include "FaxRxBufRawdata2pc.c"
  1701. //  599 #include "Delay.c"
  1702. //  600 
  1703. //  601 */
  1704. // 
  1705. // 2 828 bytes in segment CODE
  1706. //     6 bytes in segment DATA16_AN
  1707. // 
  1708. // 2 828 bytes of CODE memory
  1709. //     0 bytes of DATA memory (+ 6 bytes shared)
  1710. //
  1711. //Errors: none
  1712. //Warnings: none