1 //-----------------------------------------------------------------------------
2 // Copyright (C) 2010 iZsh <izsh at fail0verflow.com>
4 // This code is licensed to you under the terms of the GNU GPL, version 2 or,
5 // at your option, any later version. See the LICENSE.txt file for the text of
7 //-----------------------------------------------------------------------------
9 //-----------------------------------------------------------------------------
16 //#include "proxusb.h"
17 #include "proxmark3.h"
18 #include "cmdparser.h"
21 /* low-level hardware control */
23 static int CmdHelp(const char *Cmd
);
25 int CmdDetectReader(const char *Cmd
)
27 UsbCommand c
={CMD_LISTEN_READER_FIELD
};
28 // 'l' means LF - 125/134 kHz
31 } else if (*Cmd
== 'h') {
33 } else if (*Cmd
!= '\0') {
34 PrintAndLog("use 'detectreader' or 'detectreader l' or 'detectreader h'");
42 int CmdFPGAOff(const char *Cmd
)
44 UsbCommand c
= {CMD_FPGA_MAJOR_MODE_OFF
};
49 int CmdLCD(const char *Cmd
)
53 UsbCommand c
={CMD_LCD
};
54 sscanf(Cmd
, "%x %d", &i
, &j
);
62 int CmdLCDReset(const char *Cmd
)
64 UsbCommand c
= {CMD_LCD_RESET
, {strtol(Cmd
, NULL
, 0), 0, 0}};
69 int CmdReadmem(const char *Cmd
)
71 UsbCommand c
= {CMD_READ_MEM
, {strtol(Cmd
, NULL
, 0), 0, 0}};
76 int CmdReset(const char *Cmd
)
78 UsbCommand c
= {CMD_HARDWARE_RESET
};
84 * Sets the divisor for LF frequency clock: lets the user choose any LF frequency below
87 int CmdSetDivisor(const char *Cmd
)
89 UsbCommand c
= {CMD_SET_LF_DIVISOR
, {strtol(Cmd
, NULL
, 0), 0, 0}};
90 if (c
.arg
[0] < 19 || c
.arg
[0] > 255) {
91 PrintAndLog("divisor must be between 19 and 255");
94 PrintAndLog("Divisor set, expected freq=%dHz", 12000000 / (c
.arg
[0]+1));
99 int CmdSetMux(const char *Cmd
)
101 UsbCommand c
={CMD_SET_ADC_MUX
};
102 if (strcmp(Cmd
, "lopkd") == 0) {
104 } else if (strcmp(Cmd
, "loraw") == 0) {
106 } else if (strcmp(Cmd
, "hipkd") == 0) {
108 } else if (strcmp(Cmd
, "hiraw") == 0) {
115 int CmdTune(const char *Cmd
)
117 UsbCommand c
= {CMD_MEASURE_ANTENNA_TUNING
};
122 int CmdVersion(const char *Cmd
)
124 UsbCommand c
= {CMD_VERSION
};
129 static command_t CommandTable
[] =
131 {"help", CmdHelp
, 1, "This help"},
132 {"detectreader", CmdDetectReader
,0, "['l'|'h'] -- Detect external reader field (option 'l' or 'h' to limit to LF or HF)"},
133 {"fpgaoff", CmdFPGAOff
, 0, "Set FPGA off"},
134 {"lcd", CmdLCD
, 0, "<HEX command> <count> -- Send command/data to LCD"},
135 {"lcdreset", CmdLCDReset
, 0, "Hardware reset LCD"},
136 {"readmem", CmdReadmem
, 0, "[address] -- Read memory at decimal address from flash"},
137 {"reset", CmdReset
, 0, "Reset the Proxmark3"},
138 {"setlfdivisor", CmdSetDivisor
, 0, "<19 - 255> -- Drive LF antenna at 12Mhz/(divisor+1)"},
139 {"setmux", CmdSetMux
, 0, "<loraw|hiraw|lopkd|hipkd> -- Set the ADC mux to a specific value"},
140 {"tune", CmdTune
, 0, "Measure antenna tuning"},
141 {"version", CmdVersion
, 0, "Show version inforation about the connected Proxmark"},
142 {NULL
, NULL
, 0, NULL
}
145 int CmdHW(const char *Cmd
)
147 CmdsParse(CommandTable
, Cmd
);
151 int CmdHelp(const char *Cmd
)
153 CmdsHelp(CommandTable
);