KeyScan.s43
上传用户:xhjmsc
上传日期:2019-09-13
资源大小:389k
文件大小:15k
- NAME KeyScan
- RTMODEL "__double_size", "32"
- RTMODEL "__pic", "no"
- RTMODEL "__reg_r4", "free"
- RTMODEL "__reg_r5", "free"
- RTMODEL "__rt_version", "1"
- RSEG CSTACK:DATA:SORT:NOROOT(1)
- EXTERN ?SwitchKey8
- EXTERN delay1us
- FUNCTION delay1us,0202H
- EXTERN aucViewData
- EXTERN ViewCommunicationTX
- FUNCTION ViewCommunicationTX,0202H
- EXTERN ReadLast16BytesFromFlashMemoryArea
- FUNCTION ReadLast16BytesFromFlashMemoryArea,0202H
- EXTERN gwGeneralPageAddress
- EXTERN ?ShiftRight16u_6
- EXTERN ?ShiftLeft16_6
- EXTERN ROW_ADDRESS_LOW
- EXTERN ROW_ADDRESS_HIGH
- EXTERN ERASE_ONE_BLOCK
- FUNCTION ERASE_ONE_BLOCK,0202H
- EXTERN gwColumnAddress
- EXTERN aucUartRxBuf
- EXTERN Write16Bytes2FlashMemoryArea
- FUNCTION Write16Bytes2FlashMemoryArea,0202H
- EXTERN ?longjmp_r4
- EXTERN ?longjmp_r5
- EXTERN ?setjmp_r4
- EXTERN ?setjmp_r5
- PUBWEAK ?setjmp_save_r4
- PUBWEAK ?setjmp_save_r5
- PUBLIC KeyScan
- FUNCTION KeyScan,021203H
- LOCFRAME CSTACK, 4, STACK
- PUBWEAK P1IN
- PUBLIC ReadAndWriteViewDataMemory
- FUNCTION ReadAndWriteViewDataMemory,021203H
- LOCFRAME CSTACK, 8, STACK
-
- CFI Names cfiNames0
- CFI StackFrame CFA SP DATA
- CFI Resource PC:16, SP:16, SR:16, R4:16, R5:16, R6:16, R7:16, R8:16
- CFI Resource R9:16, R10:16, R11:16, R12:16, R13:16, R14:16, R15:16
- CFI EndNames cfiNames0
-
- CFI Common cfiCommon0 Using cfiNames0
- CFI CodeAlign 2
- CFI DataAlign 2
- CFI ReturnAddress PC CODE
- CFI CFA SP+2
- CFI PC Frame(CFA, -2)
- CFI SR Undefined
- CFI R4 SameValue
- CFI R5 SameValue
- CFI R6 SameValue
- CFI R7 SameValue
- CFI R8 SameValue
- CFI R9 SameValue
- CFI R10 SameValue
- CFI R11 SameValue
- CFI R12 Undefined
- CFI R13 Undefined
- CFI R14 Undefined
- CFI R15 Undefined
- CFI EndCommon cfiCommon0
-
- // E:projectFaxProgramVson_Bryan_Fax_Conexant_070423filesKeyScan.c
- // 1 /***************************************
- // 2 Program: Key Scan
- // 3 Author: Bryan Cai
- // 4 Date: 2007.04.11
- // 5 ***************************************/
- // 6
- // 7 #include "includeH.h"
- ASEGN DATA16_AN:DATA:NOROOT,020H
- // unsigned char const volatile __data P1IN
- P1IN:
- DS8 1
- // 8
- RSEG CODE:CODE:NOROOT(1)
- // 9 void KeyScan(void)
- KeyScan:
- CFI Block cfiBlock0 Using cfiCommon0
- CFI Function KeyScan
- // 10 {
- FUNCALL KeyScan, delay1us
- LOCFRAME CSTACK, 4, STACK
- FUNCALL KeyScan, delay1us
- LOCFRAME CSTACK, 4, STACK
- FUNCALL KeyScan, delay1us
- LOCFRAME CSTACK, 4, STACK
- FUNCALL KeyScan, delay1us
- LOCFRAME CSTACK, 4, STACK
- FUNCALL KeyScan, ViewCommunicationTX
- LOCFRAME CSTACK, 4, STACK
- FUNCALL KeyScan, ReadAndWriteViewDataMemory
- LOCFRAME CSTACK, 4, STACK
- FUNCALL KeyScan, delay1us
- LOCFRAME CSTACK, 4, STACK
- PUSH.W R10
- CFI R10 Frame(CFA, -4)
- CFI CFA SP+4
- // 11 unsigned char ucKeyValue=0xff;
- MOV.B #0xff, R10
- // 12 //unsigned char ucBlockCnt=0;
- // 13 //unsigned char ucRxIndex=0;
- // 14 //unsigned int wPageAddress=0;
- // 15 //Ring Number+-
- // 16 if (((KEY_PORT_IN & bitKeyRingNumDec) != bitKeyRingNumDec) ||
- // 17 ((KEY_PORT_IN & bitKeyRingNumAdd) != bitKeyRingNumAdd) ||
- // 18 ((KEY_PORT_IN & bitKeyAutoMode) != bitKeyAutoMode) ||
- // 19 ((KEY_PORT_IN & bitKeyManualMode) != bitKeyManualMode) )//||
- BIT.B #0x1, &0x20
- JNC ??KeyScan_1
- BIT.B #0x2, &0x20
- JNC ??KeyScan_1
- BIT.B #0x4, &0x20
- JNC ??KeyScan_1
- BIT.B #0x8, &0x20
- JC ??KeyScan_2
- // 20 //((KEY_PORT_IN & bitKeySendFaxSignal) != bitKeySendFaxSignal))
- // 21 {
- // 22 //VIEWLEDPORT |= bitViewLED;
- // 23 if ((KEY_PORT_IN & bitKeyRingNumDec) != bitKeyRingNumDec) ucKeyValue=0;
- ??KeyScan_1:
- BIT.B #0x1, &0x20
- JC ??KeyScan_3
- MOV.B #0x0, R10
- // 24 if ((KEY_PORT_IN & bitKeyRingNumAdd) != bitKeyRingNumAdd) ucKeyValue=1;
- ??KeyScan_3:
- BIT.B #0x2, &0x20
- JC ??KeyScan_4
- MOV.B #0x1, R10
- // 25 if ((KEY_PORT_IN & bitKeyAutoMode) != bitKeyAutoMode) ucKeyValue=2;
- ??KeyScan_4:
- BIT.B #0x4, &0x20
- JC ??KeyScan_5
- MOV.B #0x2, R10
- // 26 if ((KEY_PORT_IN & bitKeyManualMode) != bitKeyManualMode) ucKeyValue=3;
- ??KeyScan_5:
- BIT.B #0x8, &0x20
- JC ??KeyScan_6
- MOV.B #0x3, R10
- // 27 //if ((KEY_PORT_IN & bitKeySendFaxSignal) != bitKeySendFaxSignal) ucKeyValue=4;
- // 28
- // 29 switch (ucKeyValue)
- ??KeyScan_6:
- SUB.B #0x0, R10
- JEQ ??KeyScan_7
- SUB.B #0x1, R10
- JEQ ??KeyScan_8
- SUB.B #0x1, R10
- JEQ ??KeyScan_9
- SUB.B #0x1, R10
- JEQ ??KeyScan_10
- JMP ??KeyScan_11
- // 30 {
- // 31 //if ((KEY_PORT_IN & bitKeyRingNumDec) != bitKeyRingNumDec)
- // 32 case 0:
- // 33 {
- // 34 delay1us(0x0530);//300000);
- ??KeyScan_7:
- MOV.W #0x530, R12
- CALL #delay1us
- // 35 if ((KEY_PORT_IN & bitKeyRingNumDec) != bitKeyRingNumDec)
- BIT.B #0x1, &0x20
- JC ??KeyScan_11
- // 36 {
- // 37 if (gucViewRingNum>0)--gucViewRingNum;//RingNumMax--
- CMP.B #0x1, &aucViewData + 0x6
- JNC ??KeyScan_11
- ADD.B #0xff, &aucViewData + 0x6
- JMP ??KeyScan_11
- // 38 //ViewCommunicationTX(0x01);
- // 39 //ViewCommunicationRX();
- // 40 }
- // 41 break;
- // 42 }//case 0
- // 43
- // 44
- // 45 //if ((KEY_PORT_IN & bitKeyRingNumAdd) != bitKeyRingNumAdd)
- // 46 case 1:
- // 47 {
- // 48 delay1us(0x0530);
- ??KeyScan_8:
- MOV.W #0x530, R12
- CALL #delay1us
- // 49 if ((KEY_PORT_IN & bitKeyRingNumAdd) != bitKeyRingNumAdd)
- BIT.B #0x2, &0x20
- JC ??KeyScan_11
- // 50 {
- // 51 if (gucViewRingNum<9)++gucViewRingNum;//RingNumMax++
- CMP.B #0x9, &aucViewData + 0x6
- JC ??KeyScan_11
- ADD.B #0x1, &aucViewData + 0x6
- JMP ??KeyScan_11
- // 52 //ViewCommunicationTX(0x01);
- // 53 //ViewCommunicationRX();
- // 54 }
- // 55 break;
- // 56 }//case 1
- // 57
- // 58 //ModeSel Key scan: auto or manual send fax signal
- // 59 //if ((KEY_PORT_IN & bitKeyAutoMode) != bitKeyAutoMode)//bitKeyAutoMode==0
- // 60 case 2:
- // 61 {
- // 62 delay1us(0x0530);
- ??KeyScan_9:
- MOV.W #0x530, R12
- CALL #delay1us
- // 63 if ((KEY_PORT_IN & bitKeyAutoMode) != bitKeyAutoMode)
- BIT.B #0x4, &0x20
- JC ??KeyScan_11
- // 64 {
- // 65 gucViewStaticStatus |= bitViewAutoMode;//Auto Mode
- BIS.B #0x10, &aucViewData + 0x7
- // 66 gucViewStaticStatus &= ~bitViewManualMode;//
- BIC.B #0x20, &aucViewData + 0x7
- // 67 gucViewStaticStatus |= bitViewRingNum;
- BIS.B #0x40, &aucViewData + 0x7
- JMP ??KeyScan_11
- // 68
- // 69 //ViewCommunicationTX(0x01);
- // 70 //ViewCommunicationRX();
- // 71 }
- // 72 break;
- // 73 }//case 2
- // 74 //if ((KEY_PORT_IN & bitKeyManualMode) != bitKeyManualMode)
- // 75 case 3:
- // 76 {
- // 77
- // 78 delay1us(0x0530);
- ??KeyScan_10:
- MOV.W #0x530, R12
- CALL #delay1us
- // 79 if ((KEY_PORT_IN & bitKeyManualMode) != bitKeyManualMode)
- BIT.B #0x8, &0x20
- JC ??KeyScan_11
- // 80 {
- // 81 gucViewStaticStatus |= bitViewManualMode;//Manual Mode
- BIS.B #0x20, &aucViewData + 0x7
- // 82 gucViewStaticStatus &= ~bitViewAutoMode; //off atuo
- BIC.B #0x10, &aucViewData + 0x7
- // 83 gucViewStaticStatus &= ~bitViewRingNum;//off ring num
- BIC.B #0x40, &aucViewData + 0x7
- // 84
- // 85 //ViewCommunicationTX(0x01);
- // 86 //ViewCommunicationRX();
- // 87 }
- // 88 break;
- // 89 }//case 3
- // 90
- // 91 }//switch
- // 92 //Driver LCD screen
- // 93 if (((KEY_PORT_IN & bitKeyRingNumDec) != bitKeyRingNumDec) ||
- // 94 ((KEY_PORT_IN & bitKeyRingNumAdd) != bitKeyRingNumAdd) ||
- // 95 ((KEY_PORT_IN & bitKeyAutoMode) != bitKeyAutoMode) ||
- // 96 ((KEY_PORT_IN & bitKeyManualMode) != bitKeyManualMode) )
- ??KeyScan_11:
- BIT.B #0x1, &0x20
- JNC ??KeyScan_12
- BIT.B #0x2, &0x20
- JNC ??KeyScan_12
- BIT.B #0x4, &0x20
- JNC ??KeyScan_12
- BIT.B #0x8, &0x20
- JC ??KeyScan_13
- // 97 //|| ((KEY_PORT_IN & bitKeySendFaxSignal) != bitKeySendFaxSignal))
- // 98 {
- // 99 ViewCommunicationTX(0x01);
- ??KeyScan_12:
- MOV.B #0x1, R12
- CALL #ViewCommunicationTX
- // 100
- // 101 ReadAndWriteViewDataMemory();
- CALL #ReadAndWriteViewDataMemory
- // 102 }
- // 103
- // 104 if (((KEY_PORT_IN & bitKeyRingNumDec) != bitKeyRingNumDec) ||
- // 105 ((KEY_PORT_IN & bitKeyRingNumAdd) != bitKeyRingNumAdd) ||
- // 106 ((KEY_PORT_IN & bitKeyAutoMode) != bitKeyAutoMode) ||
- // 107 ((KEY_PORT_IN & bitKeyManualMode) != bitKeyManualMode))
- ??KeyScan_13:
- BIT.B #0x1, &0x20
- JNC ??KeyScan_0
- BIT.B #0x2, &0x20
- JNC ??KeyScan_0
- BIT.B #0x4, &0x20
- JNC ??KeyScan_0
- BIT.B #0x8, &0x20
- JC ??KeyScan_2
- // 108 //|| ((KEY_PORT_IN & bitKeySendFaxSignal) != bitKeySendFaxSignal))
- // 109 {
- // 110 while (1)
- // 111 {
- // 112 if (((KEY_PORT_IN & bitKeyRingNumDec) == bitKeyRingNumDec) &&
- // 113 ((KEY_PORT_IN & bitKeyRingNumAdd) == bitKeyRingNumAdd) &&
- // 114 ((KEY_PORT_IN & bitKeyAutoMode) == bitKeyAutoMode) &&
- // 115 ((KEY_PORT_IN & bitKeyManualMode) == bitKeyManualMode)) //&&
- ??KeyScan_0:
- BIT.B #0x1, &0x20
- JNC ??KeyScan_0
- BIT.B #0x2, &0x20
- JNC ??KeyScan_0
- BIT.B #0x4, &0x20
- JNC ??KeyScan_0
- BIT.B #0x8, &0x20
- JNC ??KeyScan_0
- // 116 //((KEY_PORT_IN & bitKeySendFaxSignal) == bitKeySendFaxSignal))
- // 117 {
- // 118 delay1us(0x7530);
- MOV.W #0x7530, R12
- CALL #delay1us
- // 119 if (((KEY_PORT_IN & bitKeyRingNumDec) == bitKeyRingNumDec) &&
- // 120 ((KEY_PORT_IN & bitKeyRingNumAdd) == bitKeyRingNumAdd) &&
- // 121 ((KEY_PORT_IN & bitKeyAutoMode) == bitKeyAutoMode) &&
- // 122 ((KEY_PORT_IN & bitKeyManualMode) == bitKeyManualMode))// &&
- BIT.B #0x1, &0x20
- JNC ??KeyScan_0
- BIT.B #0x2, &0x20
- JNC ??KeyScan_0
- BIT.B #0x4, &0x20
- JNC ??KeyScan_0
- BIT.B #0x8, &0x20
- JNC ??KeyScan_0
- // 123 //((KEY_PORT_IN & bitKeySendFaxSignal) == bitKeySendFaxSignal))
- // 124 break;
- // 125 }
- // 126 }
- // 127 //VIEWLEDPORT &= ~bitViewLED;
- // 128 }
- // 129
- // 130 }
- // 131 }
- ??KeyScan_2:
- POP.W R10
- CFI R10 SameValue
- CFI CFA SP+2
- RET
- CFI EndBlock cfiBlock0
- // 132
- RSEG CODE:CODE:NOROOT(1)
- // 133 void ReadAndWriteViewDataMemory(void)
- ReadAndWriteViewDataMemory:
- CFI Block cfiBlock1 Using cfiCommon0
- CFI Function ReadAndWriteViewDataMemory
- // 134 {
- FUNCALL ReadAndWriteViewDataMemory, ReadLast16BytesFromFlashMemoryArea
- LOCFRAME CSTACK, 8, STACK
- FUNCALL ReadAndWriteViewDataMemory, ERASE_ONE_BLOCK
- LOCFRAME CSTACK, 8, STACK
- FUNCALL ReadAndWriteViewDataMemory, Write16Bytes2FlashMemoryArea
- LOCFRAME CSTACK, 8, STACK
- PUSH.W R10
- CFI R10 Frame(CFA, -4)
- CFI CFA SP+4
- PUSH.W R11
- CFI R11 Frame(CFA, -6)
- CFI CFA SP+6
- PUSH.W R8
- CFI R8 Frame(CFA, -8)
- CFI CFA SP+8
- // 135 unsigned char ucBlockCnt=0;
- MOV.B #0x0, R8
- // 136 unsigned char ucRxIndex=0;
- MOV.B #0x0, R10
- // 137 unsigned int wPageAddress=0;
- MOV.W #0x0, R11
- // 138 //ReadLast16BytesFromFlashMemoryArea(cstViewDataAreaStartBlockNum,cstViewDataAreaOverBlockNum);
- // 139 ReadLastViewData();
- MOV.B #0x29, R14
- MOV.B #0x28, R12
- CALL #ReadLast16BytesFromFlashMemoryArea
- // 140 if ((gwGeneralPageAddress>>6) > cstViewDataAreaOverBlockNum)
- MOV.W &gwGeneralPageAddress, R12
- CALL #?ShiftRight16u_6
- CMP.W #0x2a, R12
- JNC ??ReadAndWriteViewDataMemory_2
- // 141 {
- // 142 for (ucBlockCnt=0;ucBlockCnt<2;ucBlockCnt++)
- MOV.B #0x0, R8
- ??ReadAndWriteViewDataMemory_0:
- CMP.B #0x2, R8
- JC ??ReadAndWriteViewDataMemory_3
- // 143 {
- // 144 wPageAddress=(cstViewDataAreaStartBlockNum+ucBlockCnt)<<6;
- MOV.B R8, R12
- AND.W #0xff, R12
- ADD.W #0x28, R12
- CALL #?ShiftLeft16_6
- MOV.W R12, R11
- // 145 ROW_ADDRESS_LOW=wPageAddress & 0XFF;
- MOV.B R11, &ROW_ADDRESS_LOW
- // 146 ROW_ADDRESS_HIGH=(wPageAddress>>8) & 0XFF;
- MOV.W R11, R14
- SWPB R14
- AND.W #0xff, R14
- MOV.B R14, &ROW_ADDRESS_HIGH
- // 147 ERASE_ONE_BLOCK();
- CALL #ERASE_ONE_BLOCK
- // 148 }
- ADD.B #0x1, R8
- JMP ??ReadAndWriteViewDataMemory_0
- // 149 gwGeneralPageAddress=cstViewDataAreaStartPage;
- ??ReadAndWriteViewDataMemory_3:
- MOV.W #0xa00, &gwGeneralPageAddress
- // 150 gwColumnAddress=0;
- MOV.W #0x0, &gwColumnAddress
- // 151 }
- // 152 ucRxIndex=0; //write view data
- ??ReadAndWriteViewDataMemory_2:
- MOV.B #0x0, R10
- // 153 aucUartRxBuf[ucRxIndex++]=gucViewRingNum;
- MOV.B R10, R14
- AND.W #0xff, R14
- MOV.B &aucViewData + 0x6, aucUartRxBuf(R14)
- ADD.B #0x1, R10
- // 154 aucUartRxBuf[ucRxIndex++]=gucViewStaticStatus;
- MOV.B R10, R14
- AND.W #0xff, R14
- MOV.B &aucViewData + 0x7, aucUartRxBuf(R14)
- ADD.B #0x1, R10
- // 155 aucUartRxBuf[ucRxIndex++]=gucViewDynamicStatus;
- MOV.B R10, R14
- AND.W #0xff, R14
- MOV.B &aucViewData + 0x8, aucUartRxBuf(R14)
- ADD.B #0x1, R10
- // 156 aucUartRxBuf[ucRxIndex++]=gucViewDceNewFaxNum;//gucIcon2;
- MOV.B R10, R14
- AND.W #0xff, R14
- MOV.B &aucViewData + 0x9, aucUartRxBuf(R14)
- ADD.B #0x1, R10
- // 157 for (ucBlockCnt=0; ucBlockCnt<12; ucBlockCnt++)
- MOV.B #0x0, R8
- ??ReadAndWriteViewDataMemory_1:
- CMP.B #0xc, R8
- JC ??ReadAndWriteViewDataMemory_4
- // 158 {
- // 159 aucUartRxBuf[ucRxIndex++]=0x55;
- MOV.B R10, R14
- AND.W #0xff, R14
- MOV.B #0x55, aucUartRxBuf(R14)
- ADD.B #0x1, R10
- // 160 }
- ADD.B #0x1, R8
- JMP ??ReadAndWriteViewDataMemory_1
- // 161 Write16Bytes2FlashMemoryArea();
- ??ReadAndWriteViewDataMemory_4:
- CALL #Write16Bytes2FlashMemoryArea
- // 162 }
- POP.W R8
- CFI R8 SameValue
- CFI CFA SP+6
- POP.W R11
- CFI R11 SameValue
- CFI CFA SP+4
- POP.W R10
- CFI R10 SameValue
- CFI CFA SP+2
- RET
- CFI EndBlock cfiBlock1
- RSEG CODE:CODE:NOROOT(1)
- ?setjmp_save_r4:
- REQUIRE ?setjmp_r4
- REQUIRE ?longjmp_r4
- RSEG CODE:CODE:NOROOT(1)
- ?setjmp_save_r5:
- REQUIRE ?setjmp_r5
- REQUIRE ?longjmp_r5
- END
- //
- // 508 bytes in segment CODE
- // 1 byte in segment DATA16_AN
- //
- // 508 bytes of CODE memory
- // 0 bytes of DATA memory (+ 1 byte shared)
- //
- //Errors: none
- //Warnings: none