Statistics
| Branch: | Revision:

root / toolbox / rfid.h @ e1d61b43

History | View | Annotate | Download (1.44 KB)

1
#ifndef RFID_H
2
#define RFID_H
3

    
4
/* First byte back from rfid reader */
5
#define RFID_OK 1
6

    
7
/* Bytes in serial number on rfid tags */
8
#define RFID_SERNO_SIZE 4
9

    
10
/* In rfid_read_safe, it must read the same value RFID_MIN_OK times. If it
11
 * encounters RFID_MAX_ERRS read errors first, it will output all 0's. */
12
#define RFID_MAX_ERRS 10
13
#define RFID_MIN_OK 5
14

    
15
/* Should be called before anything else */
16
void rfid_init();
17

    
18
/* Sends the read command to the rfid reader. After, you should call rfid_poll
19
 * until it returns nonzero */
20
void rfid_start_read();
21

    
22
/* Should only be called after rfid_start_read. Keep calling until it returns
23
 * nonzero, which means it is finished reading the serial number, and
24
 * rfid_get_serno can be called */
25
char rfid_poll();
26

    
27
/* Attempts to read the serial number multiple times, and only accepts it if it
28
 * is the same every time. Don't use it */
29
void rfid_read_safe();
30

    
31
/* Call this only after rfid_poll returns nonzero. This will copy the value it
32
 * read into serno, which should be at least RFID_SERNO_SIZE bytes */
33
void rfid_get_serno(uint8_t *serno);
34

    
35
/* Call this only after rfid_poll returns nonzero. Returns 1 if serno matches
36
 * the internal buffer of the most recently read serial number */
37
char rfid_check_serno(uint8_t *serno);
38

    
39
/* Call this only after rfid_poll returns nonzero. Returns 1 if the internal
40
 * buffer is nonzero, meaning a serial number was successfully read from an
41
 * rfid tag */
42
char rfid_nonzero();
43

    
44
#endif