as3993 ST25RU3993 Firmware
Typedefs | Functions | Variables
iso6b.c File Reference
#include "global.h"
#include "timer.h"
#include "bitbang.h"
#include "as3993.h"
#include "iso6b.h"
#include "crc16.h"
#include "logger.h"
#include "platform.h"

Go to the source code of this file.

Typedefs

typedef void(* iso6bCmd )(void)
 

Functions

static s8 iso6bPreparePreambleDelimiter (t_bbData *preData)
 
static s8 iso6bPrepareByte (t_bbData *manchdata, u8 byteData)
 
static s8 iso6bPrepareCRC (t_bbData *crcData, s16 crc)
 
static void iso6bResync ()
 
static void iso6bSendCmd (u8 cmd)
 
static void iso6bSendResend ()
 
static void iso6bSendInitialize ()
 
static void iso6bSendSuccess ()
 
static void iso6bSendFail ()
 
static void iso6bSendSelect (u8 mask, u8 *filter, u8 startaddress)
 
s8 iso6bInitialize ()
 
void iso6bOpen ()
 
void iso6bClose ()
 
s8 iso6bInventoryRound (Tag *tags, u8 maxtags, u8 mask, u8 *filter, u8 startaddress)
 
s8 iso6bRead (u8 *uid, u8 addr, u8 *buffer)
 
s8 iso6bWrite (u8 *uid, u8 addr, u8 data, u8 *buffer)
 

Variables

static t_bbData cmdData [50]
 

Detailed Description

Implementation of ISO18000-6b protocol.

Author
Rene Eggerstorfer (based on the work of C. Eisendle and T. Luecker (Substitute), project AS399x)

Implementation of ISO18000-6b protocol.

Definition in file iso6b.c.

Typedef Documentation

typedef void(* iso6bCmd)(void)

function pointer indicating the function to be used in the next collision arbitration iteration

Definition at line 64 of file iso6b.c.

Function Documentation

void iso6bClose ( void  )

Close a session.

Close the session for iso6b protocol.

Definition at line 113 of file iso6b.c.

s8 iso6bInitialize ( void  )

Initializes the iso6b module.

Returns
ISO6B_ERR_NONE : No error

Definition at line 88 of file iso6b.c.

s8 iso6bInventoryRound ( Tag tags,
u8  maxtags,
u8  mask,
u8 *  filter,
u8  startaddress 
)

This function performs an iso6b inventory round and stores up to maxtags tags into the variable tags. It performs a select function which compares up to eight consecutive bytes within the tags to a given buffer. If the tag's memory content which starts at address startaddress matches the buffer given by filter the tag backscatters his UID. The bitmask mask is used to indicate which bytes of the buffer shall be compared with the tag's memory content. If mask is zero all tags are selected.

Note
The function iso6bOpen() has to be called first.
Parameters
[out]tags: an array of Tag structs which will be filled by this function
[in]maxtags: the size of the array
[in]mask: mask identifying which bytes have to be compared
[in]filter: 8 byte long compare buffer
[in]startaddress: address of the first register to compare within the tag
Returns
the number of tags found.

Definition at line 117 of file iso6b.c.

void iso6bOpen ( void  )

Open a session.

Open a session for iso6b protocol.

Set iso6b specific parameters.

Definition at line 94 of file iso6b.c.

static s8 iso6bPrepareByte ( t_bbData manchdata,
u8  byteData 
)
static

Convert a byte to manchester coded data.

The data within an ISO18000-6B packet is manchester encoded. E.g. a 0 is encoded as 01 and a 1 is encoded as 10.

Parameters
[out]manchdata: Buffer where the manchster coded data is stored.
[in]byteData: data to write
Returns
: Actual size of the buffer used by the function

Definition at line 434 of file iso6b.c.

static s8 iso6bPrepareCRC ( t_bbData crcData,
s16  crc 
)
static

Convert a the CRC checksum to manchester coded data.

The data within an ISO18000-6B packet is manchester encoded. E.g. a 0 is encoded as 01 and a 1 is encoded as 10. This function is used to convert the already calculated CRC-16 sum to manchester encoded data. The checksum is decribed in section 6.5.7.3. in ISO18000-6 doc

Parameters
crcData: A buffer where the encoded CRC will be written. Buffer must be allocated and has to have a size of 4 (at least)
crc: CRC sum to send
Returns
: Actual size of the buffer used by the function

Definition at line 477 of file iso6b.c.

static s8 iso6bPreparePreambleDelimiter ( t_bbData preData)
static

Write the preamble and delimiter into the output packet.

This function writes the preamble and delimiter into the output packet. According to the ISO18000-6B protocol, a packet from the interrogator must start with a preamble and a delimiter. See section 8.1.4.3. and 8.1.4.4.2. of the ISO18000-6 document. The data is written to an output buffer which is then sent to the AS3991 via the bitbang module.

Parameters
preData: A buffer where the preamble and delimiter will be written. Buffer must be allocated and has to have a size of 4 (at least)
Returns
: Actual size of the buffer used by the function

Definition at line 378 of file iso6b.c.

s8 iso6bRead ( u8 *  uid,
u8  startaddr,
u8 *  buffer 
)

Issue READ command according to ISO18000-6 and stores the result in a buffer.

This function sends the READ command via the AS3993 to the tag with a given id. The data is read from start address startaddr until 8 bytes have been read. The answer is then written to the memory location pointed by buffer.

Note
The function iso6bOpen() has to be called first.
Parameters
[in]uid: 8 byte long uid of the tag
[in]startaddr: start address within the tag
[out]buffer: pointer to a memory location where the result shall be stored
Returns
ISO6B_ERR_REG_FIFO : Error reading the FIFO
ISO6B_ERR_NOTAG : No response from tag
ISO6B_ERR_IRQ : Irq Error
ISO6B_ERR_NONE : No error

Definition at line 229 of file iso6b.c.

static void iso6bResync ( )
static

Send out a resync to the tags via the AS3993.

This function is used to send out a resync signal to the tags. This is needed to initialize the internal data recovery circuit of the tag which calibrates the tag. (Especially after read and write commands)

Definition at line 404 of file iso6b.c.

static void iso6bSendCmd ( u8  cmd)
static

Send a command in direct mode according to ISO18000-6.

This function sends the command via the AS3993 to the tags. It only supports simple commands, i.e. commands where no additional information or data payload is needed. Note that the AS3993 needs to be in direct mode when using this function.

Parameters
[in]cmd: Command code to send

Definition at line 500 of file iso6b.c.

static void iso6bSendFail ( )
static

Issue FAIL command according to ISO18000-6.

The FAIL command is used during collision arbitration. FAIL is issued when there was a CRC error, i.e. more then one tag have replied. Tags having a count of 0 receiving the FAIL command call a random function (rand(0, 1)). If the function returns 0 they leave their internal count and resend the UID. If it returns 1 then they increment their counter, i.e. count is 1 then. All tags having a count greater than 0 increment their counter when they receive the FAIL command, i.e. they move fruther away from sending their UID.

Definition at line 577 of file iso6b.c.

static void iso6bSendInitialize ( )
static

Issue INITIALIZE command according to ISO18000-6.

The initialize command sets all tags into state READY.

Definition at line 541 of file iso6b.c.

static void iso6bSendResend ( )
static

Issue RESEND command according to ISO18000-6.

The resend command is used during collision abitration. RESEND is issued when tags with count = 0 shall resend their UID while other tags shall keep their current count value.

Definition at line 528 of file iso6b.c.

static void iso6bSendSelect ( u8  mask,
u8 *  filter,
u8  startaddress 
)
static

Issue the GROUP_SELECT command according to ISO18000-6.

The GROUP_SELECT command starts the collision arbitration. All tags receiving this command change their state from READY to ID, i.e. they set their internal counter to 0 and send their UID.

Definition at line 592 of file iso6b.c.

static void iso6bSendSuccess ( )
static

Issue SUCCESS command according to ISO18000-6.

The SUCCESS command is used during collision arbitration. SUCCESS is issued when NO reply has been received, i.e. all tags in the field have count > 0. As soon as the tags receive the SUCCESS command, they decrement their counter. If count is 0 the tag transmits its uid.

Definition at line 557 of file iso6b.c.

s8 iso6bWrite ( u8 *  uid,
u8  addr,
u8  data,
u8 *  buffer 
)

Issue WRITE command according to ISO18000-6 to write a specified number of bytes to a memory location within a tag.

This function sends the WRITE command via the AS3993 to the tag with a given uid. This command stores the data to the memory location at the addr on the tag.

Note
WARNING: THIS FUNCTION WAS NEVER TESTED !!!
The function iso6bOpen() has to be called first.
Parameters
[in]uid: 8 byte long uid of the tag
[in]addr: address of the register to write
[in]data: data to write
[out]buffer: pointer to a memory location where the result acknowledge or error shall be stored
Returns
ISO6B_ERR_REG_FIFO : Error reading the FIFO
ISO6B_ERR_NOTAG : No response from tag
ISO6B_ERR_IRQ : Irq Error
ISO6B_ERR_NONE : No error

Definition at line 291 of file iso6b.c.

Variable Documentation

t_bbData cmdData[50]
static

buffer used for the bitbang module

Definition at line 53 of file iso6b.c.