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 //-----------------------------------------------------------------------------
17 // There are two modes:
18 // - lf_ed_toggle_mode == 0: the output is set low (resp. high) when a low
19 // (resp. high) edge/peak is detected, with hysteresis
20 // - lf_ed_toggle_mode == 1: the output is toggling whenever an edge/peak
22 // That way you can detect two consecutive edges/peaks at the same level (L/H)
25 // - ssp_frame (wired to TIOA1 on the arm) for the edge detection/state
26 // - ssp_clk: cross_lo
28 module lo_edge_detect(
34 input lf_ed_toggle_mode
,
35 input [7:0] lf_ed_threshold
,
50 wire tag_modulation
= ssp_dout
& !lf_field
;
51 wire reader_modulation
= !ssp_dout
& lf_field
& pck_divclk
;
53 // No logic, straight through.
54 assign pwr_oe1
= 1'b0; // not used in LF mode
55 assign pwr_oe3
= 1'b0; // base antenna load = 33 Ohms
56 // when modulating, add another 33 Ohms and 10k Ohms in parallel:
57 assign pwr_oe2
= tag_modulation
;
58 assign pwr_oe4
= tag_modulation
;
60 assign ssp_clk
= cross_lo
;
61 assign pwr_lo
= reader_modulation
;
64 // filter the ADC values
66 wire [7:0] adc_filtered
;
67 assign adc_clk
= pck0
;
69 lp20khz_1MSa_iir_filter
adc_filter(
77 wire [7:0] high_threshold
, highz_threshold
, lowz_threshold
, low_threshold
;
79 wire edge_state
, edge_toggle
;
83 .
adc_d (adc_filtered
),
84 .
lf_ed_threshold (lf_ed_threshold
),
87 .
high_threshold (high_threshold
),
88 .
highz_threshold (highz_threshold
),
89 .
lowz_threshold (lowz_threshold
),
90 .
low_threshold (low_threshold
),
91 .
edge_state (edge_state
),
92 .
edge_toggle (edge_toggle
)
95 assign debug
= lf_ed_toggle_mode ? edge_toggle
: edge_state
;
97 assign ssp_frame
= lf_ed_toggle_mode ? edge_toggle
: edge_state
;