]> cvs.zerfleddert.de Git - proxmark3-svn/blame - include/proxmark3.h
replaced obsolete config options with current
[proxmark3-svn] / include / proxmark3.h
CommitLineData
6658905f 1//-----------------------------------------------------------------------------\r
2// Definitions of interest to most of the software for this project.\r
3// Jonathan Westhues, Mar 2006\r
4//-----------------------------------------------------------------------------\r
5\r
6#ifndef __PROXMARK3_H\r
7#define __PROXMARK3_H\r
8\r
9// Might as well have the hardware-specific defines everywhere.\r
6949aca9 10#include <at91sam7s512.h>\r
6658905f 11#include <config_gpio.h>\r
6949aca9 12\r
13#define WDT_HIT() AT91C_BASE_WDTC->WDTC_WDCR = 0xa5000001\r
14\r
15#define PWM_CH_MODE_PRESCALER(x) ((x)<<0)\r
16#define PWM_CHANNEL(x) (1<<(x))\r
17\r
18#define TC_CMR_TCCLKS_TIMER_CLOCK1 (0<<0)\r
bb4d2cca 19#define TC_CMR_TCCLKS_TIMER_CLOCK2 (1<<0)\r
20#define TC_CMR_TCCLKS_TIMER_CLOCK3 (2<<0)\r
21#define TC_CMR_TCCLKS_TIMER_CLOCK4 (3<<0)\r
22#define TC_CMR_TCCLKS_TIMER_CLOCK5 (4<<0)\r
6949aca9 23\r
24#define ADC_CHAN_LF 4\r
25#define ADC_CHAN_HF 5\r
26#define ADC_MODE_PRESCALE(x) ((x)<<8)\r
27#define ADC_MODE_STARTUP_TIME(x) ((x)<<16)\r
28#define ADC_MODE_SAMPLE_HOLD_TIME(x) ((x)<<24)\r
29#define ADC_CHANNEL(x) (1<<(x))\r
30#define ADC_END_OF_CONVERSION(x) (1<<(x))\r
31\r
32#define SSC_CLOCK_MODE_START(x) ((x)<<8)\r
33#define SSC_FRAME_MODE_WORDS_PER_TRANSFER(x) ((x)<<8)\r
34#define SSC_CLOCK_MODE_SELECT(x) ((x)<<0)\r
35#define SSC_FRAME_MODE_BITS_IN_WORD(x) (((x)-1)<<0)\r
36\r
37#define MC_FLASH_COMMAND_KEY ((0x5a)<<24)\r
38#define MC_FLASH_STATUS_READY (1<<0)\r
4ab62816 39#define MC_FLASH_STATUS_LOCKE (1<<2)\r
40#define MC_FLASH_STATUS_PROGE (1<<3)\r
6949aca9 41#define MC_FLASH_MODE_FLASH_WAIT_STATES(x) ((x)<<8)\r
42#define MC_FLASH_MODE_MASTER_CLK_IN_MHZ(x) ((x)<<16)\r
43#define MC_FLASH_COMMAND_PAGEN(x) ((x)<<8)\r
44\r
45#define RST_CONTROL_KEY (0xa5<<24)\r
46\r
47#define PMC_MAIN_OSC_ENABLE (1<<0)\r
48#define PMC_MAIN_OSC_STABILIZED (1<<0)\r
49#define PMC_MAIN_OSC_PLL_LOCK (1<<2)\r
50#define PMC_MAIN_OSC_MCK_READY (1<<3)\r
51\r
52#define PMC_MAIN_OSC_STARTUP_DELAY(x) ((x)<<8)\r
53#define PMC_PLL_DIVISOR(x) (x)\r
54#define PMC_CLK_PRESCALE_DIV_2 (1<<2)\r
55#define PMC_PLL_MULTIPLIER(x) (((x)-1)<<16)\r
56#define PMC_PLL_COUNT_BEFORE_LOCK(x) ((x)<<8)\r
57#define PMC_PLL_FREQUENCY_RANGE(x) ((x)<<14)\r
58#define PMC_PLL_USB_DIVISOR(x) ((x)<<28)\r
59\r
60#define UDP_INTERRUPT_ENDPOINT(x) (1<<(x))\r
61#define UDP_CSR_BYTES_RECEIVED(x) (((x) >> 16) & 0x7ff)\r
62//**************************************************************\r
63\r
64#define LOW(x) AT91C_BASE_PIOA->PIO_CODR = (x)\r
65#define HIGH(x) AT91C_BASE_PIOA->PIO_SODR = (x)\r
6658905f 66\r
67#define SPI_FPGA_MODE 0\r
68#define SPI_LCD_MODE 1\r
69\r
70typedef unsigned long DWORD;\r
71typedef signed long SDWORD;\r
72typedef unsigned long long QWORD;\r
73typedef int BOOL;\r
74typedef unsigned char BYTE;\r
75typedef signed char SBYTE;\r
76typedef unsigned short WORD;\r
77typedef signed short SWORD;\r
78#define TRUE 1\r
79#define FALSE 0\r
80\r
81#include <usb_cmd.h>\r
82\r
1dea88f9 83//#define PACKED __attribute__((__packed__))\r
6658905f 84\r
85#define USB_D_PLUS_PULLUP_ON() { \\r
6949aca9 86 HIGH(GPIO_USB_PU); \\r
87 AT91C_BASE_PIOA->PIO_OER = GPIO_USB_PU; \\r
6658905f 88 }\r
6949aca9 89#define USB_D_PLUS_PULLUP_OFF() AT91C_BASE_PIOA->PIO_ODR = GPIO_USB_PU\r
90\r
91#define LED_A_ON() HIGH(GPIO_LED_A)\r
92#define LED_A_OFF() LOW(GPIO_LED_A)\r
93#define LED_B_ON() HIGH(GPIO_LED_B)\r
94#define LED_B_OFF() LOW(GPIO_LED_B)\r
95#define LED_C_ON() HIGH(GPIO_LED_C)\r
96#define LED_C_OFF() LOW(GPIO_LED_C)\r
97#define LED_D_ON() HIGH(GPIO_LED_D)\r
98#define LED_D_OFF() LOW(GPIO_LED_D)\r
99#define RELAY_ON() HIGH(GPIO_RELAY)\r
100#define RELAY_OFF() LOW(GPIO_RELAY)\r
101#define BUTTON_PRESS() !(AT91C_BASE_PIOA->PIO_PDSR & GPIO_BUTTON)\r
6658905f 102//--------------------------------\r
103// USB declarations\r
104\r
105void UsbSendPacket(BYTE *packet, int len);\r
50722269 106BOOL UsbConnected();\r
6658905f 107BOOL UsbPoll(BOOL blinkLeds);\r
108void UsbStart(void);\r
109\r
110// This function is provided by the apps/bootrom, and called from UsbPoll\r
111// if data are available.\r
112void UsbPacketReceived(BYTE *packet, int len);\r
113\r
8a6aec16 114#define VERSION_INFORMATION_MAGIC 0x56334d50\r
115struct version_information {\r
6949aca9 116 int magic; /* Magic sequence to identify this as a correct version information structure. Must be VERSION_INFORMATION_MAGIC */\r
8a6aec16 117 char versionversion; /* Must be 1 */\r
118 char present; /* 1 if the version information could be created at compile time, otherwise 0 and the remaining fields (except for magic) are empty */\r
119 char clean; /* 1: Tree was clean, no local changes. 0: Tree was unclean. 2: Couldn't be determined */\r
120 char svnversion[9]; /* String with the SVN revision */\r
121 char buildtime[30]; /* string with the build time */\r
122} __attribute__((packed));\r
123\r
8fcbf652 124#define COMMON_AREA_MAGIC 0x43334d50\r
125#define COMMON_AREA_COMMAND_NONE 0\r
126#define COMMON_AREA_COMMAND_ENTER_FLASH_MODE 1\r
127struct common_area {\r
128 int magic; /* Magic sequence, to distinguish against random uninitialized memory */\r
129 char version; /* Must be 1 */\r
130 char command;\r
131 struct {\r
132 unsigned int bootrom_present:1; /* Set when a bootrom that is capable of parsing the common area is present */\r
133 unsigned int osimage_present:1; /* Set when a osimage that is capable of parsing the common area is present */\r
134 } __attribute__((packed)) flags;\r
135 int arg1, arg2;\r
136} __attribute__((packed));\r
137\r
6658905f 138#endif\r
Impressum, Datenschutz