1 //-----------------------------------------------------------------------------
2 // Jonathan Westhues, Aug 2005
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 //-----------------------------------------------------------------------------
8 // Utility functions used in many places, not specific to any piece of code.
9 //-----------------------------------------------------------------------------
16 // PRIx64 definition missing with gcc-arm-none-eabi v8?
24 #define SHORT_COIL() LOW(GPIO_SSC_DOUT)
28 #define OPEN_COIL() HIGH(GPIO_SSC_DOUT)
32 #define BYTEx(x, n) (((x) >> (n * 8)) & 0xff )
35 // Proxmark3 RDV4.0 LEDs
41 // Proxmark3 historical LEDs
42 #define LED_ORANGE LED_A
43 #define LED_GREEN LED_B
45 #define LED_RED2 LED_D
48 #define BUTTON_NO_CLICK 0
49 #define BUTTON_SINGLE_CLICK -1
50 #define BUTTON_DOUBLE_CLICK -2
51 #define BUTTON_ERROR -99
54 #define REV8(x) ((((x)>>7)&1)+((((x)>>6)&1)<<1)+((((x)>>5)&1)<<2)+((((x)>>4)&1)<<3)+((((x)>>3)&1)<<4)+((((x)>>2)&1)<<5)+((((x)>>1)&1)<<6)+(((x)&1)<<7))
58 #define REV16(x) (REV8(x) + (REV8 ((x) >> 8) << 8))
62 #define REV32(x) (REV16(x) + (REV16((x) >> 16) << 16))
66 #define REV64(x) (REV32(x) + ((uint64_t)(REV32((x) >> 32) << 32)))
70 #define BIT32(x,n) ((((x)[(n)>>5])>>((n)))&1)
74 #define INV32(x,i,n) ((x)[(i)>>5]^=((uint32_t)(n))<<((i)&31))
78 #define ROTL64(x, n) ((((uint64_t)(x))<<((n)&63))+(((uint64_t)(x))>>((0-(n))&63)))
81 size_t nbytes(size_t nbits
);
83 uint8_t hex2int(char hexchar
);
85 void LED(int led
, int ms
);
87 void SpinOff(uint32_t pause
);
88 void SpinErr(uint8_t led
, uint32_t speed
, uint8_t times
);
89 void SpinDown(uint32_t speed
);
90 void SpinUp(uint32_t speed
);
92 int BUTTON_CLICKED(int ms
);
93 int BUTTON_HELD(int ms
);
94 bool data_available(void);