as3993 ST25RU3993 Firmware
|
#include "as3993_config.h"
#include "platform.h"
#include "global.h"
#include "gen2.h"
#include "as3993_public.h"
#include "appl_commands.h"
#include "logger.h"
#include "errno.h"
#include "iso6b.h"
#include "timer.h"
#include "string.h"
#include <limits.h>
#include "as3993.h"
#include "tuner.h"
Go to the source code of this file.
Data Structures | |
struct | CmdBuffer |
Macros | |
#define | APPLDEBUG 0 |
#define | SESSION_GEN2 1 |
#define | SESSION_ISO6B 2 |
#define | MAX_SELECTS 2 |
#define | POWER_DOWN 0 |
#define | POWER_NORMAL 1 |
#define | POWER_NORMAL_RF 2 |
#define | POWER_STANDBY 3 |
#define | APPLOG(...) |
#define | APPLOGDUMP(...) |
Functions | |
static TuningTable tuningTable | __attribute__ ((far)) = {15, 15, 15} |
s8 | gen2ReadTID (Tag *tag) |
static void | powerDownReader (void) |
static void | powerUpReader (void) |
static void | adaptSlotCounter (int num_of_tags) |
static BOOL | continueCheckTimeout () |
static void | checkAndSetSession (u8 newSession) |
void | callWrongCommand (void) |
void | callAntennaPower (void) |
void | callAntennaTuner (void) |
void | callAutoTuner (void) |
static u8 | addToTuningTable (void) |
void | callTunerTable (void) |
void | callReaderConfig (void) |
u8 | writeRegister (u8 addr, u8 value, u16 *txSize, u8 *txData) |
u8 | readRegister (u8 addr, u16 *txSize, u8 *txData) |
void | callConfigTxRx (void) |
void | callConfigGen2 (void) |
u8 | readRegisters (u16 *txSize, u8 *txData) |
void | callInventory6B (void) |
void | callReadFromTag6B (void) |
void | callWriteToTag6B (void) |
void | callInventoryGen2Internal () |
void | callInventoryGen2 (void) |
void | callSelectTag (void) |
void | callWriteToTag (void) |
void | callChangeFreq (void) |
void | callReadFromTag (void) |
void | callLockUnlockTag (void) |
void | callKillTag (void) |
void | callStartStop (void) |
void | callGenericCommand (void) |
int | doCyclicInventory (void) |
u8 | commands (u8 protocol, u16 rxSize, const u8 *rxData, u16 *txSize, u8 *txData) |
u8 | sendTagData (u8 *protocol, u16 *txSize, u8 *txData, u16 remainingSize) |
void | callConfigPA (void) |
void | callInventoryParams (void) |
Functions which handle commands received via USB or UART.
This file contains all functions for processing commands received via either USB or UART. It implements the parsing of reports data, executing the requested command and sending data back.
A description of the protocol between host and FW is included in the documentation for commands(). The documentation of the various appl command functions (call*) will only discuss the payload of the command data and will not include the header information for every transmitted packet, as this is already described for commands().
The frequency hopping is also done in this file before calling protocol/device specific functions.
Definition in file appl_commands.c.
#define APPLDEBUG 0 |
Define this to 1 if you want to have logging for appl commands.
Definition at line 71 of file appl_commands.c.
#define APPLOG | ( | ... | ) |
macro used for printing debug messages if USE_LOGGER is set
Definition at line 94 of file appl_commands.c.
#define APPLOGDUMP | ( | ... | ) |
macro used for dumping buffers if USE_LOGGER is set
Definition at line 95 of file appl_commands.c.
#define MAX_SELECTS 2 |
Maximum of consecutive select commands currently supported.
Definition at line 79 of file appl_commands.c.
#define POWER_DOWN 0 |
value for readerPowerDownMode. Activates power down mode. (EN low)
Definition at line 82 of file appl_commands.c.
#define POWER_NORMAL 1 |
value for readerPowerDownMode. Activates normal mode. (EN high, RF off, stdby 0)
Definition at line 84 of file appl_commands.c.
#define POWER_NORMAL_RF 2 |
value for readerPowerDownMode. Activates normal mode with rf field on. (EN high, RF off, stdby 0)
Definition at line 86 of file appl_commands.c.
#define POWER_STANDBY 3 |
value for readerPowerDownMode. Activates standby mode. (EN high, RF off, stdby 1)
Definition at line 88 of file appl_commands.c.
#define SESSION_GEN2 1 |
Identifier for gen2 protocol session
Definition at line 74 of file appl_commands.c.
#define SESSION_ISO6B 2 |
Identifier for ISO6B protocol session
Definition at line 76 of file appl_commands.c.
|
static |
The tuningTable contains a list of frequencies and values for the tuner for every frequency. When frequency hopping is performed (hopFrequencies()) the closest frequency in the list is looked up and the corresponding tuner values are applied to the DTCs of the tuner. The tuningTable can be modified via callTunerTable().
Default and current tuner settings.
|
static |
This function adapts the Slot Counter Q based on the number of found tags.
The slot counter gen2qbegin will be incremented if (slots <= (2.0*num_of_tags). The slot counter gen2qbegin will be decremented if (slots/2) > (2.0* num_of_tags).
num_of_tags | Number of Found Tags |
Definition at line 3671 of file appl_commands.c.
|
static |
adds data in current USB buffer to tuning table, should be only called from callAntennaTuner().
Definition at line 689 of file appl_commands.c.
void callAntennaPower | ( | void | ) |
This function enables/disables the RF field and is executed when a stream packet with protocol = CMD_ANTENNA_POWER is received.
The payload of the stream packet looks like this:
Byte | 0 | 1 |
---|---|---|
Content | 0x00 for off 0xFF for on | eval_mode |
eval_mode: reserved, should be zero
The device sends back:
Byte | 0 |
---|---|
Content | 0 |
Status of the reply packet indicates success or error.
Definition at line 402 of file appl_commands.c.
void callAntennaTuner | ( | void | ) |
This function sets and reads antenna tuner network related values and is executed when a stream packet with protocol = CMD_ANTENNA_TUNER is received. There are different kind of tuning networks available. The full network which is currently supported by the Firmware looks like this:
On the Femto Reader there is a reduced tuning network: Clen is missing.
The DTCs capacity values range from:
The format of the payload from the host is: Get/Set current tuner parameters:
Byte | 0 | 1 | 2 | 3 | 4 | 5 |
---|---|---|---|---|---|---|
Content | set_cin | cin | set_clen | clen | set_cout | cout |
The values are only being set if the proper set_X value is set to 1.
The device sends back:
Byte | 0 | 1 | 2 | 3 | 4 | 5 |
---|---|---|---|---|---|---|
Content | reserved (0) | cin | reserved(0) | clen | reserved(0) | cout |
Reply status will be set to ERR_NONE if operation was successful. If reader does not support tuning status will be set to ERR_REQUEST.
Definition at line 501 of file appl_commands.c.
void callAutoTuner | ( | void | ) |
This function allows to trigger a auto tuning cycle. For in detail information to antenna tuning see callAntennaTuner() and tuner.h.
The function is executed when a stream packet with protocol = CMD_AUTO_TUNER is received. The format of the payload from the host is:
Byte | 0 |
---|---|
Content | auto_tune |
If the auto_tune value is not equal zero a auto tuner cycle will be started:
The device does not send a reply back, but the result of the auto tuning procedure can be read by callAntennaTuner().
Definition at line 612 of file appl_commands.c.
void callChangeFreq | ( | void | ) |
This function sets/adds/measures frequency related stuff and is executed when a stream packet with protocol = CMD_CHANGE_FREQ is received.
The format of the payload received from the host is one of the following:
Get RSSI level
Byte | 0 | 1 .. 3 |
---|---|---|
Content | 1 (SubCmd) | freq |
The reader replies with:
Byte | 0 | 1 | 2 |
---|---|---|---|
Content | I-channel | Q-channel | - |
The reader replies with ERR_REQUEST for HW with no external PA.
Get Reflected Power level
Byte | 0 | 1 .. 3 | 4 |
---|---|---|---|
Content | 2 (SubCmd) | freq | Apply Tuner Setting |
to which the reader replies with:
Byte | 0 | 1 |
---|---|---|
Content | I-channel | Q-channel |
Add frequency to frequency list used for hopping. If clear_list is set the list will be deleted before adding the new frequency. rssi_threshhold and profile_id are global values and not set for every frequency. Therefore the last value which they have been set to is valid.
Byte | 0 | 1 .. 3 | 4 | 5 | 6 |
---|---|---|---|---|---|
Content | 4 (SubCmd) | freq | clear_list | rssi_threshhold(dBm) | profile_id |
Where rssi_threshold is used by the "listen before talk" feature: Before hopping to a new channel the reader listens on the frequency if the rssi value is smaller than this threshold.
profile_id is used by the Reader Suite to enumerate the various frequency profiles.
The reader replies with this:
Byte | 0 |
---|---|
Content | 0x00 |
Status will be set to ERR_MEM if no more frequency can be added (see MAXFREQ). If command was successful status will be ERR_NONE.
Get frequency list related parameters
Byte | 0 |
---|---|
Content | 5 (SubCmd) |
The reader replies with:
Byte | 0 | 1 .. 3 | 4 .. 6 | 7 | 8 |
---|---|---|---|---|---|
Content | profile_id | min_freq | max_freq | curr_num_freqs | host_num_freqs |
Where profile_id and rssi_threshold refer to the values used in SubCmd 4. Values for the other parameters are:
Name | values |
---|---|
min_freq | Minimum frequency of current frequency list. |
max_freq | Maximum frequency of current frequency list. |
curr_num_freq | Number of frequencies in current frequency list. |
host_num_freq | Number of frequencies the host sent to add with SubCmd 4. Might be bigger than curr_num_freq. |
Set frequency hopping related parameters
Byte | 0 | 1 .. 2 | 3 .. 4 | 5 .. 6 | 7 |
---|---|---|---|---|---|
Content | 8 (SubCmd) | listeningTime | maxSendingTime | idleTime | rssi threshold |
The reader replies with:
Byte | 0 |
---|---|
Content | 0x00 |
Status of reply will be ERR_NONE.
Get frequency hopping related parameters
Byte | 0 |
---|---|
Content | 9 (SubCmd) |
The reader replies with:
Byte | 0 .. 1 | 2.. 3 | 4 .. 5 |
---|---|---|---|
Content | listening_time | max_sending_time | idle_time |
Status of reply will be ERR_NONE.
Byte | 0 | 1 .. 3 | 4 .. 5 | 6 | 7 .. 16 |
---|---|---|---|---|---|
Content | 16 (SubCmd) | freq | duration in ms | random | random_data |
Definition at line 2177 of file appl_commands.c.
void callConfigGen2 | ( | void | ) |
This function sets and reads various gen2 related settings and is executed when a stream packet with protocol = CMD_CONFIG_TX_RX is received. Most of the parameters are related to the QUERY commmand of the Gen2 protocol specification.
The format of the payload from the host is:
Byte | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Content | set_lf | lf | set_coding | coding | set_session | session | set_trext | trext | set_tari | tari | set_qbegin | qbegin | set_sel | sel | set_target | target |
The values are only being set if the proper set_X value is set to 1.
The device sends back:
Byte | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Content | reserved(0) | lf | reserved(0) | coding | reserved(0) | session | reserved(0) | trext | reserved(0) | tari | reserved(0) | qbegin | reserved(0) | sel | reserved(0) | target |
Values for the different parameters are:
Name | values |
---|---|
lf | 0 = 40 kHz, 3 = 80 kHz not AS3993, 6 = 160 kHz, 8 = 213 kHz, 9 = 256 kHz, 12 = 320 kHz, 15 = 640 kHz |
coding | 0 = FM0, 1 = Miller2, 2 = Miller4, 3 = Miller8 |
session | 0 = S0, 1 = S1, 2 = S2, 3 = S3 |
trext | 0 = short preamble, no pilot tone, 1 = long preamble, pilot tone |
tari | 0 = 6.25 us, 1 = 12.5 us, 2 = 25 us |
qbegin | 0 .. 15. Initial gen2 round is 2^qbegin long. Please be careful with higher values. |
sel | 0 .. 1 = All, 2 = ~SL, 3 = SL |
target | 0 = A, 1 = B |
Definition at line 1383 of file appl_commands.c.
void callConfigPA | ( | void | ) |
This function changes the PA HW configuration and is executed when a stream packet with protocol = CMD_CALL_PA_ID is received.
This function is currently only available for Newton readers. The payload of the stream packet looks like this:
Byte | 0 | 1 |
---|---|---|
Content | ReadWriteMode | Config Word |
ReadWriteMode:
0=> Read, 1=>Write and Read
ConfigWord:
Bit 0 (LSB) : Value for G8
Bit 1 (2LSB): Value for G16
1 => High
0 => Low
The reply of this command looks like this:
Byte | 1 |
---|---|
Content | Config Word |
Status of the reply packet indicates success or error.
Definition at line 3489 of file appl_commands.c.
void callConfigTxRx | ( | void | ) |
This function sets and reads various RF Tx/Rx related settings and is executed when a stream packet with protocol = CMD_CONFIG_TX_RX is received.
The format of the payload from the host is:
Byte | 0 | 1 | 2 | 3 |
---|---|---|---|---|
Content | set_sensitivity | sensitivity | set_antenna | antenna id |
The values are only being set if the proper set_X value is set to 1.
The device sends back:
Byte | 0 | 1 | 2 | 3 |
---|---|---|---|---|
Content | reserved(0) | sensitivity | reserved (0) | antenna id |
Values for the different parameters are:
Name | values |
---|---|
sensitivity | -128 .. 127 (dBm) |
antenna id | 1: antenna port 1 2: antenna port 2 |
Definition at line 1187 of file appl_commands.c.
void callGenericCommand | ( | void | ) |
This function executes an generic command from a previously selected gen2 tag when a stream packet with protocol = CMD_GENERIC_CMD_ID is received.
The format of the payload from the host is:
Byte | 0..3 | 4..5[UpperNibble] | 5[LowerNibble]..6 | 7 | 8 | 9..9+TransmitByteSize |
---|---|---|---|---|---|---|
Content | password | length_transmit_data | length_receive_data | direct command | no_response_time | transmit data |
Parameters are:
The device sends back the following report:
Byte | 0 | 1 | 2..2+ReceivedByteSize |
---|---|---|---|
Content | status | length_received_data | received data |
Definition at line 2683 of file appl_commands.c.
void callInventory6B | ( | void | ) |
This function performs one inventory round using ISO18000-6b protocol. The format of the payload from the host is:
Byte | 0 | 1..8 | 9 |
---|---|---|---|
Content | address | word_data | mask |
where
The device sends back:
Byte | 0 | 1..8 | 9..16 | ... |
---|---|---|---|---|
Content | number of tags | ID of first tag | ID of second tag | ... |
Definition at line 1455 of file appl_commands.c.
void callInventoryGen2 | ( | void | ) |
This function performs a single gen2 protocol inventory round according to
parameters configured by callConfigGen2() and callSelectTag().
The function is executed when a stream packet with protocol = CMD_INVENTORY_GEN2 is received.
The format of the payload from the host is:
Byte | 0 | 1 | 2 |
---|---|---|---|
Content | autoAck | tid(2LSB)+fast(LSB) | rssi |
Where autoAck defines if the autoACK mode of the reader is used. If autoAck = 0 autoACK will not be used, otherwise autoACK will be used. The parameter tid defines if a read of the TID Memory will be performed in inventory rounds. If tid = 1 the TID memory will be read, otherwise no read will be done. Parameter fast defines how the inventory rounds are performed. If fast = 0 the inventory round is executed until the tag is in the Open state. If fast = 1 the inventory round is stopped when the tag reaches Acknowledged state (no Req_RN command is sent). See Gen2 protocol specification page 47: Tag state diagram for details.
The rssi parameter defines which rssi value should be measured when getting a tag. The value of rssi parameter will be written to register 0x29.
The device sends back all the tags using the following report:
Byte | 0 | 1 | 2 | 3 | 4 | 5 .. 7 | 8 | 9 | 10 | 11 .. 11+epclen | 12+epclen | 13+epclen .. 15+epclen | ... |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Content | cyclic | tags_left | tags_in_reply | AGC and status (reg 0x2A) | RSSI_value (reg 0x2B) | base_freq | epclen+pclen | pc[0] | pc[1] | epc | next tag: RSSI | next tag: base_freq | ... |
Sending the reply is implemented in function sendTagData(), which has to be called repeatedly until all tag data has been sent.
Definition at line 1667 of file appl_commands.c.
void callInventoryGen2Internal | ( | ) |
This function is called by callInventoryGen2() and doCyclicInventory() and performs the actual Gen2 inventory round.
Definition at line 1589 of file appl_commands.c.
void callInventoryParams | ( | void | ) |
This function changes some Inventory Parameters and is executed when a stream packet with protocol = CMD_CALL_INV_PARAMS_ID is received.
The payload of the stream packet looks like this:
Byte | 0 | 1..2 | 3 | 4 | 5 | 6 | 7 | 8 | 9..10 | 11 |
---|---|---|---|---|---|---|---|---|---|---|
Content | Write Round Delay | Round Delay | Write Query Adjust Parameters | Adaptive Q | Addtional Rounds | QueryAdjust Up Threshold | QueryAdjust Down Threshold | Write Tuning Parameters | Tuning Interval | Tuning Deviation |
Write Round Delay: 0 => Read, 1 => Write and Read
Round Delay: Inventory Round Delay
Write Query Adjust Parameters: 0 => Read, 1 => Write and Read
Adaptive Q: 0 => Off, 1 => On, see function inventoryGen2
Addtional Rounds: see function gen2SearchForTags
QueryAdjust Up Threshold: see function gen2SearchForTags
QueryAdjust Down Threshold: see function gen2SearchForTags
Write Tuning Parameters: 0 => Read, 1 => Write and Read
Tuning Interval: see function hopFrequencies
Tuning Deviation: see function hopFrequencies
The reply of this command looks like this:
Byte | 0..1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |
---|---|---|---|---|---|---|---|---|
Content | Round Delay | Adaptive Q | Addtional Rounds | QueryAdjust Up Threshold | QueryAdjust Down Threshold | Write Tuning Parameters | Tuning Interval | Tuning Deviation |
Status of the reply packet indicates success or error.
Definition at line 3541 of file appl_commands.c.
void callKillTag | ( | void | ) |
This function kills a gen2 tag and is executed when a stream packet with protocol = CMD_KILL_TAG is received.
The format of the payload from the host is:
Byte | 0 .. 3 | 4 |
---|---|---|
Content | kill password | recom |
where:
The device sends back the following report:
Byte | 0 |
---|---|
Content | status |
Definition at line 2594 of file appl_commands.c.
void callLockUnlockTag | ( | void | ) |
This function locks\unlocks a gen2 tag and is executed when a stream packet with protocol = CMD_LOCK_UNLOCK_TAG is received.
The format of the payload from the host is:
Byte | 0..2 | 3 .. 5 |
---|---|---|
Content | mask_and_action | access password |
The device sends back the following report:
Byte | 0 |
---|---|
Content | tag_code |
Definition at line 2534 of file appl_commands.c.
void callReaderConfig | ( | void | ) |
This function gets/sets the current reader config and is executed when a stream packet with protocol = CMD_READER_CONFIG is received. The reader config contains the power down mode which can be changed and various non-changeable parameters like: error codes, FW compile time switches, ...
The format of the payload from the host is:
Byte | 0 | 1 |
---|---|---|
Content | set_powermode | powermode |
The values are only being set if the proper set_X value is set to 1.
The powermode value will be applied to readerPowerDownMode variable and used in powerDownReader() and powerUpReader().
The device reply payload is:
Byte | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |
---|---|---|---|---|---|---|---|---|---|
Content | WrongChipId | InitErrCode | VCO | PA | INPUT | AntSwitch | Tuner | powerDownMode | Hardware ID |
The values for the parameters are:
Parameter | Values |
---|---|
WrongChipId | 0-99: No Error. FW and reader chip match. The value is the last to digits of the reader chip eg: for AS3993 the value is 93. 0xFF: FW is not compatible with the reader chip on this board. |
Init Error | 0: No Error. Init of reader chip was successful. 1: Writing and reading SPI failed. 2: Reset via EN low + high failed. 3: IRQ line failed. 4: Crystal not stable (Bit0 in AGC and Internal Status register 0x2A). 5: PLL not locked (Bit1 in AGC and Internal Status register 0x2A) |
VCO | 0: FW was compiled for internal VCO (INTVCO). 1: FW was compiled for external VCO (EXTVCO). |
PA | 0: FW was compiled for internal PA (INTPA). 1: FW was compiled for external PA (EXTPA). |
Input | 0: FW was compiled for balanced input (BALANCEDINP). 1: FW was compiled for single input (SINGLEINP). |
AntSwitch | 0: FW was not compiled for 2 antenna ports. 1: FW was compiled to use 2 antenna ports (ANTENNA_SWITCH). |
Tuner | Or'ed tuner configuration, every bit repesents a tunable cap (DTC). 0: FW does not support tuning. 0x01: Cin tuner is used (TUNER_CIN). 0x02: Clen tuner is used (TUNER_CLEN). 0x04: Cout tuner is used (TUNER_COUT). other bits: not yet supported. |
powerDownMode | Currently configured power down mode of reader. Available modes are: POWER_DOWN, POWER_NORMAL, POWER_NORMAL_RF and POWER_STANDBY. |
Hardware ID | Identification number for the board (HARDWARE_ID_NUM) Available IDs are defined in as3993_config.h |
If any of the parameters is set to 0xFF an unidentified error/configuration occured.
Definition at line 995 of file appl_commands.c.
void callReadFromTag | ( | void | ) |
This function reads from a previously selected gen2 tag and is executed when a stream packet with protocol = CMD_READ_FROM_TAG is received.
The format of the payload from the host is:
Byte | 0 | 1..4 | 5..8 |
---|---|---|---|
Content | mem_bank | address | password |
rxSize divided by two defines the number of words to be read. If rxSize is odd then word by word reading is used. If even the desired memory is read as one bulk. Parameters are:
The device sends back the following report:
Byte | 0..txSize(max) |
---|---|
Content | data |
If the returned error is ERR_HEADER, the txSize will be odd and the last byte will be the error code returned by the tag.
Definition at line 2433 of file appl_commands.c.
void callReadFromTag6B | ( | void | ) |
This function reads from a tag using ISO18000-6b protocol command READ. The format of the payload from the host is:
Byte | 0..7 | 8 |
---|---|---|
Content | ID | address |
The device sends back:
Byte | 0..7 |
---|---|
Content | word_data |
Definition at line 1508 of file appl_commands.c.
void callSelectTag | ( | void | ) |
This function stores or clears gen2 select command parameters. The gen2 select based on these parameters can be executed with the function performSelects.
A Gen2 tag can be singulated using the given mask for subsequent operations like inventory/read/write. Several (MAX_SELECTS) Select commands can be configured, which are executed sequentially, allowing union and intersection based tag partitioning. See Gen2 protocol specification for further details.
This function is executed when a stream packet with protocol = CMD_SELECT_TAG is received.
The format of the payload received from the host is one of the following:
Clear list of Select commands (no Select commands is executed):
Byte | 0 | ... |
---|---|---|
Content | 0x00 (SubCmd ID) | ignored |
The device sends back status ERR_NONE and no payload.
Add to list of Select commands, execute the Select commands and try to singulate a tag:
Byte | 0 | 1 | 2 | 3 | 4 .. 5 | 6 | 7 | 8 .. 8 + mask_len |
---|---|---|---|---|---|---|---|---|
Content | 0x01 (SubCmd ID) | target | action | mem_bank | address | mask_len | truncate | mask |
The device sends back a status (no payload). ERR_MEM if no more select command can be selected or a specific Gen2 error if singulating tag failed.
Byte | 0 | 1 | 2 | 3 | 4 .. 5 | 6 | 7 | 8 .. 8 + mask_len |
---|---|---|---|---|---|---|---|---|
Content | 0x02 (SubCmd ID) | target | action | mem_bank | address | mask_len | truncate | mask |
Values for the different parameters are:
Name | values |
---|---|
target | 0 = Inventoried (S0), 1 = Inventoried (S1), 2 = Inventoried (S2), 3 = Inventoried (S3), 4 = SL, >4 = RFU |
action | Action tag should perform is Select matches. See Table 6.20 in Gen2 protocol specification. |
mem_bank | 0 = RFU, 1 = EPC, 2 = TID, 3 = User |
address | 16bit pointer in memory bank, where mask should be applied. Will be converted into EBV format before Select command is sent. |
mask_len | Length of mask in bits. |
truncate | 0 = Disable truncation. 1 = Enable truncation. |
mask | Actual mask data. |
Definition at line 1849 of file appl_commands.c.
void callStartStop | ( | void | ) |
This function starts/stops cyclic inventory rounds and is executed when a stream packet with protocol = CMD_START_STOP is received.
The cyclic inventory rounds are performed by calling callInventoryGen2Internal() from the main loop. Therefore after starting a cyclic inventory, the host has to expect data just like after issueing the callInventoryGen2() because sendTagData() will be called repeatedly.
The format of the payload from the host is:
Byte | 0 | 1 | 2 | 3 | 4 |
---|---|---|---|---|---|
Content | update | start | autoAck | tid(2LSB)+fast(LSB) | rssi |
If update is zero the command is ignored. Parameter start defines if the cyclic inventories are started (1) or stopped (0).
For description of autoAck,tid, fast and rssi parameters see callInventoryGen2().
The device sends back:
Byte | 0 |
---|---|
Content | current start value |
Subsequently callInventoryGen2() result packets are returned in a dense continuous loop.
Definition at line 2639 of file appl_commands.c.
void callTunerTable | ( | void | ) |
This function allows to update the tuner table. For in detail information to antenna tuning see callAntennaTuner() and tuner.h.
The function is executed when a stream packet with protocol = CMD_TUNER_TABLE is received. The format of the payload received from the host is one of the following:
Get current tuning table size:
Byte | 0 |
---|---|
Content | 0x00 (SubCmd ID) |
The device sends back:
Byte | 0 | 1 | 2 |
---|---|---|---|
Content | 0x00 (SubCmd ID) | maximum tuning table size this device supports | current tuning table size |
Delete current tuning table:
Byte | 0 |
---|---|
Content | 0x01 (SubCmd ID) |
The device sends back:
Byte | 0 | 1 | 2 |
---|---|---|---|
Content | 0x01 (SubCmd ID) | maximum tuning table size this device supports | n/a |
Add new entry in tuning table:
Byte | 0 | 1..3 | 4 | 5 | 6 | 7 | 8..9 | 10 | 11 | 12 | 13 | 14..15 |
---|---|---|---|---|---|---|---|---|---|---|---|---|
Content | 0x02 (SubCmd ID) | frequency | Ant1: tune enable | Ant1: cin | Ant1: clen | Ant1: cout | Ant1: I*I+Q*Q | Ant2: tune enable | Ant2: cin | Ant2: clen | Ant2: cout | Ant2: I*I+Q*Q |
Adds the data to the internal tuning table. The first set of data is for antenna 1 the second set for antenna 2.
The device responds:
Byte | 0 | 1 | 2 |
---|---|---|---|
Content | 0x02 (SubCmd ID) | remaining size in tuningTable | n/a |
If no more space is left in tuningTable the status will be set to ERR_NOMEM. If adding to tuningTable was successful status will be set to ERR_NONE.
Byte | 0 | 1 | 2 |
---|---|---|---|
Content | 0xFF | 0x00 | n/a |
Definition at line 880 of file appl_commands.c.
void callWriteToTag | ( | void | ) |
This function writes to a previously selected (callSelectTag()) gen2 tag
and is executed when a stream packet with protocol = CMD_WRITE_TO_TAG is received.
The format of the payload from the host is:
Byte | 0 | 1 | 2 .. 5 | 6 .. (rxsize-1) |
---|---|---|---|---|
Content | mem_bank | address | acces_pw | data |
where
The device sends back:
Byte | 0 | 1 |
---|---|---|
Content | num_words_written | tag error code if status==ERR_HEADER |
Definition at line 1940 of file appl_commands.c.
void callWriteToTag6B | ( | void | ) |
This function writes to a tag using ISO18000-6b protocol command WRITE. The format of the payload from the host is:
Byte | 0..7 | 8 | 9 |
---|---|---|---|
Content | ID of the tag | address | byte_data |
The device sends back:
Byte | 0 |
---|---|
Content | acknowledge |
Definition at line 1552 of file appl_commands.c.
void callWrongCommand | ( | void | ) |
Dummy appl command which is called if an invalid command ID was received. Logs error message and returns error ERR_REQUEST to host.
Definition at line 343 of file appl_commands.c.
|
static |
This function can be used instead of continueCheckTimeout() to circumvent allocation timeouts as this function always returns 1. This funcition checks the current session, if necessary closes it and opens a new session. Valid session values are: SESSION_GEN2 and SESSION_ISO6B.
Definition at line 311 of file appl_commands.c.
u8 commands | ( | u8 | protocol, |
u16 | rxSize, | ||
const u8 * | rxData, | ||
u16 * | txSize, | ||
u8 * | txData | ||
) |
Process various generic commands.
protocol | : forward from applProcessCmd() |
rxData | : forward from applProcessCmd() |
rxSize | : forward from applProcessCmd() |
txData | : forward from applProcessCmd() |
txSize | : forward from applProcessCmd() |
The following description gives an overview of the ams stream protocol and how the data of stream packets is forwarded to the commands() function. The protocol can be executed over USB or UART. Only the header bytes between USB and UART are different.
For a detailed description of the ams stream protocol have a look in ams_stream.h
A simple USB stream packet (not splitted, only 1 protocol in packet) is shown in the following table, which maps the transmitted data to the function parameters of commands().
Byte | 0 | 1 | 2 | 3 | 4..5 | 6..7 | 8..8+txprot-1 |
---|---|---|---|---|---|---|---|
Content | TID | payload | reserved | protocol | txprot | rxprot | data |
Parameter | protocol | rxSize | txSize | rxData[0..rxSize-1] |
where
The response will look like this:
Byte | 0 | 1 | 2 | 3 | 4 | 5 | 6..7 | 8..8+txprot-1 |
---|---|---|---|---|---|---|---|---|
Content | TID | payload | stream status | protocol | reserved | prot status | txprot | data |
Parameter | protocol | status | txSize | txData[0..txSize-1] |
where
Request from host (Reader Suite):
Byte | 0 | 1 | 2 | 3 | 4..5 | 6..7 | 8 |
---|---|---|---|---|---|---|---|
Content | TID | payload | reserved | protocol | txprot | rxprot | data |
Value | 0x0F | 0x07 | 0x00 | 0x01 | 0x0002 | 0x0001 | 0xFF |
where:
The reader answer with this report:
Byte | 0 | 1 | 2 | 3 | 4 | 5 | 6..7 | 8 |
---|---|---|---|---|---|---|---|---|
Content | TID | payload | stream status | protocol | reserved | prot status | txprot | data |
Value | 0xF0 | 0x06 | 0x00 | 0x01 | 0x00 | 0x00 | 0x0001 | 0x00 |
A simple UART stream packet is shown in the following table, which maps the transmitted data to the function parameters of commands().
Byte | 0 | 1 | 2..3 | 4 | 5..6 | 7..8 | 9..9+txprot-1 |
---|---|---|---|---|---|---|---|
Content | TID | Status | payload | protocol | txprot | rxprot | data |
Parameter | protocol | rxSize | txSize | rxData[0..rxSize-1] |
where
The response will look like this:
Byte | 0 | 1 | 2..3 | 4 | 5 | 6 | 7..8 | 9..9+txprot-1 |
---|---|---|---|---|---|---|---|---|
Content | TID | Status | payload | protocol | reserved | prot status | txprot | data |
Parameter | protocol | status | txSize | txData[0..txSize-1] |
where
UART Settings:
Request from host (Reader Suite):
Byte | 0 | 1 | 2..3 | 4 | 5..6 | 7..8 | 9..12 |
---|---|---|---|---|---|---|---|
Content | TID | Status | payload | protocol | txprot | rxprot | data |
Parameter | 0x20 | 0x00 | 0x00 09 | 0x04 | 0x00 04 | 0x00 04 | 0x00 00 01 01 |
where:
The reader answer with this report:
Byte | 0 | 1 | 2..3 | 4 | 5 | 6 | 7..8 | 9..12 |
---|---|---|---|---|---|---|---|---|
Content | TID | Status | payload | protocol | reserved | prot status | txprot | data |
Parameter | 0x01 | 0x00 | 0x00 09 | 0x04 | 0x00 | 0x00 | 0x00 04 | 0x00 0B 00 01 |
Request from host (Reader Suite):
Byte | 0 | 1 | 2..3 | 4 | 5..6 | 7..8 | 9..12 |
---|---|---|---|---|---|---|---|
Content | TID | Status | payload | protocol | txprot | rxprot | data |
Parameter | 0x07 | 0x00 | 0x00 08 | 0x85 | 0x00 03 | 0x00 00 | 0x00 01 06 |
where:
The reader answer with this report:
Byte | 0 | 1 | 2..3 | 4 | 5 | 6 | 7..8 | 9..12 |
---|---|---|---|---|---|---|---|---|
Content | TID | Status | payload | protocol | reserved | prot status | txprot | data |
Parameter | 0x76 | 0x00 | 0x00 14 | 0x05 | 0x00 | 0x00 | 0x00 0F | 00 00 01 8f ff ac 3c 0d 06 10 00 ba ba 77 77 |
Request from host (Reader Suite):
Byte | 0 | 1 | 2..3 | 4 | 5..6 | 7..8 | 9..17 |
---|---|---|---|---|---|---|---|
Content | TID | Status | payload | protocol | txprot | rxprot | data |
Parameter | 0x3E | 0x00 | 0x00 0e | 0x08 | 0x00 09 | 0x00 09 | 0x00 00 00 00 00 00 00 00 00 |
where:
The reader answer with this report:
Byte | 0 | 1 | 2..3 | 4 | 5 | 6 | 7..8 | 9..16 |
---|---|---|---|---|---|---|---|---|
Content | TID | Status | payload | protocol | reserved | prot status | txprot | data |
Parameter | 0xE7 | 0x00 | 0x00 0D | 0x08 | 0x00 | 0x00 | 0x00 08 | 00 00 00 00 55 55 55 55 |
Functions which handle the commands from the host are located in appl_commands.c
The documentation of the various appl command functions will only discuss the data received/sent back to host and will not include the header information for every transmitted packet.
For more details on the ams stream protocol have a look into ams_stream.h
Definition at line 3324 of file appl_commands.c.
|
static |
This function can be used as callback parameter for gen2SearchForTags(). It will return 1 as long as allocation timeout has not been exceeded yet. If allocation timeout has occured it will return 0.
Definition at line 289 of file appl_commands.c.
int doCyclicInventory | ( | void | ) |
This function is called periodically from main() loop. If a cyclic inventory has been started callInventoryGen2Internal() is called.
Definition at line 3036 of file appl_commands.c.
s8 gen2ReadTID | ( | Tag * | tag | ) |
This function reads the TID Memory of a specific Tag.
The maximum length is limited by TIDLENGTH.
*tag | Pointer to the Tag structure. |
Definition at line 3606 of file appl_commands.c.
|
static |
Handles the configured power down mode of the reader. The power down mode is define in readerPowerDownMode variable and can be changed via callReaderConfig(). Available modes are: POWER_DOWN, POWER_NORMAL, POWER_NORMAL_RF and POWER_STANDBY
Definition at line 3050 of file appl_commands.c.
|
static |
Handles power up of reader. Basically reverts changes done by powerDownReader().
Definition at line 3075 of file appl_commands.c.
u8 readRegister | ( | u8 | addr, |
u16 * | txSize, | ||
u8 * | txData | ||
) |
reads one AS3993 register at address and puts the value into the reply to the host.
see cmdReadReg() for reply structure.
addr | register address |
txSize | expected tx size |
txData | buffer for reply |
Definition at line 1125 of file appl_commands.c.
u8 readRegisters | ( | u16 * | txSize, |
u8 * | txData | ||
) |
reads all AS3993 registers and puts the values into the reply to the host.
see cmdReadReg() for reply structure.
txSize | expected tx size |
txData | buffer for reply |
Definition at line 1395 of file appl_commands.c.
u8 sendTagData | ( | u8 * | protocol, |
u16 * | txSize, | ||
u8 * | txData, | ||
u16 | remainingSize | ||
) |
This function sends the tag data received in the last inventory round to the host. The payload description is here: callInventoryGen2()
protocol | Protocol byte for the stream packet |
txData | Buffer to use for tx data |
txSize | Number of bytes which have been copied into the buffer. |
remainingSize | Number of available bytes in the tx buffer. |
number of bytes | content |
---|---|
1 | cyclic |
1 | tags_left |
1 | tags_in_reply |
1 | AGC and status (reg 0x2A) |
1 | RSSI_value (reg 0x2B) |
3 | base_freq |
1 | epclen+pclen |
2 | pc |
sum : 10 |
Definition at line 3390 of file appl_commands.c.
u8 writeRegister | ( | u8 | addr, |
u8 | value, | ||
u16 * | txSize, | ||
u8 * | txData | ||
) |
writes to AS3993 register at address addr the value and prepares tx answer to host.
see cmdWriteReg() for reply structure.
addr | register address |
value | the value to write |
txSize | expected tx size |
txData | buffer for reply |
Definition at line 1097 of file appl_commands.c.
|
static |
If set to 1 the adaptSlotCounter function should be executed after an inventory round.
Definition at line 206 of file appl_commands.c.
|
static |
Defines the Threshold for the QueryAdjust Parameter to decrement the Slot Counter Q. For details see gen2SearchForTags().
Definition at line 212 of file appl_commands.c.
|
static |
Defines the Number of additional rounds that can be executed after a Query Command Round
Definition at line 208 of file appl_commands.c.
|
static |
Defines the Threshold for the QueryAdjust Parameter to increment the Slot Counter Q. For details see gen2SearchForTags().
Definition at line 210 of file appl_commands.c.
|
static |
If set to 0 inventory round commandos will be triggered by the FW, otherwise the autoACK feature of the reader will be used which sends the required Gen2 commands automatically.
Definition at line 200 of file appl_commands.c.
|
static |
Structure which contains the command data which has been received and shall be sent. Provides access to parameters of commands() to all appl command funtions (call*()).
Definition at line 250 of file appl_commands.c.
|
static |
Index of currently used frequency in frequency table Frequencies. Used in hopFrequencies().
Definition at line 252 of file appl_commands.c.
|
static |
Currently used protocol, valid values are: SESSION_GEN2 and SESSION_ISO6B.
Definition at line 254 of file appl_commands.c.
|
static |
Will be set to 1 if a cyclic inventory is performed, see callStartStop().
Definition at line 196 of file appl_commands.c.
|
static |
If set to 0 normal inventory round will be performed, if set to 1 fast inventory rounds will be performed. The value is set in callStartStop() and callInventoryGen2(). For details on normal/fast inventory rounds see parameter singulate of gen2SearchForTags().
Definition at line 204 of file appl_commands.c.
Freq Frequencies |
Contains the list of used frequencies.
Definition at line 170 of file appl_commands.c.
|
static |
Default Gen2 configuration, can be changed callConfigGen2().
Definition at line 127 of file appl_commands.c.
u8 gen2qbegin = 4 |
Start value for Q for Gen2 inventory rounds, can be changed callConfigGen2().
Definition at line 129 of file appl_commands.c.
|
static |
Profile settings which can be set via GUI commands. We default to Europe settings.
Definition at line 172 of file appl_commands.c.
|
static |
Profile settings which can be set via GUI commands. We default to Europe settings.
Definition at line 178 of file appl_commands.c.
|
static |
Profile settings which can be set via GUI commands. We default to Europe settings.
Definition at line 176 of file appl_commands.c.
|
static |
Profile settings which can be set via GUI commands. We default to Europe settings.
Definition at line 174 of file appl_commands.c.
|
static |
Profile settings which can be set via GUI commands. We default to Europe settings.
Before starting the frequency hop this time (in ms) will be waited for.
Definition at line 184 of file appl_commands.c.
|
static |
Delay between Inventory Rounds
Definition at line 140 of file appl_commands.c.
|
static |
To be communicated to GUI, basically result of hopFrequencies(), having information on skipped rounds
Definition at line 225 of file appl_commands.c.
|
static |
Profile settings which can be set via GUI commands. We default to Europe settings.
Measure rssi for this time (in ms) before deciding if the channel should be used.
Definition at line 190 of file appl_commands.c.
|
static |
Maximal channel arbitration time in ms (internal value of maxSendingTime)
Definition at line 192 of file appl_commands.c.
|
static |
Will be set to 1 when maxSendingLimit in continueCheckTimeout() timed out.
Definition at line 194 of file appl_commands.c.
|
static |
Profile settings which can be set via GUI commands. We default to Europe settings.
Maximum allocation time (in ms) of a channel.
Definition at line 187 of file appl_commands.c.
|
static |
Internal variable which contains the number of received tags in the last inventory round.
Definition at line 155 of file appl_commands.c.
|
static |
Internal number of currently configured select commands.
Definition at line 150 of file appl_commands.c.
u16 readerInitStatus |
AS3993 init status. This is the return value of as3993Initialize()
Definition at line 160 of file appl_commands.c.
|
static |
Currently configured power down mode of reader. Available modes are: POWER_DOWN, POWER_NORMAL, POWER_NORMAL_RF and POWER_STANDBY
Definition at line 223 of file appl_commands.c.
|
static |
If set to 1 an read of the TID will be performed in inventory rounds. The value is set in callStartStop() and callInventoryGen2(). For details see parameter followTagCommand of gen2SearchForTags() and gen2ReadTID(Tag *tag).
Definition at line 217 of file appl_commands.c.
|
static |
Value for register AS3993_REG_STATUSPAGE. This defines what RSSI value is sent to the host along with the tag data. The value is set in callStartStop() and callInventoryGen2().
Definition at line 220 of file appl_commands.c.
|
static |
If rssi measurement is above this threshold the channel is regarded as used and the system will hop to the next frequency. Otherwise this frequency is used
Definition at line 181 of file appl_commands.c.
|
static |
Deviation Level for Retuning in percentage
Definition at line 148 of file appl_commands.c.
|
static |
Scan Tuning Interval
Definition at line 142 of file appl_commands.c.
Tag* selectedTag |
Pointer to data of currently selected Tag.
Definition at line 167 of file appl_commands.c.
|
static |
Parameters for select commands, can be changed via callSelectTag()
Definition at line 152 of file appl_commands.c.
|
static |
New tag data has been received in last inventory round and can be sent in sendTagData() now.
Definition at line 157 of file appl_commands.c.
Array of Structures which stores all necessary Information about the Tags.
Definition at line 164 of file appl_commands.c.
|
static |
Tuning counter
Definition at line 145 of file appl_commands.c.
|
static |
Stores which antenna port is used atm. valid values are 1 and 2.
Definition at line 230 of file appl_commands.c.