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

📄 pbir.asm

📁 IR Decoding source code
💻 ASM
字号:
;; Packard Bell Infrared Remote receiver;; Copyright (C) 2000-1 Tom Parker   (tom-hc11@wiresncode.com); Portions Copyright (C) 2000 Paul Stoffregen (paul@pjrc.com);; This program is free software; you can redistribute it and/or; modify it under the terms of the GNU General Public License; as published by the Free Software Foundation; either version 2; of the License, or (at your option) any later version.;; This program is distributed in the hope that it will be useful,; but WITHOUT ANY WARRANTY; without even the implied warranty of; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the; GNU General Public License for more details.;; You should have received a copy of the GNU General Public License; along with this program; if not, write to the Free Software; Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.;; Author's note: This is free software, for commerical use I would; appreciate some recognition though.  If you are using this and like; it send me some email or a postcard.  Code changes for inclusion; are also welcome.;; Tom Parker, PO Box 2165, Fitzroy, VIC, 3065, AUSTRALIA (tom@wiresncode.com);.include "pbir.h".include "../serial/serial.h";;---------------------------------------------------------; ; ;-*                *------------------*       *-------*               *-------*; |                |                  |       |       |               |       |; |                |                  |       |       |               |       |; *----------------*                  *-------*       *---------------*       *---; ^                                   ^               ^                       ^; |             preamble              |      zero     |              one      |;;minpre = 0x3080			;Minimum preamble lengthmaxpre = 0x3100 		;Maximum preamble lengthminzero = 0x03f0		;Minimum zero pulse lengthmaxzero = 0x0430		;Maximum zero pulse lengthminone = 0x07f0			;Minimum one pulse lengthmaxone = 0x0830			;Maximum one pulse length; typical sequence;; 30 A0 ; 04 0F 04 0F 03 F9 04 10 08 22 03 FB 04 25 03 F8 08 12 08 0D 08 21 08 11 04 0E 08 23 07 FB ; 08 20 08 13 04 0C 04 0E 08 0F 03 FC 04 10 04 0D 04 11 04 0E 07 FB 08 22 04 0E 08 10 08 23;---------------------------------------------------------;	.module pbir_asm	.area	code (REL);;Initialisation;pbir_init:	mov	irmesg+0, #0	mov	irmesg+1, #0	mov	irbitcnt, #0	mov	ircode, #0xff	clr	irprefound	ret;;save current timer & enable interrupts;pbir_start:	mov	irtimersample+0, th0	mov	irtimersample+1, tl0	setb	ea	ret;;interrupt service routine;pbir_isr:	clr	ea	push	acc	clr	rs1			;register bank 1	setb	rs0	clr	tr0	mov	r6, th0			;save new timer sample	mov	r7, tl0	setb	tr0	mov	a, r6	mov	r4, a	mov	a, r7			;subtract lsb from previous	clr	c	subb	a, irtimersample+1	jnc	i0noborrow	dec	r4			;borrow from msbi0noborrow:	mov	r5, a	mov	a, r4			;subtract msb from previous	clr	c	subb	a, irtimersample+0	mov	r4, a	mov	irtimersample+0, r6	mov	irtimersample+1, r7i0zmsbmax:	add	a, #255 - (maxzero >> 8)	jc	i0omsbmax                ;check zero msb maximum	inc	a	jnz	i0zmsbmin	mov	a, r5			;check lsb maximum	add	a, #255 - (maxzero & 0x00ff)	jc	i0omsbmaxi0zmsbmin:	mov	a, r4	add	a, #255 - (minzero >> 8) + 1	jnc	i0invalid		;check msb minimum	jnz	i0zerofound	mov	a, r5			;check lsb minimum	clr	c	subb	a, #(minzero & 0x00ff)	jc	i0invalidi0zerofound:	jnb	irprefound, i0invalid	clr	c	sjmp	i0datafoundi0invalid:	clr	irprefound	ajmp	i0donei0omsbmax:	mov	a, r4	add	a, #255 - (maxone >> 8)	jc	i0pmsbmax                ;check zero msb maximum	inc	a	jnz	i0omsbmin	mov	a, r5			;check lsb maximum	add	a, #255 - (maxone & 0x00ff)	jc	i0pmsbmaxi0omsbmin:	mov	a, r4	add	a, #255 - (minone >> 8) + 1	jnc	i0invalid		;check msb minimum	jnz	i0onefound	mov	a, r5			;check lsb minimum	clr	c	subb	a, #(minone & 0x00ff)	jc	i0invalidi0onefound:	jnb	irprefound, i0invalid	setb	ci0datafound:	mov	a, irmesg+0	rlc	a	mov	irmesg+0, a	mov	a, irmesg+1	rlc	a	mov	irmesg+1, a	dec	irbitcnt	mov	a, irbitcnt	jz	i0mesg			;whole mesg?	cjne	a, #16, i0done		;first 2 bytes?	mov	a, irmesg+1		;check for control ID	cjne	a, #0x08, i0invalid	mov	a, irmesg+0	cjne	a, #0xf7, i0invalid	sjmp	i0donei0mesg:	mov	a, ircode		;check previous mesg was received	cjne	a, #0xff, i0invalid	mov	a, irmesg+0		;check new mesg	xrl	a, #0xff	cjne	a, irmesg+1, i0invalid	mov	ircode, a	clr	irprefound		sjmp	i0donei0pmsbmax:	mov	a, r4	add	a, #255 - (maxpre >> 8)	jc	i0invalid                ;check msb maximum	inc	a	jnz	i0pmsbmin	mov	a, r5			;check lsb maximum	add	a, #255 - (maxpre & 0x00ff)	jc	i0invalidi0pmsbmin:	mov	a, r4	add	a, #255 - (minpre >> 8) + 1	jnc	i0invalid		;check msb minimum	jnz	i0prefound	mov	a, r5			;check lsb minimum	clr	c	subb	a, #(minpre & 0x00ff)	jc	i0invalidi0prefound:	setb	irprefound		;flag preamble and clear message buffer	mov	irmesg+0, #0	mov	irmesg+1, #0	mov	irbitcnt, #32i0done:	pop	acc	setb	ea	clr	rs1			;register bank 0	clr	rs0	reti

⌨️ 快捷键说明

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