⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 message_handler.lst

📁 PKE(被动无钥门禁系统
💻 LST
📖 第 1 页 / 共 5 页
字号:
MPASM 03.90.01 Released                   MESSAGE_HANDLER.ASM   11-21-2005  16:07:18         PAGE  1


LOC  OBJECT CODE     LINE SOURCE TEXT
  VALUE

                      00001 ;/*
                      00002 ; Message_Handler.asm
                      00003 ;       Jan Ornter
                      00004 ;
                      00005 ;       DATE:   11-9-2005
                      00006 ;       VER.:   1.0
                      00007 ;       This class handles the incoming messages
                      00008 ;       
                      00009 ;       
                      00010 ;       The function MESSAGE_HANDLER will be called, everytime the rx line goes high.
                      00011 ;       After it is called, the REC_EVENTS will be disabled.
                      00012 ;       To ensure that the function is been called at the right time, the 
                      00013 ;       rx line should still be high, if not the function will end without 
                      00014 ;       trying to receive more bits. When this is not the case, LF.Receive8 
                      00015 ;       will be called, to receive the command from the base station.
                      00016 ;       The received byte will be interpreted as a command and the command 
                      00017 ;       specific code will be executeted. For a more detailed description of 
                      00018 ;       the function, see the flow chart below or refer to the source code.
                      00019 ;       At last the REC_EVENT will be enabled and the subroutine ends.
                      00020 ;
                      00021 ;       @timingdiagram Basestation first hand shake
                      00022 ;           |<   LF-Header        >|< 10-bits  = command(ID)+ Parity + 1 stop bit  >|
                      00023 ;            __________   ____      _   _
                      00024 ;       ____|          |_|    |____| |_| |_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 
                      00025 ;
                      00026 ;
                      00027 ;
                      00028 ;       @timingdiagram Transponder first hand shake
                      00029 ;           |<   LF-Header        >|< 32 bits ID + 4 Parity bits >|
                      00030 ;            __________   ____      _   _
                      00031 ;       ____|          |_|    |____| |_| |_XXXXXXXXXXXXXXXXXXXXXXX 
                      00032 ;
                      00033 ;
                      00034 ;       @timingdiagram Basestation second hand shake
                      00035 ;           |<   LF-Header        >|< 46-bits  = IFF command(8bits)+ P+ 32bits(challenge) + 4P +1 stop b
                            it  >|
                      00036 ;            __________   ____      _   _
                      00037 ;       ____|          |_|    |____| |_| |_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
                            XXXXX 
                      00038 ;
                      00039 ;
                      00040 ;
                      00041 ;       @timingdiagram Transponder second hand shake
                      00042 ;           |<   LF-Header        >|< sendback the 32 challenge bits + 4 Parity bits >|
                      00043 ;            __________   ____      _   _
                      00044 ;       ____|          |_|    |____| |_| |_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 
                      00045 ;
                      00046 ;
                      00047 
                      00048 ;
                      00049 ;*/
                      00050 #include        Project.inc
                      00001 
MPASM 03.90.01 Released                   MESSAGE_HANDLER.ASM   11-21-2005  16:07:18         PAGE  2


LOC  OBJECT CODE     LINE SOURCE TEXT
  VALUE

                      00002 
                      00003         list p=16F636                           ; list directive to define processor
                      00004         #include <p16f636.inc>      ; processor specific variable definitions
                      00001         LIST
                      00002 ; P16F636.INC  Standard Header File, Version 1.00    Microchip Technology, Inc.
                      00317         LIST
                      00005 
                      00006         ERRORLEVEL 0,-302,-312  ; Messages, Warnings and Errors Printed
                      00007                                         ; Ignore [301] => Processor Mismatch. 
                      00008                                         ; Ignore [302] => Register in operand not in bank 0. 
                      00009                                                                 ; Ignore [312] => Pagesel not needed for
                             Device
                      00051 #include        PIC16F639.inc
                      00001 
                      00002 #define CommsLED        PORTC,0         ; LED D4
                      00003 #define ErrorLED        PORTA,5         ; LED D5
                      00004 
                      00005 
                      00006 
                      00007 #define LFDATA          PORTC,3         ; Low Frequency Data IN
                      00008 
                      00009 #define REC_EVENT       4
                      00010 #define IDLE            6
                      00011 #define RF_START        7
                      00012 #define RF_Button       0
                      00013 
                      00014 
                      00015         ifndef MSG_INTERRUPT
                      00016         #define MSG_INTERRUPT   (1<<REC_EVENT)
                      00017         endif
                      00018 
                      00019 
                      00020         ifndef BUTTON_MASK
                      00021         #define BUTTON_MASK             B'00000001'
                      00022         endif
                      00023 
                      00024 
                      00025 ;/*
                      00026 ;       This register indicates the occurred events
                      00027 ;
                      00028 ;       @bitfield       N.A. | IDLE | RA5_EVENT | MSG_INTERRUPT | RA3_EVENT | RA2_EVENT | RA1_EVENT | RA
                            0_EVENT |
                      00029 ;
                      00030 ;*/
  0000                00031         extern  EVENT_REG
                      00032 ;/*
                      00033 ;       This register is a copy of PORTA, when the last button event occured
                      00034 ;*/
  0000                00035         extern  Button_old
                      00036 ;/*
                      00037 ;       Referrence to the DATA in the EEPROM.
                      00038 ;       The first four bytes are the Serial number
                      00039 ;       The next eight bytes are the Encryption Key
MPASM 03.90.01 Released                   MESSAGE_HANDLER.ASM   11-21-2005  16:07:18         PAGE  3


LOC  OBJECT CODE     LINE SOURCE TEXT
  VALUE

                      00040 ;*/
  0000                00041         extern  EE_DATA
                      00042 ;/*
                      00043 ;       Referrence to the beginning of userspace EEPROM memory.
                      00044 ;       The following 8 bytes are reserved for that purpose.
                      00045 ;*/
  0000                00046         extern  EE_USER
                      00047 
                      00048 
  0000                00049         extern  BUTTON_DELAY
                      00052 #include        LF.inc
                      00001 #ifndef LF_INC
                      00002 #define LF_INC
                      00003 
  0000                00004         extern  LF.Send8, LF.Receive8, LF.ReadBuffer, LF.SendBuffer
                      00005 
                      00006 
                      00007         #define LF.DATAIN               PORTC,3
                      00008 
                      00009 
                      00010 #endif
                      00053 #include        RF.inc
                      00001 
                      00002 #ifndef RF_INC
                      00003 #define RF_INC
                      00004 
                      00005 
                      00006 #ifndef RF.PIN
                      00007         #define RF.PIN          5               ; RF Modulation Output
                      00008         #define RF.PORT         PORTC
                      00009 #endif
  0000                00010         extern RF.Send_Header, RF.Send_Data, RF.SendBuffer
                      00011 
                      00012 
                      00013 
                      00014 ;/*
                      00015 ;
                      00016 ;       This macro initialises the RF module.
                      00017 ;       Initialize the Delay module first.
                      00018 ;
                      00019 ;*/
                      00020 RF.Init macro
                      00021         banksel TRISA
                      00022         bcf             RF.PORT,RF.PIN
                      00023         endm
                      00024 
                      00025 
                      00026 #endif
                      00054 #include        EEPROM.inc
                      00001 #ifndef EEPROM_INC
                      00002 #define EEPROM_INC
                      00003 
                      00004         #define EEPROM.RamAddress
MPASM 03.90.01 Released                   MESSAGE_HANDLER.ASM   11-21-2005  16:07:18         PAGE  4


LOC  OBJECT CODE     LINE SOURCE TEXT
  VALUE

                      00005 
                      00006 ;/*
                      00007 ;       The address in the EEPROM for the next operation on it.
                      00008 ;*/
  0000                00009         extern EEPROM.ADDRESS
  0000                00010         extern EEPROM.ByteCount
  0000                00011         extern EEPROM.Write, EEPROM.WriteBytes, EEPROM.Read, EEPROM.ReadBytes
                      00012 
                      00013 
                      00014 ;/*
                      00015 ;
                      00016 ;       This macro initialises the EEPROM module
                      00017 ;
                      00018 ;       @example
                      00019 ;       EEPROM.Init             ;initialises the EEPROM module
                      00020 ;       @end-ex
                      00021 ;       @ex-desc That's it
                      00022 ;
                      00023 ;       @status Tested
                      00024 ;
                      00025 ;       @stacklevel 0
                      00026 ;
                      00027 ;       @registers EEDATA, EEADR, EECON1, EECON1
                      00028 ;
                      00029 ;
                      00030 ;*/
                      00031 EEPROM.Init     macro
                      00032         banksel EEADR
                      00033         CLRF    EEDAT
                      00034         CLRF    EEADR
                      00035         CLRF    EECON1
                      00036         CLRF    EECON2
                      00037         endm
                      00038 
                      00039 
                      00040 #endif
                      00055 #include        Delay.inc
                      00001 #ifndef DELAY_INC
                      00002 #define DELAY_INC
                      00003 
                      00004 
                      00005 #define Delay.Returned  Delay.flag,3
                      00006 
  0000                00007         extern Delay.wait_w_x_50us, Delay.flag, Delay.Counter
  0000                00008         extern Delay.start, Delay.Wait
                      00009 ;
                      00010 ;
                      00011 ;       This macro initialises the delay module
                      00012 ;
                      00013 ;
                      00014 ;Delay.Init macro
                      00015 ;       banksel OPTION_REG
                      00016 ;       MOVLW   b'00000000'             ; SET UP FOR TMR0'S PRESCALER VALUE TO 1
MPASM 03.90.01 Released                   MESSAGE_HANDLER.ASM   11-21-2005  16:07:18         PAGE  5


LOC  OBJECT CODE     LINE SOURCE TEXT
  VALUE

                      00017 ;                                                       ; (RAPU, bit7) = 0 to enable weak pull-up for Po
                            rtA also 
                      00018 ;       MOVWF   OPTION_REG              ; this is used for Delay loop only
                      00019 ;       endm
                      00020 
                      00021 ;/*
                      00022 ;
                      00023 ;       This macro waits for up to 12 ms.
                      00024 ;       The time has to be a multible of 50us.
                      00025 ;       It is just added to enhance readability of the source code.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -