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

传真(Fax)编程

开发平台:

C/C++

  1.         NAME KeyScan
  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 ?SwitchKey8
  9.         EXTERN delay1us
  10.         FUNCTION delay1us,0202H
  11.         EXTERN aucViewData
  12.         EXTERN ViewCommunicationTX
  13.         FUNCTION ViewCommunicationTX,0202H
  14.         EXTERN ReadLast16BytesFromFlashMemoryArea
  15.         FUNCTION ReadLast16BytesFromFlashMemoryArea,0202H
  16.         EXTERN gwGeneralPageAddress
  17.         EXTERN ?ShiftRight16u_6
  18.         EXTERN ?ShiftLeft16_6
  19.         EXTERN ROW_ADDRESS_LOW
  20.         EXTERN ROW_ADDRESS_HIGH
  21.         EXTERN ERASE_ONE_BLOCK
  22.         FUNCTION ERASE_ONE_BLOCK,0202H
  23.         EXTERN gwColumnAddress
  24.         EXTERN aucUartRxBuf
  25.         EXTERN Write16Bytes2FlashMemoryArea
  26.         FUNCTION Write16Bytes2FlashMemoryArea,0202H
  27.         EXTERN ?longjmp_r4
  28.         EXTERN ?longjmp_r5
  29.         EXTERN ?setjmp_r4
  30.         EXTERN ?setjmp_r5
  31.         PUBWEAK ?setjmp_save_r4
  32.         PUBWEAK ?setjmp_save_r5
  33.         PUBLIC KeyScan
  34.         FUNCTION KeyScan,021203H
  35.         LOCFRAME CSTACK, 4, STACK
  36.         PUBWEAK P1IN
  37.         PUBLIC ReadAndWriteViewDataMemory
  38.         FUNCTION ReadAndWriteViewDataMemory,021203H
  39.         LOCFRAME CSTACK, 8, STACK
  40.         
  41.         CFI Names cfiNames0
  42.         CFI StackFrame CFA SP DATA
  43.         CFI Resource PC:16, SP:16, SR:16, R4:16, R5:16, R6:16, R7:16, R8:16
  44.         CFI Resource R9:16, R10:16, R11:16, R12:16, R13:16, R14:16, R15:16
  45.         CFI EndNames cfiNames0
  46.         
  47.         CFI Common cfiCommon0 Using cfiNames0
  48.         CFI CodeAlign 2
  49.         CFI DataAlign 2
  50.         CFI ReturnAddress PC CODE
  51.         CFI CFA SP+2
  52.         CFI PC Frame(CFA, -2)
  53.         CFI SR Undefined
  54.         CFI R4 SameValue
  55.         CFI R5 SameValue
  56.         CFI R6 SameValue
  57.         CFI R7 SameValue
  58.         CFI R8 SameValue
  59.         CFI R9 SameValue
  60.         CFI R10 SameValue
  61.         CFI R11 SameValue
  62.         CFI R12 Undefined
  63.         CFI R13 Undefined
  64.         CFI R14 Undefined
  65.         CFI R15 Undefined
  66.         CFI EndCommon cfiCommon0
  67.         
  68. // E:projectFaxProgramVson_Bryan_Fax_Conexant_070423filesKeyScan.c
  69. //    1 /***************************************
  70. //    2 Program:     Key Scan
  71. //    3 Author:      Bryan Cai
  72. //    4 Date:        2007.04.11
  73. //    5 ***************************************/
  74. //    6 
  75. //    7 #include "includeH.h"
  76.         ASEGN DATA16_AN:DATA:NOROOT,020H
  77. // unsigned char const volatile __data P1IN
  78. P1IN:
  79.         DS8 1
  80. //    8 
  81.         RSEG CODE:CODE:NOROOT(1)
  82. //    9 void KeyScan(void)
  83. KeyScan:
  84.         CFI Block cfiBlock0 Using cfiCommon0
  85.         CFI Function KeyScan
  86. //   10 {
  87.         FUNCALL KeyScan, delay1us
  88.         LOCFRAME CSTACK, 4, STACK
  89.         FUNCALL KeyScan, delay1us
  90.         LOCFRAME CSTACK, 4, STACK
  91.         FUNCALL KeyScan, delay1us
  92.         LOCFRAME CSTACK, 4, STACK
  93.         FUNCALL KeyScan, delay1us
  94.         LOCFRAME CSTACK, 4, STACK
  95.         FUNCALL KeyScan, ViewCommunicationTX
  96.         LOCFRAME CSTACK, 4, STACK
  97.         FUNCALL KeyScan, ReadAndWriteViewDataMemory
  98.         LOCFRAME CSTACK, 4, STACK
  99.         FUNCALL KeyScan, delay1us
  100.         LOCFRAME CSTACK, 4, STACK
  101. PUSH.W R10
  102.         CFI R10 Frame(CFA, -4)
  103.         CFI CFA SP+4
  104. //   11      unsigned char ucKeyValue=0xff;
  105. MOV.B #0xff, R10
  106. //   12      //unsigned char ucBlockCnt=0;
  107. //   13      //unsigned char ucRxIndex=0;
  108. //   14      //unsigned int wPageAddress=0;
  109. //   15    //Ring Number+-
  110. //   16       if (((KEY_PORT_IN & bitKeyRingNumDec) != bitKeyRingNumDec) ||
  111. //   17          ((KEY_PORT_IN & bitKeyRingNumAdd) != bitKeyRingNumAdd) ||
  112. //   18          ((KEY_PORT_IN & bitKeyAutoMode) != bitKeyAutoMode) ||
  113. //   19          ((KEY_PORT_IN & bitKeyManualMode) != bitKeyManualMode) )//||
  114. BIT.B #0x1, &0x20
  115. JNC ??KeyScan_1
  116. BIT.B #0x2, &0x20
  117. JNC ??KeyScan_1
  118. BIT.B #0x4, &0x20
  119. JNC ??KeyScan_1
  120. BIT.B #0x8, &0x20
  121. JC ??KeyScan_2
  122. //   20          //((KEY_PORT_IN & bitKeySendFaxSignal) != bitKeySendFaxSignal))
  123. //   21       {
  124. //   22         //VIEWLEDPORT |= bitViewLED;
  125. //   23         if ((KEY_PORT_IN & bitKeyRingNumDec) != bitKeyRingNumDec) ucKeyValue=0;
  126. ??KeyScan_1:
  127. BIT.B #0x1, &0x20
  128. JC ??KeyScan_3
  129. MOV.B #0x0, R10
  130. //   24         if ((KEY_PORT_IN & bitKeyRingNumAdd) != bitKeyRingNumAdd) ucKeyValue=1;
  131. ??KeyScan_3:
  132. BIT.B #0x2, &0x20
  133. JC ??KeyScan_4
  134. MOV.B #0x1, R10
  135. //   25         if ((KEY_PORT_IN & bitKeyAutoMode) != bitKeyAutoMode)     ucKeyValue=2;
  136. ??KeyScan_4:
  137. BIT.B #0x4, &0x20
  138. JC ??KeyScan_5
  139. MOV.B #0x2, R10
  140. //   26         if ((KEY_PORT_IN & bitKeyManualMode) != bitKeyManualMode) ucKeyValue=3;
  141. ??KeyScan_5:
  142. BIT.B #0x8, &0x20
  143. JC ??KeyScan_6
  144. MOV.B #0x3, R10
  145. //   27         //if ((KEY_PORT_IN & bitKeySendFaxSignal) != bitKeySendFaxSignal) ucKeyValue=4;
  146. //   28         
  147. //   29         switch (ucKeyValue)
  148. ??KeyScan_6:
  149. SUB.B #0x0, R10
  150. JEQ ??KeyScan_7
  151. SUB.B #0x1, R10
  152. JEQ ??KeyScan_8
  153. SUB.B #0x1, R10
  154. JEQ ??KeyScan_9
  155. SUB.B #0x1, R10
  156. JEQ ??KeyScan_10
  157. JMP ??KeyScan_11
  158. //   30         {
  159. //   31       //if ((KEY_PORT_IN & bitKeyRingNumDec) != bitKeyRingNumDec)
  160. //   32        case 0:
  161. //   33        {
  162. //   34          delay1us(0x0530);//300000);
  163. ??KeyScan_7:
  164. MOV.W #0x530, R12
  165. CALL #delay1us
  166. //   35          if ((KEY_PORT_IN & bitKeyRingNumDec) != bitKeyRingNumDec)
  167. BIT.B #0x1, &0x20
  168. JC ??KeyScan_11
  169. //   36          {
  170. //   37           if (gucViewRingNum>0)--gucViewRingNum;//RingNumMax--
  171. CMP.B #0x1, &aucViewData + 0x6
  172. JNC ??KeyScan_11
  173. ADD.B #0xff, &aucViewData + 0x6
  174. JMP ??KeyScan_11
  175. //   38           //ViewCommunicationTX(0x01);
  176. //   39           //ViewCommunicationRX();
  177. //   40          }
  178. //   41           break;
  179. //   42        }//case 0
  180. //   43       
  181. //   44         
  182. //   45       //if ((KEY_PORT_IN & bitKeyRingNumAdd) != bitKeyRingNumAdd)
  183. //   46         case 1:
  184. //   47         {
  185. //   48          delay1us(0x0530);
  186. ??KeyScan_8:
  187. MOV.W #0x530, R12
  188. CALL #delay1us
  189. //   49          if ((KEY_PORT_IN & bitKeyRingNumAdd) != bitKeyRingNumAdd)
  190. BIT.B #0x2, &0x20
  191. JC ??KeyScan_11
  192. //   50           { 
  193. //   51             if (gucViewRingNum<9)++gucViewRingNum;//RingNumMax++
  194. CMP.B #0x9, &aucViewData + 0x6
  195. JC ??KeyScan_11
  196. ADD.B #0x1, &aucViewData + 0x6
  197. JMP ??KeyScan_11
  198. //   52             //ViewCommunicationTX(0x01);
  199. //   53             //ViewCommunicationRX();
  200. //   54           }
  201. //   55           break;
  202. //   56          }//case 1
  203. //   57       
  204. //   58       //ModeSel Key scan: auto or manual send fax signal
  205. //   59       //if ((KEY_PORT_IN & bitKeyAutoMode) != bitKeyAutoMode)//bitKeyAutoMode==0
  206. //   60         case 2:
  207. //   61         {
  208. //   62            delay1us(0x0530);
  209. ??KeyScan_9:
  210. MOV.W #0x530, R12
  211. CALL #delay1us
  212. //   63            if ((KEY_PORT_IN & bitKeyAutoMode) != bitKeyAutoMode)
  213. BIT.B #0x4, &0x20
  214. JC ??KeyScan_11
  215. //   64             {
  216. //   65              gucViewStaticStatus |= bitViewAutoMode;//Auto Mode
  217. BIS.B #0x10, &aucViewData + 0x7
  218. //   66              gucViewStaticStatus &= ~bitViewManualMode;//
  219. BIC.B #0x20, &aucViewData + 0x7
  220. //   67              gucViewStaticStatus |= bitViewRingNum;
  221. BIS.B #0x40, &aucViewData + 0x7
  222. JMP ??KeyScan_11
  223. //   68             
  224. //   69              //ViewCommunicationTX(0x01);
  225. //   70              //ViewCommunicationRX();
  226. //   71             }
  227. //   72             break;
  228. //   73         }//case 2
  229. //   74       //if ((KEY_PORT_IN & bitKeyManualMode) != bitKeyManualMode)
  230. //   75         case 3:
  231. //   76         {
  232. //   77            
  233. //   78            delay1us(0x0530);
  234. ??KeyScan_10:
  235. MOV.W #0x530, R12
  236. CALL #delay1us
  237. //   79            if ((KEY_PORT_IN & bitKeyManualMode) != bitKeyManualMode)
  238. BIT.B #0x8, &0x20
  239. JC ??KeyScan_11
  240. //   80             {
  241. //   81              gucViewStaticStatus |= bitViewManualMode;//Manual Mode
  242. BIS.B #0x20, &aucViewData + 0x7
  243. //   82              gucViewStaticStatus &= ~bitViewAutoMode; //off atuo
  244. BIC.B #0x10, &aucViewData + 0x7
  245. //   83              gucViewStaticStatus &= ~bitViewRingNum;//off ring num
  246. BIC.B #0x40, &aucViewData + 0x7
  247. //   84             
  248. //   85              //ViewCommunicationTX(0x01);
  249. //   86              //ViewCommunicationRX();
  250. //   87             }
  251. //   88             break;
  252. //   89         }//case 3
  253. //   90         
  254. //   91         }//switch
  255. //   92       //Driver LCD screen
  256. //   93       if (((KEY_PORT_IN & bitKeyRingNumDec) != bitKeyRingNumDec) ||
  257. //   94          ((KEY_PORT_IN & bitKeyRingNumAdd) != bitKeyRingNumAdd) ||
  258. //   95          ((KEY_PORT_IN & bitKeyAutoMode) != bitKeyAutoMode) ||
  259. //   96          ((KEY_PORT_IN & bitKeyManualMode) != bitKeyManualMode) )
  260. ??KeyScan_11:
  261. BIT.B #0x1, &0x20
  262. JNC ??KeyScan_12
  263. BIT.B #0x2, &0x20
  264. JNC ??KeyScan_12
  265. BIT.B #0x4, &0x20
  266. JNC ??KeyScan_12
  267. BIT.B #0x8, &0x20
  268. JC ??KeyScan_13
  269. //   97          //|| ((KEY_PORT_IN & bitKeySendFaxSignal) != bitKeySendFaxSignal))
  270. //   98        {
  271. //   99           ViewCommunicationTX(0x01);
  272. ??KeyScan_12:
  273. MOV.B #0x1, R12
  274. CALL #ViewCommunicationTX
  275. //  100           
  276. //  101           ReadAndWriteViewDataMemory();
  277. CALL #ReadAndWriteViewDataMemory
  278. //  102         }   
  279. //  103       
  280. //  104       if (((KEY_PORT_IN & bitKeyRingNumDec) != bitKeyRingNumDec) ||
  281. //  105          ((KEY_PORT_IN & bitKeyRingNumAdd) != bitKeyRingNumAdd) ||
  282. //  106          ((KEY_PORT_IN & bitKeyAutoMode) != bitKeyAutoMode) ||
  283. //  107          ((KEY_PORT_IN & bitKeyManualMode) != bitKeyManualMode))
  284. ??KeyScan_13:
  285. BIT.B #0x1, &0x20
  286. JNC ??KeyScan_0
  287. BIT.B #0x2, &0x20
  288. JNC ??KeyScan_0
  289. BIT.B #0x4, &0x20
  290. JNC ??KeyScan_0
  291. BIT.B #0x8, &0x20
  292. JC ??KeyScan_2
  293. //  108          //|| ((KEY_PORT_IN & bitKeySendFaxSignal) != bitKeySendFaxSignal))
  294. //  109       { 
  295. //  110       while (1)
  296. //  111       {
  297. //  112        if (((KEY_PORT_IN & bitKeyRingNumDec) == bitKeyRingNumDec) &&
  298. //  113          ((KEY_PORT_IN & bitKeyRingNumAdd) == bitKeyRingNumAdd) &&
  299. //  114          ((KEY_PORT_IN & bitKeyAutoMode) == bitKeyAutoMode) &&
  300. //  115          ((KEY_PORT_IN & bitKeyManualMode) == bitKeyManualMode)) //&&
  301. ??KeyScan_0:
  302. BIT.B #0x1, &0x20
  303. JNC ??KeyScan_0
  304. BIT.B #0x2, &0x20
  305. JNC ??KeyScan_0
  306. BIT.B #0x4, &0x20
  307. JNC ??KeyScan_0
  308. BIT.B #0x8, &0x20
  309. JNC ??KeyScan_0
  310. //  116          //((KEY_PORT_IN & bitKeySendFaxSignal) == bitKeySendFaxSignal))
  311. //  117          {
  312. //  118            delay1us(0x7530);
  313. MOV.W #0x7530, R12
  314. CALL #delay1us
  315. //  119            if (((KEY_PORT_IN & bitKeyRingNumDec) == bitKeyRingNumDec) &&
  316. //  120                ((KEY_PORT_IN & bitKeyRingNumAdd) == bitKeyRingNumAdd) &&
  317. //  121                ((KEY_PORT_IN & bitKeyAutoMode) == bitKeyAutoMode) &&
  318. //  122                ((KEY_PORT_IN & bitKeyManualMode) == bitKeyManualMode))// &&
  319. BIT.B #0x1, &0x20
  320. JNC ??KeyScan_0
  321. BIT.B #0x2, &0x20
  322. JNC ??KeyScan_0
  323. BIT.B #0x4, &0x20
  324. JNC ??KeyScan_0
  325. BIT.B #0x8, &0x20
  326. JNC ??KeyScan_0
  327. //  123                //((KEY_PORT_IN & bitKeySendFaxSignal) == bitKeySendFaxSignal))
  328. //  124                break;
  329. //  125          } 
  330. //  126       }
  331. //  127       //VIEWLEDPORT &= ~bitViewLED;
  332. //  128       }
  333. //  129       
  334. //  130       }
  335. //  131 }
  336. ??KeyScan_2:
  337. POP.W R10
  338.         CFI R10 SameValue
  339.         CFI CFA SP+2
  340. RET
  341.         CFI EndBlock cfiBlock0
  342. //  132 
  343.         RSEG CODE:CODE:NOROOT(1)
  344. //  133 void ReadAndWriteViewDataMemory(void)
  345. ReadAndWriteViewDataMemory:
  346.         CFI Block cfiBlock1 Using cfiCommon0
  347.         CFI Function ReadAndWriteViewDataMemory
  348. //  134 {
  349.         FUNCALL ReadAndWriteViewDataMemory, ReadLast16BytesFromFlashMemoryArea
  350.         LOCFRAME CSTACK, 8, STACK
  351.         FUNCALL ReadAndWriteViewDataMemory, ERASE_ONE_BLOCK
  352.         LOCFRAME CSTACK, 8, STACK
  353.         FUNCALL ReadAndWriteViewDataMemory, Write16Bytes2FlashMemoryArea
  354.         LOCFRAME CSTACK, 8, STACK
  355. PUSH.W R10
  356.         CFI R10 Frame(CFA, -4)
  357.         CFI CFA SP+4
  358. PUSH.W R11
  359.         CFI R11 Frame(CFA, -6)
  360.         CFI CFA SP+6
  361. PUSH.W R8
  362.         CFI R8 Frame(CFA, -8)
  363.         CFI CFA SP+8
  364. //  135           unsigned char ucBlockCnt=0;
  365. MOV.B #0x0, R8
  366. //  136          unsigned char ucRxIndex=0;
  367. MOV.B #0x0, R10
  368. //  137          unsigned int wPageAddress=0;
  369. MOV.W #0x0, R11
  370. //  138          //ReadLast16BytesFromFlashMemoryArea(cstViewDataAreaStartBlockNum,cstViewDataAreaOverBlockNum);
  371. //  139           ReadLastViewData();
  372. MOV.B #0x29, R14
  373. MOV.B #0x28, R12
  374. CALL #ReadLast16BytesFromFlashMemoryArea
  375. //  140           if ((gwGeneralPageAddress>>6) > cstViewDataAreaOverBlockNum)
  376. MOV.W &gwGeneralPageAddress, R12
  377. CALL #?ShiftRight16u_6
  378. CMP.W #0x2a, R12
  379. JNC ??ReadAndWriteViewDataMemory_2
  380. //  141          {
  381. //  142           for (ucBlockCnt=0;ucBlockCnt<2;ucBlockCnt++)
  382. MOV.B #0x0, R8
  383. ??ReadAndWriteViewDataMemory_0:
  384. CMP.B #0x2, R8
  385. JC ??ReadAndWriteViewDataMemory_3
  386. //  143             {
  387. //  144                wPageAddress=(cstViewDataAreaStartBlockNum+ucBlockCnt)<<6;
  388. MOV.B R8, R12
  389. AND.W #0xff, R12
  390. ADD.W #0x28, R12
  391. CALL #?ShiftLeft16_6
  392. MOV.W R12, R11
  393. //  145                ROW_ADDRESS_LOW=wPageAddress & 0XFF;
  394. MOV.B R11, &ROW_ADDRESS_LOW
  395. //  146                ROW_ADDRESS_HIGH=(wPageAddress>>8) & 0XFF; 
  396. MOV.W R11, R14
  397. SWPB R14
  398. AND.W #0xff, R14
  399. MOV.B R14, &ROW_ADDRESS_HIGH
  400. //  147                ERASE_ONE_BLOCK();
  401. CALL #ERASE_ONE_BLOCK
  402. //  148             }
  403. ADD.B #0x1, R8
  404. JMP ??ReadAndWriteViewDataMemory_0
  405. //  149             gwGeneralPageAddress=cstViewDataAreaStartPage;
  406. ??ReadAndWriteViewDataMemory_3:
  407. MOV.W #0xa00, &gwGeneralPageAddress
  408. //  150             gwColumnAddress=0;
  409. MOV.W #0x0, &gwColumnAddress
  410. //  151           }
  411. //  152            ucRxIndex=0; //write view data
  412. ??ReadAndWriteViewDataMemory_2:
  413. MOV.B #0x0, R10
  414. //  153            aucUartRxBuf[ucRxIndex++]=gucViewRingNum;
  415. MOV.B R10, R14
  416. AND.W #0xff, R14
  417. MOV.B &aucViewData + 0x6, aucUartRxBuf(R14)
  418. ADD.B #0x1, R10
  419. //  154            aucUartRxBuf[ucRxIndex++]=gucViewStaticStatus;
  420. MOV.B R10, R14
  421. AND.W #0xff, R14
  422. MOV.B &aucViewData + 0x7, aucUartRxBuf(R14)
  423. ADD.B #0x1, R10
  424. //  155            aucUartRxBuf[ucRxIndex++]=gucViewDynamicStatus;
  425. MOV.B R10, R14
  426. AND.W #0xff, R14
  427. MOV.B &aucViewData + 0x8, aucUartRxBuf(R14)
  428. ADD.B #0x1, R10
  429. //  156            aucUartRxBuf[ucRxIndex++]=gucViewDceNewFaxNum;//gucIcon2;
  430. MOV.B R10, R14
  431. AND.W #0xff, R14
  432. MOV.B &aucViewData + 0x9, aucUartRxBuf(R14)
  433. ADD.B #0x1, R10
  434. //  157            for (ucBlockCnt=0; ucBlockCnt<12; ucBlockCnt++)
  435. MOV.B #0x0, R8
  436. ??ReadAndWriteViewDataMemory_1:
  437. CMP.B #0xc, R8
  438. JC ??ReadAndWriteViewDataMemory_4
  439. //  158             {
  440. //  159              aucUartRxBuf[ucRxIndex++]=0x55;
  441. MOV.B R10, R14
  442. AND.W #0xff, R14
  443. MOV.B #0x55, aucUartRxBuf(R14)
  444. ADD.B #0x1, R10
  445. //  160             }
  446. ADD.B #0x1, R8
  447. JMP ??ReadAndWriteViewDataMemory_1
  448. //  161            Write16Bytes2FlashMemoryArea();
  449. ??ReadAndWriteViewDataMemory_4:
  450. CALL #Write16Bytes2FlashMemoryArea
  451. //  162 } 
  452. POP.W R8
  453.         CFI R8 SameValue
  454.         CFI CFA SP+6
  455. POP.W R11
  456.         CFI R11 SameValue
  457.         CFI CFA SP+4
  458. POP.W R10
  459.         CFI R10 SameValue
  460.         CFI CFA SP+2
  461. RET
  462.         CFI EndBlock cfiBlock1
  463.         RSEG CODE:CODE:NOROOT(1)
  464. ?setjmp_save_r4:
  465. REQUIRE ?setjmp_r4
  466. REQUIRE ?longjmp_r4
  467.         RSEG CODE:CODE:NOROOT(1)
  468. ?setjmp_save_r5:
  469. REQUIRE ?setjmp_r5
  470. REQUIRE ?longjmp_r5
  471.         END
  472. // 
  473. // 508 bytes in segment CODE
  474. //   1 byte  in segment DATA16_AN
  475. // 
  476. // 508 bytes of CODE memory
  477. //   0 bytes of DATA memory (+ 1 byte shared)
  478. //
  479. //Errors: none
  480. //Warnings: none