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

📄 ir.s

📁 IR Decoding source code
💻 S
字号:
; ; Packard Bell IR Remote receiver; ; ;-*                *------------------*       *-------*               *--; |                |                  |       |       |               | ; |                |                  |       |       |               | ; *----------------*                  *-------*       *---------------* ;   low preamble       high preamble    short    high     long low;                                        low     data       data;                                       data             ;        .include         "../include/symbols.f1w.h"        .include         "../lib/serial.h";; Timer equates;MINLP   =     0x11a0           ; Minimum low preambleMAXLP   =     0x1200           ; Maximum low preambleMINHP   =     0x0860           ; Minimum high preambleMAXHP   =     0x08c0           ; Maximum high preambleMINLD   =     0x0100           ; minimum low data pulse lengthMAXLD   =     0x01a0           ; maximum low data pulse lengthMINHDS  =     0x00a0           ; minimum high short data pulse lengthMAXHDS  =     0x0140           ; maximum high short data pulse lengthMINHDL  =     0x0300           ; minimum high long data pulse lengthMAXHDL  =     0x0520           ; maximum high long data pulse length;; RAM variables;        .section       .page0IC3STAT:.skip  1       ;bit 1 - 0 = looking for high preamble, 1 = found high preamble                       ;bit 2 - 0 = looking for low preamble, 1 = found low preamble                       ;bit 3 - 0 = looking for low, 1 = looking for highBITCNT: .skip  1       ;count of bits receivedIC3TIC: .skip  2MESG:   .skip  4       ;received bits bufferDATA:   .skip  1       ;received message        .section       .text;; Program;        .globl          mainmain:;; Initialization Portion;        clr     IC3STAT        clr     DATA;; Serial Port;        ldaa    #0x30           ;19.2k @16Mhz        jsr     serial_init        ldx     #VERSION        jsr     serial_send_string        jsr     serial_send_crlf;; Timer init;        ldx     #REGBS          ; Point to register block        bset    TCTL2,X,#0b00000010 ; IC3 falling edge        bclr    TFLG1,X,#0b11111110 ; clear IC3F        bset    TMSK1,X,#0b00000001 ; enable IC3 interrupts;; Wait for activity;        cli                     ; Enable Interrupts.LOOP1:        tst     DATA        beq     .LOOP1        ldab    DATA        andb    #0x0f        cmpb    #0x07            ;check for lower nibble = 7        bne     .NEXT1        ldx     #TBL_LSB7        bra     .LKUP.NEXT1:        cmpb    #0x0D            ;check for lower nibble = D        bne     .NEXT2        ldx     #TBL_LSBD        bra     .LKUP.NEXT2:        cmpb    #0x0F            ;check for lower nibble = F        bne     .LOOP1        ldx     #TBL_LSBF.LKUP:        ldab    DATA        andb    #0xf0        lsrb        lsrb        lsrb        abx        ldx     0,x             ;lookup string address        jsr     serial_send_string        clr     DATA        jsr     serial_send_crlf        bra     .LOOP1;; IC3 interrupt service routine;        .globl  ic3isric3isr:        psha        pshb        pshx        pshy        ldx     #REGBS          ; Point to register block        ldd     TIC3,X        subd    IC3TIC        brset   TCTL2,X,#0b00000010, .FALLING ; Check state - rising/falling.RISING:        bclr    TCTL2,X,#0b00000001 ; IC3 falling edge next        bset    TCTL2,X,#0b00000010        brset   *IC3STAT #0b00000100 .NOTLOWPREAMBLE        cpd     #MINLP          ; Check minimum low preamble pulse width        bls     .CLRSTATE        cpd     #MAXLP          ; Check maximum low preamble pulse width        bhs     .CLRSTATE        bset    *IC3STAT #0b00000100 ; flag low preamble found        jmp     .SAMPLE.NOTLOWPREAMBLE:        brclr   *IC3STAT #0b00000110 .CLRSTATE ; check for both preambles        brset   *IC3STAT #0b00001000 .CLRSTATE ; not looking for a low        cpd     #MINLD         ; Check minimum low data pulse width        bls     .CLRSTATE        cpd     #MAXLD         ; Check maximum low data pulse width        bhs     .CLRSTATE        bset    *IC3STAT #0b00001000 ; flag looking for a high        jmp     .SAMPLE.FALLING:        bset    TCTL2,X #0b00000001 ; IC3 rising edge next        bclr    TCTL2,X #0b00000010        brset   *IC3STAT #0b00000010, .NOTHIGHPREAMBLE        brclr   *IC3STAT #0b00000100, .CLRSTATE ; must see low preamble first        cpd     #MINHP          ; Check minimum high preamble pulse width        bls     .CLRSTATE        cpd     #MAXHP          ; Check maximum high preamble pulse width        bhs     .CLRSTATE        bset    *IC3STAT #0b00000010 ; flag high preamble        clr     MESG+0          ; Clear data memory        clr     MESG+1        clr     MESG+2        clr     MESG+3        clr     BITCNT        jmp     .SAMPLE.CLRSTATE:        clr     BITCNT        bclr    *IC3STAT #0b01111110 ; Reset state machine        jmp     .SAMPLE.NOTHIGHPREAMBLE:        brclr   *IC3STAT #0b00001110 .CLRSTATE ; check looking for high & both preambles        cpd     #MINHDS          ; Check minimum high short data pulse width        bls     .CLRSTATE        cpd     #MAXHDS          ; Check maximum high short data pulse width        bhs     .NOTSHORTHIGH        bclr    *IC3STAT #0b00001000 ; flag looking for a low        clc                      ; Short high is a zero data        bra     .DATA.NOTSHORTHIGH:        cpd     #MINHDL          ; Check minimum high long data pulse width        bls     .CLRSTATE        cpd     #MAXHDL          ; Check maximum high long data pulse width        bhs     .CLRSTATE        brclr   *IC3STAT #0b00001000, .CLRSTATE ; not looking for a high        bclr    *IC3STAT #0b00001000 ; flag looking for a low        sec                      ; Long high is a one .DATA:        rol     MESG+3              ;rotate new bit into data        rol     MESG+2        rol     MESG+1        rol     MESG+0        inc     BITCNT        ldaa    #32              ;check for 32 bits        cmpa    BITCNT        bne     .SAMPLE        ldaa    MESG+0           ;check for preamble        cmpa    #0x08          bne     .CLRSTATE        ldaa    MESG+1        cmpa    #0xF7        bne     .CLRSTATE        ldaa    MESG+2           ;check message byte are complement        coma        cmpa    MESG+3        bne     .CLRSTATE        staa    DATA        jmp     .CLRSTATE.SAMPLE:        ldd     TIC3,X        std     IC3TIC        bclr    TFLG1,X,#0b11111110    ; Clear IC3F        puly        pulx        pulb        pula        rti;; Version information string;VERSION:        .asciz   "ir.asm $Revision: 1.16 $";; Remote Control Key strings;.IR0F:   .asciz    "DISPLAY".IR17:   .asciz    "IR3".IR1D:   .asciz    "AUX3".IR1F:   .asciz    "AUX1".IR2F:   .asciz    "RIGHT".IR37:   .asciz    "VOLDOWN".IR3D:   .asciz    "IR2".IR3F:   .asciz    "IR8".IR47:   .asciz    "LMOUSE".IR4F:   .asciz    "CHNUP".IR57:   .asciz    "IR9".IR5D:   .asciz    "AUX2".IR5F:   .asciz    "CD".IR6F:   .asciz    "UP".IR77:   .asciz    "MUTE".IR7D:   .asciz    "IR5".IR7F:   .asciz    "IR0".IR8F:   .asciz    "ENTER".IR97:   .asciz    "IR6".IR9D:   .asciz    "SRS".IR9F:   .asciz    "PHONE".IRAF:   .asciz    "DOWN".IRB7:   .asciz    "VOLUP".IRBD:   .asciz    "IR1".IRBF:   .asciz    "IR7".IRC7:   .asciz    "RMOUSE".IRCF:   .asciz    "CHNDOWN".IRD7:   .asciz    "HASH".IRDD:   .asciz    "MESSAGE".IRDF:   .asciz    "HELP".IREF:   .asciz    "LEFT".IRF7:   .asciz    "MENU".IRFD:   .asciz    "IR4".IRFF:   .asciz    "STAR".IRERROR:.asciz    "ERROR";; string lookup table;TBL_LSB7:        .word    .IRERROR        .word    .IR17        .word    .IRERROR        .word    .IR37        .word    .IR47        .word    .IR57        .word    .IRERROR        .word    .IR77        .word    .IRERROR        .word    .IR97        .word    .IRERROR        .word    .IRB7        .word    .IRC7        .word    .IRD7        .word    .IRERROR        .word    .IRF7TBL_LSBD:        .word    .IRERROR        .word    .IR1D        .word    .IRERROR        .word    .IR3D        .word    .IRERROR        .word    .IR5D        .word    .IRERROR        .word    .IR7D        .word    .IRERROR        .word    .IR9D        .word    .IRERROR        .word    .IRBD        .word    .IRERROR        .word    .IRDD        .word    .IRERROR        .word    .IRFDTBL_LSBF:        .word    .IR0F        .word    .IR1F        .word    .IR2F        .word    .IR3F        .word    .IR4F        .word    .IR5F        .word    .IR6F        .word    .IR7F        .word    .IR8F        .word    .IR9F        .word    .IRAF        .word    .IRBF        .word    .IRCF        .word    .IRDF        .word    .IREF        .word    .IRFF

⌨️ 快捷键说明

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