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