📄 level2.h
字号:
/*
*-------------------------------------------------------------------------------
*-- RCSId: $Id: level2.h,v 1.50 2005-04-12 14:54:27+02 mjg Exp mjg $
*-- $Name: $
*-------------------------------------------------------------------------------
*-- level2.c - Low level data transforming header file
*-------------------------------------------------------------------------------
*-- $Log: level2.h,v $*-- Revision 1.50 2005-04-12 14:54:27+02 mjg*-- switch to normal mode*--*-- Revision 1.49 2005-03-21 17:01:04+01 mjg*-- Uplink timing tuned*--*-- Revision 1.47 2005-02-28 13:35:30+01 mjg*-- EM4006 uid crc check*--*-- Revision 1.46 2005-02-25 11:23:13+01 mjg*-- EM4006 extraction routine, no crc check*--*-- Revision 1.45 2005-02-25 11:19:41+01 mjg*-- EM4006 extraction routine, no crc check*--
*-- Revision 1.44 2005-02-25 09:12:49+01 mjg
*-- EM4006 decode mode
*--
*-- Revision 1.43 2005-02-23 16:04:15+01 mjg
*-- EM4006 raw mode, not tested
*--
*-- Revision 1.42 2005-02-21 18:13:55+01 mjg
*-- hubneme IV
*--
*-- Revision 1.41 2005-02-21 10:56:31+01 mjg
*-- hubneme III
*--
*-- Revision 1.40 2005-02-21 10:47:42+01 mjg
*-- hubneme III
*--
*-- Revision 1.39 2005-02-21 10:45:25+01 mjg
*-- hubneme III
*--
*-- Revision 1.38 2005-01-19 15:53:51+01 mjg
*-- EM4034 EAS off support corrected
*--
*-- Revision 1.37 2004-12-13 08:49:33+01 mjg
*-- compiler sensitive code in HWTransaction
*--
*-- Revision 1.36 2004-12-07 17:22:17+01 mjg
*-- version 4 of 1TS ready
*--
*-- Revision 1.35 2004-12-07 15:22:21+01 mjg
*-- 1.33 strikes back!
*--
*-- Revision 1.33 2004-06-30 12:47:41+02 mjg
*-- key selection extension
*--
*-- Revision 1.32 2004-05-31 16:41:51+02 mjg
*-- single carrier too slow caused CRC errors, speeded up
*--
*-- Revision 1.31 2004-05-21 09:29:37+02 mjg
*-- startup inventory, to toggle EAS off for EM4034
*--
*-- Revision 1.30 2004-05-10 09:23:28+02 mjg
*-- to toggle EAS off
*--
*-- Revision 1.29 2004-05-07 08:10:25+02 mjg
*-- HW auth passed
*--
*-- Revision 1.28 2004-04-27 17:05:44+02 mjg
*-- to better test the design
*--
*-- Revision 1.27 2004-04-21 15:48:47+02 mjg
*-- FSK low data rate support
*--
*-- Revision 1.26 2004-04-21 13:05:21+02 mjg
*-- EOF ignored because of FSK and 4034 support
*--
*-- Revision 1.25 2004-04-13 11:21:39+02 mjg
*-- sync
*--
*-- Revision 1.24 2004-03-25 16:09:19+01 mjg
*-- to add delayed EOF feature
*--
*-- Revision 1.23 2004-03-25 15:13:23+01 mjg
*-- to add delayed EOF feature
*--
*-- Revision 1.22 2004-03-24 13:35:36+01 mjg
*-- error msg needs better handling
*--
*-- Revision 1.21 2004-03-15 16:59:06+01 mjg
*-- to check SPI
*--
*-- Revision 1.20 2004-02-16 08:04:11+01 mjg
*-- preliminary CD
*--
*-- Revision 1.18 2004-02-10 19:24:40+01 mjg
*-- FSK to add valid bits
*--
*-- Revision 1.17 2004-02-10 18:30:46+01 mjg
*-- dual carrier raw, decoded 1st try
*--
*-- Revision 1.16 2004-02-09 18:03:33+01 mjg
*-- raw dual carrier capture
*--
*-- Revision 1.15 2004-02-08 12:30:52+01 mjg
*-- Decode var removed, FSK polling added
*--
*-- Revision 1.14 2004-02-07 14:59:47+01 mjg
*-- Response parsing correction
*--
*-- Revision 1.13 2004-02-03 08:42:52+01 mjg
*-- hubneme II
*--
*-- Revision 1.12 2004-02-03 07:24:37+01 mjg
*-- fwd debug implemented and removed from being compiled
*--
*-- Revision 1.11 2004-01-19 14:08:05+01 mjg
*-- hubneme I
*--
*-- Revision 1.9 2003-12-11 17:37:20+01 mjg
*-- yes
*--
*-- Revision 1.8 2003-12-11 16:33:41+01 mjg
*-- 1TS gives too much responses, stayquiet ?
*--
*-- Revision 1.7 2003-12-10 08:15:48+01 mjg
*-- to add dbg code
*--
*-- Revision 1.6 2003-12-09 12:43:01+01 mjg
*-- to 1TS inventory
*--
*-- Revision 1.4 2003-12-09 12:42:44+01 mjg
*-- to 1TS inventory
*--
*-- Revision 1.3 2003-12-05 08:38:56+01 mjg
*-- write update
*--
*-- Revision 1.2 2003-12-04 15:58:08+01 mjg
*-- to write
*--
*-- Revision 1.1 2003-12-01 08:18:04+01 mjg
*-- single carrier low drate level1 ok
*--
*-- Revision 1.0 2003-11-26 09:01:03+01 mjg
*-- Initial revision
*--
*-------------------------------------------------------------------------------
*/
#ifndef __LEVEL2__
#define __LEVEL2__
//constants----------------------------------------------------------
#define MAXTRELAX 0 //increase this value to increase max capture time
#define CAPTURE_SIZE (128) //capture buffer length
//PORTB pin position
#define SDA_PIN 1
#define SDO_PIN 2
//PORTC pin position
#define MOD_PIN 0 //DIN
#define DCLK_PIN 1 //DCLK
#define LED_PIN 2
#define SCK_PIN 3
//PORTD pin position
#define DBG_FORWARD 2
#define DBG_TRANS 6
#define SSN_PIN 7
#define SetLEDOn() cbi( PORTC, LED_PIN )
#define SetLEDOff() sbi( PORTC, LED_PIN )
#define SetSSN() cbi( DDRD, SSN_PIN )
#define ResetSSN() sbi( DDRD, SSN_PIN )
#define SetSCK() cbi( DDRC, SCK_PIN )
#define ResetSCK() sbi( DDRC, SCK_PIN )
#define SetSDA() cbi( DDRB, SDA_PIN )
#define ResetSDA() sbi( DDRB, SDA_PIN )
//public variables---------------------------------------------------
extern uint8_t bufferClean; //flag for pre-cleaning
typedef struct TCAPTURE {
uint8_t capture_data[CAPTURE_SIZE]; //captured and decoded data bits
uint8_t capture_valid[CAPTURE_SIZE]; //their valid bits
} TCAPTURE;
extern struct TCAPTURE capture;
extern uint8_t * forward_ptr; //ptr for forward message preparation
extern uint8_t data_buffer[CAPTURE_SIZE]; //forward data XOR clean response data
#ifdef DEBUG
extern uint16_t solich;
extern uint16_t offset;
#endif
extern uint16_t fwd_delays[7]; //delays array for forwardlink timing tuning
//function declarations----------------------------------------------
extern void SendForward(uint8_t fwd_bit_count);
extern void SendEOF(void);
extern uint8_t Prepare_Data( uint8_t data );
extern void ClearCaptureBuffers(void);
extern void Capture(uint8_t);
extern uint8_t ExtractData( uint8_t size );
extern uint8_t Extract_EM4006( uint8_t size );
extern void WriteSPI(uint16_t low, uint16_t hi);
extern uint16_t CRC(uint8_t *data, uint8_t len);
extern void HWTransaction(uint8_t *data, uint8_t *dst, uint8_t len);
extern void HWSign(uint8_t *data, uint8_t *dst, uint8_t len);
#endif // __LEVEL2__
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -