1 //-----------------------------------------------------------------------------
2 // Copyright (C) Proxmark3 contributors. See AUTHORS.md for details.
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // See LICENSE.txt for the text of the license.
15 //-----------------------------------------------------------------------------
16 #ifndef __LFSAMPLING_H
17 #define __LFSAMPLING_H
36 * acquisition of Cotag LF signal. Similar to other LF, since the Cotag has such long datarate RF/384
37 * and is Manchester?, we directly gather the manchester data into bigbuff
39 void doCotagAcquisition(void);
40 uint16_t doCotagAcquisitionManchester(uint8_t *dest
, uint16_t destlen
);
43 * acquisition of T55x7 LF signal. Similar to other LF, but adjusted with @marshmellows thresholds
44 * the data is collected in BigBuf.
46 void doT55x7Acquisition(size_t sample_size
, bool ledcontrol
);
49 * Initializes the FPGA for reader-mode (field on), and acquires the samples.
50 * @return number of bits sampled
52 uint32_t SampleLF(bool verbose
, uint32_t sample_size
, bool ledcontrol
);
55 * Do LF sampling and send samples to the USB
57 * Uses parameters in config. Only bits_per_sample = 8 is working now
59 * @param reader_field - true for reading tags, false for sniffing
60 * @return sampling result
62 int ReadLF_realtime(bool reader_field
);
65 * Initializes the FPGA for sniff-mode (field off), and acquires the samples.
66 * @return number of bits sampled
68 uint32_t SniffLF(bool verbose
, uint32_t sample_size
, bool ledcontrol
);
70 uint32_t DoAcquisition(uint8_t decimation
, uint8_t bits_per_sample
, bool avg
, int16_t trigger_threshold
,
71 bool verbose
, uint32_t sample_size
, uint32_t cancel_after
, int32_t samples_to_skip
, bool ledcontrol
);
73 // adds sample size to default options
74 uint32_t DoPartialAcquisition(int trigger_threshold
, bool verbose
, uint32_t sample_size
, uint32_t cancel_after
, bool ledcontrol
);
77 * @brief Does sample acquisition, ignoring the config values set in the sample_config.
78 * This method is typically used by tag-specific readers who just wants to read the samples
80 * @param trigger_threshold
82 * @return number of bits sampled
84 uint32_t DoAcquisition_default(int trigger_threshold
, bool verbose
, bool ledcontrol
);
86 * @brief Does sample acquisition, using the config values set in the sample_config.
87 * @param trigger_threshold
89 * @return number of bits sampled
92 uint32_t DoAcquisition_config(bool verbose
, uint32_t sample_size
, bool ledcontrol
);
95 * Refactoring of lf sampling buffer
97 void initSampleBuffer(uint32_t *sample_size
);
98 void initSampleBufferEx(uint32_t *sample_size
, bool use_malloc
);
99 void logSampleSimple(uint8_t sample
);
100 void logSample(uint8_t sample
, uint8_t decimation
, uint8_t bits_per_sample
, bool avg
);
101 uint32_t getSampleCounter(void);
104 * Setup the FPGA to listen for samples. This method downloads the FPGA bitstream
105 * if not already loaded, sets divisor and starts up the antenna.
106 * @param divisor : 1, 88> 255 or negative ==> 134.8 kHz
107 * 0 or 95 ==> 125 kHz
110 void LFSetupFPGAForADC(int divisor
, bool reader_field
);
113 * Called from the USB-handler to set the sampling configuration
114 * The sampling config is used for std reading and sniffing.
116 * Other functions may read samples and ignore the sampling config,
117 * such as functions to read the UID from a prox tag or similar.
119 * Values set to '0' implies no change (except for averaging)
120 * @brief setSamplingConfig
123 void setSamplingConfig(const sample_config
*sc
);
124 void setDefaultSamplingConfig(void);
125 sample_config
*getSamplingConfig(void);
127 void printLFConfig(void);
128 void printSamples(void);
130 #endif // __LFSAMPLING_H