as3993 ST25RU3993 Firmware
|
#include "as3993_config.h"
#include "platform.h"
#include "as3993.h"
#include "logger.h"
#include "timer.h"
#include "gen2.h"
#include "string.h"
Go to the source code of this file.
Macros | |
#define | EPCDEBUG 0 |
#define | EPCLOG(...) |
#define | EPCLOGDUMP(...) |
#define | EPC_QUERYREP 0 |
#define | EPC_ACK 1 |
#define | EPC_QUERY 0x08 |
#define | EPC_QUERYADJUST 0x09 |
#define | EPC_SELECT 0x0A |
#define | EPC_NAK 0xC0 |
#define | EPC_REQRN 0xC1 |
#define | EPC_READ 0xC2 |
#define | EPC_WRITE 0xC3 |
#define | EPC_KILL 0xC4 |
#define | EPC_LOCK 0xC5 |
#define | EPC_ACCESS 0xC6 |
#define | EPC_BLOCKWRITE 0xC7 |
#define | EPC_BLOCKERASE 0xC8 |
#define | EPC_BLOCKPERMALOCK 0xC9 |
Functions | |
static s8 | gen2ReqRNHandleChar (u8 const *handle, u8 *dest_handle) |
void | gen2Select (struct gen2SelectParams *p) |
s8 | gen2QueryMeasureRSSI (u8 *agc, u8 *log_rssis, s8 *irssi, s8 *qrssi) |
static s8 | gen2SlotAutoAck (Tag *tag, u8 qCommand, u8 q, BOOL fast, u8 followCommand) |
s8 | gen2AccessTag (Tag const *tag, u8 const *password) |
s8 | gen2LockTag (Tag *tag, const u8 *mask_action, u8 *tag_reply) |
s8 | gen2KillTag (Tag const *tag, u8 const *password, u8 rfu, u8 recom, u8 *tag_error) |
s8 | gen2WriteWordToTag (Tag const *tag, u8 memBank, u32 wordPtr, u8 const *databuf, u8 *tag_error) |
s8 | gen2ReadFromTag (Tag *tag, u8 memBank, u32 wordPtr, u8 wordCount, u8 *destbuf) |
void | gen2PrintTagInfo (Tag *tag, u8 epclen, u8 tagNr) |
unsigned | gen2SearchForTags (Tag *tags_, u8 maxtags, u8 q, u8 addRounds, u8 queryAdjustUpTh, u8 queryAdjustDownTh, BOOL(*cbContinueScanning)(void), BOOL singulate, BOOL toggleSession, s8(*followTagCommand)(Tag *tag)) |
unsigned | gen2SearchForTagsAutoAck (Tag *tags_, u8 maxtags, u8 q, BOOL(*cbContinueScanning)(void), BOOL singulate, BOOL toggleSession, s8(*followTagCommand)(Tag *tag)) |
void | gen2Configure (const struct gen2Config *config) |
void | gen2Open (const struct gen2Config *config) |
void | gen2Close (void) |
struct gen2Config * | getGen2IntConfig () |
Variables | |
static u8 | buf_ [8+EPCLENGTH+PCLENGTH+CRCLENGTH] |
This file includes functions providing an implementation of the ISO6c aka GEN2 RFID EPC protocol.
Detailed documentation of the provided functionality can be found in gen2.h.
Definition in file gen2.c.
#define EPC_BLOCKERASE 0xC8 |
#define EPC_BLOCKPERMALOCK 0xC9 |
#define EPC_BLOCKWRITE 0xC7 |
#define EPC_NAK 0xC0 |
#define EPC_QUERYADJUST 0x09 |
#define EPC_REQRN 0xC1 |
#define EPCLOG | ( | ... | ) |
#define EPCLOGDUMP | ( | ... | ) |
s8 gen2AccessTag | ( | Tag const * | tag, |
u8 const * | password | ||
) |
EPC ACCESS command send to the Tag. This function is used to bring a tag with set access password from the Open state to the Secured state.
*tag | Pointer to the Tag structure. |
*password | Pointer to first byte of the access password |
void gen2Close | ( | void | ) |
void gen2Configure | ( | const struct gen2Config * | config | ) |
s8 gen2KillTag | ( | Tag const * | tag, |
u8 const * | password, | ||
u8 | rfu, | ||
u8 | recom, | ||
u8 * | tag_error | ||
) |
EPC KILL command send to the Tag. This function is used to permanently kill a tag. After that the tag will never ever respond again.
*tag | Pointer to the Tag structure. |
*password | Pointer to first byte of the kill password |
rfu | 3 bits used as rfu content for first half of kill, should be zero |
recom | 3 bits used as recom content for second half of kill, zero for real kill, !=0 for recommisioning |
*tag_error,: | in case header bit is set this will be the return code from the tag |
s8 gen2LockTag | ( | Tag * | tag, |
const u8 * | mask_action, | ||
u8 * | tag_reply | ||
) |
EPC LOCK command send to the Tag. This function is used to lock some data region in the tag.
*tag | Pointer to the Tag structure. |
*mask_action | Pointer to the first byte of the mask and action array. |
*tag_reply | In case ERR_HEADER is returned this variable will contain the 8-bit error code from the tag. |
void gen2Open | ( | const struct gen2Config * | config | ) |
void gen2PrintTagInfo | ( | Tag * | tag, |
u8 | epclen, | ||
u8 | tagNr | ||
) |
s8 gen2ReadFromTag | ( | Tag * | tag, |
u8 | memBank, | ||
u32 | wordPtr, | ||
u8 | wordCount, | ||
u8 * | destbuf | ||
) |
EPC READ command send to the Tag.
*tag | Pointer to the Tag structure. |
memBank | Memory Bank to which the data should be written. |
wordPtr | Word Pointer Address to which the data should be written. |
wordCount | Number of bytes to read from the tag. |
*destbuf | Pointer to the first byte of the data array. |
|
static |
EPC REQRN command send to the Tag. This function is used to request a new RN16 or a handle from the tag.
*handle | Pointer to the first byte of the handle. |
*dest_handle | Pointer to the first byte of the backscattered handle. |
unsigned gen2SearchForTags | ( | Tag * | tags, |
u8 | maxtags, | ||
u8 | q, | ||
u8 | addRounds, | ||
u8 | queryAdjustUpTh, | ||
u8 | queryAdjustDownTh, | ||
BOOL(*)(void) | cbContinueScanning, | ||
BOOL | singulate, | ||
BOOL | toggleSession, | ||
s8(*)(Tag *tag) | followTagCommand | ||
) |
Search for tags (aka do an inventory round). Before calling any other gen2 functions this routine has to be called. It first selects using the given mask a set of tags and then does an inventory round issuing query commands. All tags are stored in then tags array for examination by the user.
*tags | an array for the found tags to be stored to |
maxtags | the size of the tags array |
q | 2^q slots will be done first, additional 2 round with increased or decreased q may be performed |
addRounds | additional Rounds with Query Adjust |
queryAdjustUpTh | Threshold for the additional round with Query Adjust to increase Q; slots * (queryAdjustUpTh/100) |
queryAdjustDownTh | Threshold for the additional round with Query Adjust to decrease Q; slots * (queryAdjustDownTh/100) |
cbContinueScanning | callback is called after each slot to inquire if we should continue scanning (e.g. for allowing a timeout) |
singulate | If set to true Req_RN command will be sent to get tag into Open state otherwise it will end up in arbitrate |
toggleSession | If set to true, QueryRep commands will be sent immediately after receiving tag reply to toggle session flag on tag. |
followTagCommand | callback function is called after a tag is inventoried. If function will be called, no fast mode is possible. |
unsigned gen2SearchForTagsAutoAck | ( | Tag * | tags_, |
u8 | maxtags, | ||
u8 | q, | ||
BOOL(*)(void) | cbContinueScanning, | ||
BOOL | singulate, | ||
BOOL | toggleSession, | ||
s8(*)(Tag *tag) | followTagCommand | ||
) |
For reference see gen2SearchForTags(). The main difference is that it uses the autoACK mode of the reader.
void gen2Select | ( | struct gen2SelectParams * | p | ) |
|
static |
s8 gen2WriteWordToTag | ( | Tag const * | tag, |
u8 | memBank, | ||
u32 | wordPtr, | ||
u8 const * | databuf, | ||
u8 * | tag_error | ||
) |
EPC WRITE command send to the Tag. This function writes one word (16 bit) to the tag. It first requests a new handle. The handle is then exored with the data.
*tag | Pointer to the Tag structure. |
memBank | Memory Bank to which the data should be written. |
wordPtr | Word Pointer Address to which the data should be written. |
*databuf | Pointer to the first byte of the data array. The data buffer has to be 2 bytes long. |
*tag_error | In case tag returns an error (header bit set), this functions returns ERR_HEADER and inside tag_error the actual code |
struct gen2Config* getGen2IntConfig | ( | ) |