Chameleon-Mini
Main Page
Related Pages
Classes
Files
File List
File Members
All
Classes
Files
Functions
Variables
Macros
Pages
Firmware
Chameleon-Mini
Common.h
1
/* Copyright 2013 Timo Kasper, Simon Küppers, David Oswald ("ORIGINAL
2
* AUTHORS"). All rights reserved.
3
*
4
* DEFINITIONS:
5
*
6
* "WORK": The material covered by this license includes the schematic
7
* diagrams, designs, circuit or circuit board layouts, mechanical
8
* drawings, documentation (in electronic or printed form), source code,
9
* binary software, data files, assembled devices, and any additional
10
* material provided by the ORIGINAL AUTHORS in the ChameleonMini project
11
* (https://github.com/skuep/ChameleonMini).
12
*
13
* LICENSE TERMS:
14
*
15
* Redistributions and use of this WORK, with or without modification, or
16
* of substantial portions of this WORK are permitted provided that the
17
* following conditions are met:
18
*
19
* Redistributions and use of this WORK, with or without modification, or
20
* of substantial portions of this WORK must include the above copyright
21
* notice, this list of conditions, the below disclaimer, and the following
22
* attribution:
23
*
24
* "Based on ChameleonMini an open-source RFID emulator:
25
* https://github.com/skuep/ChameleonMini"
26
*
27
* The attribution must be clearly visible to a user, for example, by being
28
* printed on the circuit board and an enclosure, and by being displayed by
29
* software (both in binary and source code form).
30
*
31
* At any time, the majority of the ORIGINAL AUTHORS may decide to give
32
* written permission to an entity to use or redistribute the WORK (with or
33
* without modification) WITHOUT having to include the above copyright
34
* notice, this list of conditions, the below disclaimer, and the above
35
* attribution.
36
*
37
* DISCLAIMER:
38
*
39
* THIS PRODUCT IS PROVIDED BY THE ORIGINAL AUTHORS "AS IS" AND ANY EXPRESS
40
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
41
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
42
* DISCLAIMED. IN NO EVENT SHALL THE ORIGINAL AUTHORS OR CONTRIBUTORS BE
43
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
44
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
45
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
46
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
47
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
48
* ARISING IN ANY WAY OUT OF THE USE OF THIS PRODUCT, EVEN IF ADVISED OF
49
* THE POSSIBILITY OF SUCH DAMAGE.
50
*
51
* The views and conclusions contained in the hardware, software, and
52
* documentation should not be interpreted as representing official
53
* policies, either expressed or implied, of the ORIGINAL AUTHORS.
54
*/
55
56
#ifndef COMMON_H_
57
#define COMMON_H_
58
59
#include <stdio.h>
60
#include <stdbool.h>
61
#include <util/parity.h>
62
#include <util/delay.h>
63
#include <avr/pgmspace.h>
64
65
#define ODD_PARITY(Value) (parity_even_bit(Value) ? 0 : 1)
66
67
#define INLINE \
68
static inline __attribute__((always_inline))
69
70
#define NIBBLE_TO_HEXCHAR(x) ( (x) < 0x0A ? (x) + '0' : (x) + 'A' - 0x0A )
71
#define HEXCHAR_TO_NIBBLE(x) ( (x) < 'A' ? (x) - '0' : (x) - 'A' + 0x0A )
72
#define VALID_HEXCHAR(x) ( ( (x) >= '0' && (x) <= '9' ) || ( (x) >= 'A' && (x) <= 'F' ) )
73
#define MIN(x,y) ( (x) < (y) ? (x) : (y) )
74
#define MAX(x,y) ( (x) > (y) ? (x) : (y) )
75
76
#define BITS_PER_BYTE 8
77
78
uint16_t BufferToHexString(
char
* HexOut, uint16_t MaxChars,
const
void
* Buffer, uint16_t ByteCount);
79
uint16_t HexStringToBuffer(
void
* Buffer, uint16_t MaxBytes,
const
char
* HexIn);
80
81
#endif
/* COMMON_H_ */
Generated on Thu Jan 2 2014 10:08:11 for Chameleon-Mini by
1.8.4