mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-20 05:13:46 -07:00
generic tearoff: make use of new @iceman SpinDelayUsPrecision :)
This commit is contained in:
parent
f322094dd6
commit
07023657f2
2 changed files with 17 additions and 7 deletions
|
@ -68,7 +68,7 @@ extern uint32_t _stack_start, _stack_end;
|
||||||
struct common_area common_area __attribute__((section(".commonarea")));
|
struct common_area common_area __attribute__((section(".commonarea")));
|
||||||
static int button_status = BUTTON_NO_CLICK;
|
static int button_status = BUTTON_NO_CLICK;
|
||||||
static bool allow_send_wtx = false;
|
static bool allow_send_wtx = false;
|
||||||
static uint32_t tearoff_delay_us = 0;
|
static uint16_t tearoff_delay_us = 0;
|
||||||
static bool tearoff_enabled = false;
|
static bool tearoff_enabled = false;
|
||||||
|
|
||||||
int tearoff_hook(void) {
|
int tearoff_hook(void) {
|
||||||
|
@ -77,7 +77,7 @@ int tearoff_hook(void) {
|
||||||
Dbprintf(_RED_("No tear-off delay configured!"));
|
Dbprintf(_RED_("No tear-off delay configured!"));
|
||||||
return PM3_SUCCESS; // SUCCESS = the hook didn't do anything
|
return PM3_SUCCESS; // SUCCESS = the hook didn't do anything
|
||||||
}
|
}
|
||||||
WaitUS(tearoff_delay_us);
|
SpinDelayUsPrecision(tearoff_delay_us);
|
||||||
FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
|
FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
|
||||||
tearoff_enabled = false;
|
tearoff_enabled = false;
|
||||||
Dbprintf(_YELLOW_("Tear-off triggered!"));
|
Dbprintf(_YELLOW_("Tear-off triggered!"));
|
||||||
|
@ -751,7 +751,7 @@ static void PacketReceived(PacketCommandNG *packet) {
|
||||||
}
|
}
|
||||||
case CMD_SET_TEAROFF: {
|
case CMD_SET_TEAROFF: {
|
||||||
struct p {
|
struct p {
|
||||||
uint32_t delay_us;
|
uint16_t delay_us;
|
||||||
bool on;
|
bool on;
|
||||||
bool off;
|
bool off;
|
||||||
} PACKED;
|
} PACKED;
|
||||||
|
|
|
@ -520,14 +520,15 @@ static int CmdTearoff(const char *Cmd) {
|
||||||
CLIParserContext *ctx;
|
CLIParserContext *ctx;
|
||||||
CLIParserInit(&ctx, "hw tearoff",
|
CLIParserInit(&ctx, "hw tearoff",
|
||||||
"Configure a tear-off hook for the next write command supporting tear-off\n"
|
"Configure a tear-off hook for the next write command supporting tear-off\n"
|
||||||
"After having been triggered by a write command, the tear-off hook is deactivated",
|
"After having been triggered by a write command, the tear-off hook is deactivated\n"
|
||||||
|
"Delay (in us) must be between 1 and 43000 (43ms). Precision is about 1/3us.",
|
||||||
"hw tearoff --delay 1200 --> define delay of 1200us\n"
|
"hw tearoff --delay 1200 --> define delay of 1200us\n"
|
||||||
"hw tearoff --on --> (re)activate a previously defined delay\n"
|
"hw tearoff --on --> (re)activate a previously defined delay\n"
|
||||||
"hw tearoff --off --> deactivate a previously activated but not yet triggered hook\n");
|
"hw tearoff --off --> deactivate a previously activated but not yet triggered hook\n");
|
||||||
|
|
||||||
void *argtable[] = {
|
void *argtable[] = {
|
||||||
arg_param_begin,
|
arg_param_begin,
|
||||||
arg_int0(NULL, "delay", "<decimal>", "Delay in us before triggering tear-off, must be > 0"),
|
arg_int0(NULL, "delay", "<dec>", "Delay in us before triggering tear-off, must be between 1 and 43000"),
|
||||||
arg_lit0(NULL, "on", "Activate tear-off hook"),
|
arg_lit0(NULL, "on", "Activate tear-off hook"),
|
||||||
arg_lit0(NULL, "off", "Deactivate tear-off hook"),
|
arg_lit0(NULL, "off", "Deactivate tear-off hook"),
|
||||||
arg_param_end
|
arg_param_end
|
||||||
|
@ -535,14 +536,23 @@ static int CmdTearoff(const char *Cmd) {
|
||||||
|
|
||||||
CLIExecWithReturn(ctx, Cmd, argtable, false);
|
CLIExecWithReturn(ctx, Cmd, argtable, false);
|
||||||
struct {
|
struct {
|
||||||
uint32_t delay_us;
|
uint16_t delay_us;
|
||||||
bool on;
|
bool on;
|
||||||
bool off;
|
bool off;
|
||||||
} PACKED params;
|
} PACKED params;
|
||||||
params.delay_us = arg_get_u32_def(ctx, 1, 0);
|
int delay = arg_get_int_def(ctx, 1, -1);
|
||||||
params.on = arg_get_lit(ctx, 2);
|
params.on = arg_get_lit(ctx, 2);
|
||||||
params.off = arg_get_lit(ctx, 3);
|
params.off = arg_get_lit(ctx, 3);
|
||||||
CLIParserFree(ctx);
|
CLIParserFree(ctx);
|
||||||
|
if (delay != -1) {
|
||||||
|
if ((delay < 1) || (delay > 43000)) {
|
||||||
|
PrintAndLogEx(WARNING, "You can't set delay out of 1..43000 range!");
|
||||||
|
return PM3_EINVARG;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
delay = 0; // will be ignored by ARM
|
||||||
|
}
|
||||||
|
params.delay_us = delay;
|
||||||
if (params.on && params.off) {
|
if (params.on && params.off) {
|
||||||
PrintAndLogEx(WARNING, "You can't set both --on and --off!");
|
PrintAndLogEx(WARNING, "You can't set both --on and --off!");
|
||||||
return PM3_EINVARG;
|
return PM3_EINVARG;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue