as3993 ST25RU3993 Firmware
|
#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] |
Implementation of ISO18000-6b protocol.
Implementation of ISO18000-6b protocol.
Definition in file iso6b.c.
typedef void(* iso6bCmd)(void) |
void iso6bClose | ( | void | ) |
s8 iso6bInitialize | ( | void | ) |
Initializes the iso6b module.
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.
[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 |
void iso6bOpen | ( | void | ) |
|
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.
[out] | manchdata | : Buffer where the manchster coded data is stored. |
[in] | byteData | : data to write |
|
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
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 |
|
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.
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) |
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.
[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 |
|
static |
|
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.
[in] | cmd | : Command code to send |
|
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.
|
static |
|
static |
|
static |
|
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.
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.
[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 |