2017-01-25 07:33:03 +08:00
|
|
|
#ifndef __LFSAMPLING_H
|
|
|
|
#define __LFSAMPLING_H
|
2015-01-31 06:03:44 +08:00
|
|
|
|
2019-08-08 22:57:33 +08:00
|
|
|
#include "common.h"
|
|
|
|
#include "pm3_cmd.h"
|
2016-09-23 22:35:26 +08:00
|
|
|
|
2020-01-08 05:05:01 +08:00
|
|
|
typedef struct {
|
|
|
|
uint8_t *buffer;
|
|
|
|
uint32_t numbits;
|
|
|
|
uint32_t position;
|
|
|
|
} BitstreamOut;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
int dec_counter;
|
|
|
|
uint32_t sum;
|
|
|
|
uint32_t counter;
|
|
|
|
uint32_t total_saved;
|
|
|
|
} sampling_t;
|
2017-01-25 07:33:03 +08:00
|
|
|
|
2015-10-15 16:23:15 +08:00
|
|
|
/**
|
2017-02-02 22:32:21 +08:00
|
|
|
* acquisition of Cotag LF signal. Similar to other LF, since the Cotag has such long datarate RF/384
|
|
|
|
* and is Manchester?, we directly gather the manchester data into bigbuff
|
|
|
|
**/
|
2020-07-02 18:35:33 +08:00
|
|
|
void doCotagAcquisition(void);
|
2020-08-25 21:34:10 +08:00
|
|
|
uint16_t doCotagAcquisitionManchester(uint8_t *dest, uint16_t destlen);
|
2017-02-02 22:32:21 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* acquisition of T55x7 LF signal. Similar to other LF, but adjusted with @marshmellows thresholds
|
2015-10-15 16:23:15 +08:00
|
|
|
* the data is collected in BigBuf.
|
|
|
|
**/
|
2015-11-03 03:46:17 +08:00
|
|
|
void doT55x7Acquisition(size_t sample_size);
|
2015-10-15 16:23:15 +08:00
|
|
|
|
2015-01-31 06:03:44 +08:00
|
|
|
/**
|
|
|
|
* Initializes the FPGA for reader-mode (field on), and acquires the samples.
|
|
|
|
* @return number of bits sampled
|
|
|
|
**/
|
2020-01-08 05:05:01 +08:00
|
|
|
uint32_t SampleLF(bool verbose, uint32_t sample_size);
|
2015-01-31 06:03:44 +08:00
|
|
|
|
|
|
|
/**
|
2019-03-12 20:15:39 +08:00
|
|
|
* Initializes the FPGA for sniff-mode (field off), and acquires the samples.
|
2015-01-31 06:03:44 +08:00
|
|
|
* @return number of bits sampled
|
|
|
|
**/
|
2020-09-20 17:12:38 +08:00
|
|
|
uint32_t SniffLF(bool verbose, uint32_t sample_size);
|
2015-01-31 06:03:44 +08:00
|
|
|
|
2020-01-10 02:28:44 +08:00
|
|
|
uint32_t DoAcquisition(uint8_t decimation, uint8_t bits_per_sample, bool avg, int16_t trigger_threshold,
|
|
|
|
bool verbose, uint32_t sample_size, uint32_t cancel_after, int32_t samples_to_skip);
|
2020-01-08 05:05:01 +08:00
|
|
|
|
2017-02-24 22:45:24 +08:00
|
|
|
// adds sample size to default options
|
2020-01-08 05:05:01 +08:00
|
|
|
uint32_t DoPartialAcquisition(int trigger_threshold, bool verbose, uint32_t sample_size, uint32_t cancel_after);
|
2017-02-24 22:45:24 +08:00
|
|
|
|
2015-01-31 06:03:44 +08:00
|
|
|
/**
|
|
|
|
* @brief Does sample acquisition, ignoring the config values set in the sample_config.
|
|
|
|
* This method is typically used by tag-specific readers who just wants to read the samples
|
|
|
|
* the normal way
|
|
|
|
* @param trigger_threshold
|
2020-01-08 05:05:01 +08:00
|
|
|
* @param verbose
|
2015-01-31 06:03:44 +08:00
|
|
|
* @return number of bits sampled
|
|
|
|
*/
|
2020-01-08 05:05:01 +08:00
|
|
|
uint32_t DoAcquisition_default(int trigger_threshold, bool verbose);
|
2015-01-31 06:03:44 +08:00
|
|
|
/**
|
|
|
|
* @brief Does sample acquisition, using the config values set in the sample_config.
|
|
|
|
* @param trigger_threshold
|
2020-01-08 05:05:01 +08:00
|
|
|
* @param verbose
|
2015-01-31 06:03:44 +08:00
|
|
|
* @return number of bits sampled
|
|
|
|
*/
|
|
|
|
|
2020-01-08 05:05:01 +08:00
|
|
|
uint32_t DoAcquisition_config(bool verbose, uint32_t sample_size);
|
2015-01-31 06:03:44 +08:00
|
|
|
|
2020-01-02 03:47:27 +08:00
|
|
|
/**
|
|
|
|
* Refactoring of lf sampling buffer
|
|
|
|
*/
|
2020-01-10 02:28:44 +08:00
|
|
|
void initSampleBuffer(uint32_t *sample_size);
|
2020-01-29 11:37:10 +08:00
|
|
|
void initSampleBufferEx(uint32_t *sample_size, bool use_malloc);
|
2020-01-16 17:42:39 +08:00
|
|
|
void logSampleSimple(uint8_t sample);
|
2020-01-10 02:28:44 +08:00
|
|
|
void logSample(uint8_t sample, uint8_t decimation, uint8_t bits_per_sample, bool avg);
|
2020-05-10 22:59:38 +08:00
|
|
|
uint32_t getSampleCounter(void);
|
2020-01-02 03:47:27 +08:00
|
|
|
|
2015-01-31 06:03:44 +08:00
|
|
|
/**
|
|
|
|
* Setup the FPGA to listen for samples. This method downloads the FPGA bitstream
|
|
|
|
* if not already loaded, sets divisor and starts up the antenna.
|
2019-05-09 07:07:34 +08:00
|
|
|
* @param divisor : 1, 88> 255 or negative ==> 134.8 kHz
|
|
|
|
* 0 or 95 ==> 125 kHz
|
2015-01-31 06:03:44 +08:00
|
|
|
*
|
|
|
|
**/
|
2020-04-26 18:56:19 +08:00
|
|
|
void LFSetupFPGAForADC(int divisor, bool reader_field);
|
2015-01-31 06:03:44 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Called from the USB-handler to set the sampling configuration
|
2019-03-12 20:15:39 +08:00
|
|
|
* The sampling config is used for std reading and sniffing.
|
2015-01-31 06:03:44 +08:00
|
|
|
*
|
|
|
|
* Other functions may read samples and ignore the sampling config,
|
|
|
|
* such as functions to read the UID from a prox tag or similar.
|
|
|
|
*
|
|
|
|
* Values set to '0' implies no change (except for averaging)
|
|
|
|
* @brief setSamplingConfig
|
|
|
|
* @param sc
|
|
|
|
*/
|
|
|
|
void setSamplingConfig(sample_config *sc);
|
|
|
|
|
2020-05-10 22:59:38 +08:00
|
|
|
sample_config *getSamplingConfig(void);
|
2015-07-23 05:00:52 +08:00
|
|
|
|
2020-09-07 06:48:36 +08:00
|
|
|
void printLFConfig(void);
|
2020-06-23 17:21:17 +08:00
|
|
|
void printSamples(void);
|
2015-07-23 05:00:52 +08:00
|
|
|
|
2017-01-25 07:33:03 +08:00
|
|
|
#endif // __LFSAMPLING_H
|