📄 adsbin.c
字号:
/*********************************************************************
* FileName: adsbin.c
* Dependencies: See INCLUDES section below
* Processor: PIC18
* Compiler: C18 2.30.01+
* Company: sprut
* Copyright: 2007-2010 Joerg Bredendiek (sprut)
*
*
********************************************************************/
/*
* 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.
*/
/** I N C L U D E S **********************************************************/
#include <p18cxxx.h>
#include <usart.h>
#include "system\typedefs.h"
#include "system\usb\usb.h"
#include "io_cfg.h" // I/O pin mapping
#include "delays.h"
//#include "system\interrupt\interrupt.h"
#include "user\user.h"
#include "user\adsbin.h"
/** V A R I A B L E S ********************************************************/
#pragma udata
/** D E C L A R A T I O N S **************************************************/
#pragma code
// 0x2E ... 0x34 ...0x39 ... 0x3B
// AAA0 ... AAA6 ...AAA11 ... AAA13
// Warten und finden eines Datenblocks
// wenn er gefunden wird, dann
// Einschreiben in adsb[0..13]
// 56Bit:Lang=0 / 112Bit:Lang=1
// Rueckkehr mit w=0
// wenn er NICHT gefunden wird, dann
// Rueckkehr mit w=1
// Anzahl der Suchschleifen: adsbLoopH-adsbLoopL
// 25600 Schleifen in 15 ms => 0.6 us pro Schleife ~ 7 Befehle
char adsb_in(void)
{
_asm
BCF INTCON, GIEH, A
BCF PORTC, 1, A // HDR_OUT
BRA Start_Hdr
// Fehler im Datenblock
Error_Data:
// Einstieg: gerufen von 03F46
// Fehler im Header
Error_Hdr:
//BTFSC 0x16, 0, 1 // wird gesetzt wenn usart was empfaengt
DECFSZ adsbLoopL, F, 1 // 255 erfolglose Leseversuche, outer loop
BRA Start_Hdr // neuer Versuch
DECFSZ adsbLoopH, F, 1
BRA Start_Hdr
BSF INTCON, GIEH, A
MOVLW 1 // true, Fehler, nichts empfangen
RETURN 0
// Einlesen : ist das ein Header ?
Start_Hdr:
BTFSC PORTC, 0, A // 1
BTFSS PORTC, 0, A // 0,166 us lang
M04262:
BRA Error_Hdr
M04264:
MOVF TMR1L, W, A
MOVWF Zeit, 1
NOP
BTFSS PORTC, 0, A // 0
BTFSC PORTC, 0, A
M0426E:
BRA Error_Hdr
M04270:
NOP
NOP
NOP
BTFSC PORTC, 0, A // 1
BTFSS PORTC, 0, A
M0427A:
BRA _Skip_Pulse // es wurde erst der 2. Puls gefunden, deshalb vorspringen
M0427C:
NOP
NOP
NOP
BTFSS PORTC, 0, A // 0
BTFSC PORTC, 0, A
M04286:
BRA Error_Hdr
M04288:
NOP
NOP
NOP
BTFSS PORTC, 0, A // 0
BTFSC PORTC, 0, A
M04292:
BRA Error_Hdr
M04294:
NOP
_Skip_Pulse:
NOP
NOP
BTFSS PORTC, 0, A // 0
BTFSC PORTC, 0, A
M0429E:
BRA Error_Hdr
M042A0:
NOP
NOP
NOP
BTFSS PORTC, 0, A // 0
BTFSC PORTC, 0, A
M042AA:
BRA Error_Hdr
M042AC:
NOP
NOP
NOP
BTFSC PORTC, 0, A // 1
BTFSS PORTC, 0, A
M042B6:
BRA Error_Hdr
M042B8:
NOP
NOP
NOP
BTFSS PORTC, 0, A // 0
BTFSC PORTC, 0, A
M042C2:
BRA Error_Hdr
M042C4:
NOP
NOP
NOP
BTFSC PORTC, 0, A // 1
BTFSS PORTC, 0, A
M042CE:
BRA Error_Hdr
M042D0:
NOP
NOP
NOP
BTFSS PORTC, 0, A // 0
BTFSC PORTC, 0, A
M042DA:
BRA Error_Hdr
M042DC:
NOP
NOP
NOP
BTFSS PORTC, 0, A // 0
BTFSC PORTC, 0, A
M042E6:
BRA Error_Hdr
M042E8:
NOP
NOP
NOP
BTFSS PORTC, 0, A // 0
BTFSC PORTC, 0, A
M042F2:
BRA Error_Hdr
M042F4:
NOP
NOP
NOP
BTFSS PORTC, 0, A // 0
BTFSC PORTC, 0, A
M042FE:
BRA Error_Hdr
M04300:
NOP
NOP
NOP
BTFSS PORTC, 0, A // 0
BTFSC PORTC, 0, A
M0430A:
BRA Error_Hdr
M0430C:
NOP
NOP
NOP
BTFSS PORTC, 0, A // 0
BTFSC PORTC, 0, A
M04316:
BRA Error_Hdr
// es folgt der Datenblock
// 5 Bit Format-Number
//Lang = 0
// DF00 00000 56 bit
// DF04 00100 56 bit
// DF05 00101 56 bit
// DF11 01011 56 bit
// Lang = 1
// DF16 10000 112 bit
// DF17 10001 112 bit
// DF19 10011 112 bit
// DF20 10100 112 bit
// DF21 10101 112 bit
// DF22 10110 112 bit
// DF24 11000 112 bit
//
// das erste Bit unterscheidet zwischen 56 und 112 bit
M04318:
NOP
BCF PORTC, 2, A // altes frame nun ungueltig
BSF PORTC, 1, A
RRCF PORTC, W, A
RLCF AAA0, F, 1
CLRF Lang, 1 // 56 oder 112 bit noch unbekannt //CLRF 0x14, 1
BTFSC AAA0, 0, 1 // Test 56 oder 112 Bit ?
INCF Lang, F, 1 // 112 Bit : 0x14=1 //INCF 0x14, F, 1
M04328:
NOP
MOVF PORTC, W, A
XORWF AAA0, W, 1
ANDLW 0x01
BZ Error_Data // Fehler im Datenblock
NOP
NOP
RRCF PORTC, W, A
RLCF AAA0, F, 1
NOP
NOP
NOP
NOP
MOVF PORTC, W, A
XORWF AAA0, W, 1
ANDLW 0x01
BNZ M0434C
BRA Error_Data
M0434C:
NOP
RRCF PORTC, W, A
RLCF AAA0, F, 1
NOP
NOP
NOP
NOP
MOVF PORTC, W, A
XORWF AAA0, W, 1
ANDLW 0x01
BNZ M04364
BRA Error_Data
M04364:
NOP
RRCF PORTC, W, A
RLCF AAA0, F, 1
NOP
NOP
NOP
NOP
MOVF PORTC, W, A
XORWF AAA0, W, 1
ANDLW 0x01
BNZ M0437C
BRA Error_Data
M0437C:
NOP
RRCF PORTC, W, A
RLCF AAA0, F, 1
NOP
NOP
NOP
NOP
MOVF PORTC, W, A
XORWF AAA0, W, 1
ANDLW 0x01
BNZ M04394
BRA Error_Data
M04394:
NOP
RRCF PORTC, W, A
RLCF AAA0, F, 1
NOP
NOP
NOP
NOP
MOVF PORTC, W, A
XORWF AAA0, W, 1
ANDLW 0x01
BNZ M043AC
BRA Error_Data
M043AC:
NOP
RRCF PORTC, W, A
RLCF AAA0, F, 1
NOP
NOP
NOP
NOP
MOVF PORTC, W, A
XORWF AAA0, W, 1
ANDLW 0x01
BNZ M043C4
BRA Error_Data
M043C4:
NOP
RRCF PORTC, W, A
RLCF AAA0, F, 1
NOP
NOP
NOP
BSF ADCON0, 1, A
MOVF PORTC, W, A
XORWF AAA0, W, 1
ANDLW 0x01
BNZ M043DC
BRA Error_Data
M043DC:
NOP
RRCF PORTC, W, A
RLCF AAA1, F, 1
NOP
NOP
NOP
NOP
MOVF PORTC, W, A
XORWF AAA1, W, 1
ANDLW 0x01
BNZ M043F4
BRA Error_Data
M043F4:
NOP
RRCF PORTC, W, A
RLCF AAA1, F, 1
NOP
NOP
NOP
NOP
MOVF PORTC, W, A
XORWF AAA1, W, 1
ANDLW 0x01
BNZ M0440C
BRA Error_Data
M0440C:
NOP
RRCF PORTC, W, A
RLCF AAA1, F, 1
NOP
NOP
NOP
NOP
MOVF PORTC, W, A
XORWF AAA1, W, 1
ANDLW 0x01
BNZ M04424
BRA Error_Data
M04424:
NOP
RRCF PORTC, W, A
RLCF AAA1, F, 1
NOP
NOP
NOP
NOP
MOVF PORTC, W, A
XORWF AAA1, W, 1
ANDLW 0x01
BNZ M0443C
BRA Error_Data
M0443C:
NOP
RRCF PORTC, W, A
RLCF AAA1, F, 1
NOP
NOP
NOP
NOP
MOVF PORTC, W, A
XORWF AAA1, W, 1
ANDLW 0x01
BNZ M04454
BRA Error_Data
M04454:
NOP
RRCF PORTC, W, A
RLCF AAA1, F, 1
NOP
NOP
NOP
NOP
MOVF PORTC, W, A
XORWF AAA1, W, 1
ANDLW 0x01
BNZ M0446C
BRA Error_Data
M0446C:
NOP
RRCF PORTC, W, A
RLCF AAA1, F, 1
NOP
NOP
NOP
NOP
MOVF PORTC, W, A
XORWF AAA1, W, 1
ANDLW 0x01
BNZ M04484
BRA Error_Data
M04484:
NOP
RRCF PORTC, W, A
RLCF AAA1, F, 1
NOP
NOP
NOP
NOP
MOVF PORTC, W, A
XORWF AAA1, W, 1
ANDLW 0x01
BNZ M0449C
BRA Error_Data
M0449C:
NOP
RRCF PORTC, W, A
RLCF AAA2, F, 1
NOP
NOP
NOP
NOP
MOVF PORTC, W, A
XORWF AAA2, W, 1
ANDLW 0x01
BNZ M044B4
BRA Error_Data
M044B4:
NOP
RRCF PORTC, W, A
RLCF AAA2, F, 1
NOP
NOP
NOP
NOP
MOVF PORTC, W, A
XORWF AAA2, W, 1
ANDLW 0x01
BNZ M044CC
BRA Error_Data
M044CC:
NOP
RRCF PORTC, W, A
RLCF AAA2, F, 1
NOP
NOP
NOP
NOP
MOVF PORTC, W, A
XORWF AAA2, W, 1
ANDLW 0x01
BNZ M044E4
BRA Error_Data
M044E4:
NOP
RRCF PORTC, W, A
RLCF AAA2, F, 1
NOP
NOP
NOP
NOP
MOVF PORTC, W, A
XORWF AAA2, W, 1
ANDLW 0x01
BNZ M044FC
BRA Error_Data
M044FC:
NOP
RRCF PORTC, W, A
RLCF AAA2, F, 1
NOP
NOP
NOP
NOP
MOVF PORTC, W, A
XORWF AAA2, W, 1
ANDLW 0x01
BNZ M04514
BRA Error_Data
M04514:
NOP
RRCF PORTC, W, A
RLCF AAA2, F, 1
NOP
NOP
NOP
NOP
MOVF PORTC, W, A
XORWF AAA2, W, 1
ANDLW 0x01
BNZ M0452C
BRA Error_Data
M0452C:
NOP
RRCF PORTC, W, A
RLCF AAA2, F, 1
NOP
NOP
NOP
NOP
MOVF PORTC, W, A
XORWF AAA2, W, 1
ANDLW 0x01
BNZ M04544
BRA Error_Data
M04544:
NOP
RRCF PORTC, W, A
RLCF AAA2, F, 1
NOP
NOP
NOP
NOP
MOVF PORTC, W, A
XORWF AAA2, W, 1
ANDLW 0x01
BNZ M0455C
BRA Error_Data
M0455C:
NOP
RRCF PORTC, W, A
RLCF AAA3, F, 1
NOP
NOP
NOP
NOP
MOVF PORTC, W, A
XORWF AAA3, W, 1
ANDLW 0x01
BNZ M04574
BRA Error_Data
M04574:
NOP
RRCF PORTC, W, A
RLCF AAA3, F, 1
NOP
NOP
NOP
NOP
MOVF PORTC, W, A
XORWF AAA3, W, 1
ANDLW 0x01
BNZ M0458C
BRA Error_Data
M0458C:
NOP
RRCF PORTC, W, A
RLCF AAA3, F, 1
NOP
NOP
NOP
NOP
MOVF PORTC, W, A
XORWF AAA3, W, 1
ANDLW 0x01
BNZ M045A4
BRA Error_Data
M045A4:
NOP
RRCF PORTC, W, A
RLCF AAA3, F, 1
NOP
NOP
NOP
NOP
MOVF PORTC, W, A
XORWF AAA3, W, 1
ANDLW 0x01
BNZ M045BC
BRA Error_Data
M045BC:
NOP
RRCF PORTC, W, A
RLCF AAA3, F, 1
NOP
NOP
NOP
NOP
MOVF PORTC, W, A
XORWF AAA3, W, 1
ANDLW 0x01
BNZ M045D4
BRA Error_Data
M045D4:
NOP
RRCF PORTC, W, A
RLCF AAA3, F, 1
NOP
NOP
NOP
NOP
MOVF PORTC, W, A
XORWF AAA3, W, 1
ANDLW 0x01
BNZ M045EC
BRA Error_Data
M045EC:
NOP
RRCF PORTC, W, A
RLCF AAA3, F, 1
NOP
NOP
NOP
NOP
MOVF PORTC, W, A
XORWF AAA3, W, 1
ANDLW 0x01
BNZ M04604
BRA Error_Data
M04604:
NOP
RRCF PORTC, W, A
RLCF AAA3, F, 1
NOP
NOP
NOP
NOP
MOVF PORTC, W, A
XORWF AAA3, W, 1
ANDLW 0x01
BNZ M0461C
BRA Error_Data
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -