]> git.zerfleddert.de Git - proxmark3-svn/blob - include/proxmark3.h
Fix mkversion.pl for the case where the global svn revision is different from the...
[proxmark3-svn] / include / proxmark3.h
1 //-----------------------------------------------------------------------------
2 // Definitions of interest to most of the software for this project.
3 // Jonathan Westhues, Mar 2006
4 //-----------------------------------------------------------------------------
5
6 #ifndef __PROXMARK3_H
7 #define __PROXMARK3_H
8
9 // Might as well have the hardware-specific defines everywhere.
10 #include <at91sam7s128.h>
11
12 #include <config_gpio.h>
13 #define LOW(x) PIO_OUTPUT_DATA_CLEAR = (1 << (x))
14 #define HIGH(x) PIO_OUTPUT_DATA_SET = (1 << (x))
15
16 #define SPI_FPGA_MODE 0
17 #define SPI_LCD_MODE 1
18
19 typedef unsigned long DWORD;
20 typedef signed long SDWORD;
21 typedef unsigned long long QWORD;
22 typedef int BOOL;
23 typedef unsigned char BYTE;
24 typedef signed char SBYTE;
25 typedef unsigned short WORD;
26 typedef signed short SWORD;
27 #define TRUE 1
28 #define FALSE 0
29
30 #include <usb_cmd.h>
31
32 #define PACKED __attribute__((__packed__))
33
34 #define USB_D_PLUS_PULLUP_ON() { \
35 PIO_OUTPUT_DATA_SET = (1<<GPIO_USB_PU); \
36 PIO_OUTPUT_ENABLE = (1<<GPIO_USB_PU); \
37 }
38 #define USB_D_PLUS_PULLUP_OFF() PIO_OUTPUT_DISABLE = (1<<GPIO_USB_PU)
39
40 #define LED_A_ON() PIO_OUTPUT_DATA_SET = (1<<GPIO_LED_A)
41 #define LED_A_OFF() PIO_OUTPUT_DATA_CLEAR = (1<<GPIO_LED_A)
42 #define LED_B_ON() PIO_OUTPUT_DATA_SET = (1<<GPIO_LED_B)
43 #define LED_B_OFF() PIO_OUTPUT_DATA_CLEAR = (1<<GPIO_LED_B)
44 #define LED_C_ON() PIO_OUTPUT_DATA_SET = (1<<GPIO_LED_C)
45 #define LED_C_OFF() PIO_OUTPUT_DATA_CLEAR = (1<<GPIO_LED_C)
46 #define LED_D_ON() PIO_OUTPUT_DATA_SET = (1<<GPIO_LED_D)
47 #define LED_D_OFF() PIO_OUTPUT_DATA_CLEAR = (1<<GPIO_LED_D)
48 #define RELAY_ON() PIO_OUTPUT_DATA_SET = (1<<GPIO_RELAY)
49 #define RELAY_OFF() PIO_OUTPUT_DATA_CLEAR = (1<<GPIO_RELAY)
50 #define BUTTON_PRESS() !(PIO_PIN_DATA_STATUS & (1<<GPIO_BUTTON))
51 //--------------------------------
52 // USB declarations
53
54 void UsbSendPacket(BYTE *packet, int len);
55 BOOL UsbConnected();
56 BOOL UsbPoll(BOOL blinkLeds);
57 void UsbStart(void);
58
59 // This function is provided by the apps/bootrom, and called from UsbPoll
60 // if data are available.
61 void UsbPacketReceived(BYTE *packet, int len);
62
63 #define VERSION_INFORMATION_MAGIC 0x56334d50
64 struct version_information {
65 int magic; /* Magic sequence to identify this as a correct version information structure. Must be VERSION_INFORMATION_MAGIC */
66 char versionversion; /* Must be 1 */
67 char present; /* 1 if the version information could be created at compile time, otherwise 0 and the remaining fields (except for magic) are empty */
68 char clean; /* 1: Tree was clean, no local changes. 0: Tree was unclean. 2: Couldn't be determined */
69 char svnversion[9]; /* String with the SVN revision */
70 char buildtime[30]; /* string with the build time */
71 } __attribute__((packed));
72
73 #define COMMON_AREA_MAGIC 0x43334d50
74 #define COMMON_AREA_COMMAND_NONE 0
75 #define COMMON_AREA_COMMAND_ENTER_FLASH_MODE 1
76 struct common_area {
77 int magic; /* Magic sequence, to distinguish against random uninitialized memory */
78 char version; /* Must be 1 */
79 char command;
80 struct {
81 unsigned int bootrom_present:1; /* Set when a bootrom that is capable of parsing the common area is present */
82 unsigned int osimage_present:1; /* Set when a osimage that is capable of parsing the common area is present */
83 } __attribute__((packed)) flags;
84 int arg1, arg2;
85 } __attribute__((packed));
86
87 #endif
Impressum, Datenschutz