as3993 ST25RU3993 Firmware
Macros | Functions | Variables
appl_commands.h File Reference
#include "global.h"

Go to the source code of this file.

Macros

#define CMD_READER_CONFIG   0
 
#define CMD_ANTENNA_POWER   1
 
#define CMD_CHANGE_FREQ   2
 
#define CMD_GEN2_SETTINGS   3
 
#define CMD_CONFIG_TX_RX   4
 
#define CMD_INVENTORY_GEN2   5
 
#define CMD_SELECT_TAG   6
 
#define CMD_WRITE_TO_TAG   7
 
#define CMD_READ_FROM_TAG   8
 
#define CMD_LOCK_UNLOCK_TAG   9
 
#define CMD_KILL_TAG   10
 
#define CMD_START_STOP   12
 
#define CMD_TUNER_TABLE   13
 
#define CMD_AUTO_TUNER   14
 
#define CMD_ANTENNA_TUNER   15
 
#define CMD_INVENTORY_6B   17
 
#define CMD_READ_FROM_TAG_6B   18
 
#define CMD_WRITE_TO_TAG_6B   19
 
#define CMD_GENERIC_CMD_ID   20
 
#define CMD_RSSI_MEAS_CMD_ID   21
 
#define CMD_CALL_PA_ID   22
 
#define CMD_CALL_INV_PARAMS_ID   23
 
#define CMD_CALL_INV_PARAMS_ID   23
 

Functions

u8 commands (u8 protocol, u16 rxSize, const u8 *rxData, u16 *txSize, u8 *txData)
 
u8 sendTagData (u8 *protocol, u16 *txSize, u8 *txData, u16 remainingSize)
 
int doCyclicInventory (void)
 
u8 readRegister (u8 addr, u16 *txSize, u8 *txData)
 
u8 readRegisters (u16 *txSize, u8 *txData)
 
u8 writeRegister (u8 addr, u8 value, u16 *txSize, u8 *txData)
 

Variables

struct callFunction call_fkt_ [CALL_FKT_SIZE]
 

Detailed Description

This file is the include file for the appl_commands.c file.

This file contains defines for handling appl commands, eg: The defines for the index of command functions in call_ftk_() and expected rx and tx data sizes.

Author
Ulrich Herrmann
Bernhard Breinbauer
Rene Eggerstorfer

Definition in file appl_commands.h.

Macro Definition Documentation

#define CMD_ANTENNA_POWER   1

appl command ID for callAntennaPower()

Definition at line 80 of file appl_commands.h.

#define CMD_ANTENNA_TUNER   15

appl command ID for callAntennaTuner()

Definition at line 106 of file appl_commands.h.

#define CMD_AUTO_TUNER   14

appl command ID for callAutoTuner()

Definition at line 104 of file appl_commands.h.

#define CMD_CALL_INV_PARAMS_ID   23

appl command ID for callInventoryParams()

Definition at line 216 of file appl_commands.h.

#define CMD_CALL_INV_PARAMS_ID   23

appl command ID for callInventoryParams()

Definition at line 216 of file appl_commands.h.

#define CMD_CALL_PA_ID   22

appl command ID for callConfigPA()

Definition at line 118 of file appl_commands.h.

#define CMD_CHANGE_FREQ   2

appl command ID for callChangeFreq()

Definition at line 82 of file appl_commands.h.

#define CMD_CONFIG_TX_RX   4

appl command ID for callConfigTxRx()

Definition at line 86 of file appl_commands.h.

#define CMD_GEN2_SETTINGS   3

appl command ID for callConfigGen2()

Definition at line 84 of file appl_commands.h.

#define CMD_GENERIC_CMD_ID   20

appl command ID for callGenericCMD()

Definition at line 114 of file appl_commands.h.

#define CMD_INVENTORY_6B   17

appl command ID for callInventory6B()

Definition at line 108 of file appl_commands.h.

#define CMD_INVENTORY_GEN2   5

appl command ID for callInventoryGen2()

Definition at line 88 of file appl_commands.h.

#define CMD_KILL_TAG   10

appl command ID for callKillTag()

Definition at line 98 of file appl_commands.h.

#define CMD_LOCK_UNLOCK_TAG   9

appl command ID for callLockUnlockTag()

Definition at line 96 of file appl_commands.h.

#define CMD_READ_FROM_TAG   8

appl command ID for callReadFromTag()

Definition at line 94 of file appl_commands.h.

#define CMD_READ_FROM_TAG_6B   18

appl command ID for callReadFromTag6B()

Definition at line 110 of file appl_commands.h.

#define CMD_READER_CONFIG   0

appl command ID for callReaderConfig()

Definition at line 78 of file appl_commands.h.

#define CMD_RSSI_MEAS_CMD_ID   21

appl command ID for callRSSIMeasureCMD()

Definition at line 116 of file appl_commands.h.

#define CMD_SELECT_TAG   6

appl command ID for callSelectTag()

Definition at line 90 of file appl_commands.h.

#define CMD_START_STOP   12

appl command ID for callStartStop()

Definition at line 100 of file appl_commands.h.

#define CMD_TUNER_TABLE   13

appl command ID for callTunerTable()

Definition at line 102 of file appl_commands.h.

#define CMD_WRITE_TO_TAG   7

appl command ID for callWriteToTag()

Definition at line 92 of file appl_commands.h.

#define CMD_WRITE_TO_TAG_6B   19

appl command ID for callWriteToTag6B()

Definition at line 112 of file appl_commands.h.

Function Documentation

u8 commands ( u8  protocol,
u16  rxSize,
const u8 *  rxData,
u16 *  txSize,
u8 *  txData 
)

Process various generic commands.

Parameters
protocol: forward from applProcessCmd()
rxData: forward from applProcessCmd()
rxSize: forward from applProcessCmd()
txData: forward from applProcessCmd()
txSize: forward from applProcessCmd()
Returns
error code for processed command

Protocol description

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

Protocol for USB:

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().

Byte01234..56..78..8+txprot-1
ContentTIDpayloadreservedprotocoltxprotrxprotdata
ParameterprotocolrxSizetxSizerxData[0..rxSize-1]

where

  • TID : transaction ID.
  • payload: amount of data in report.
  • protocol: defines which action should be triggered. If commands() is is called it refers to a firmware application command (no generic stream command).
  • txprot: amount of data which has been received and should be forwarded to command function.
  • rxprot: This variable contains the expected size of data this command will return and will be set to the size of the actual data to be tx-ed back to host.
  • data: input data for command

The response will look like this:

Byte0123456..78..8+txprot-1
ContentTIDpayloadstream statusprotocolreservedprot statustxprotdata
ParameterprotocolstatustxSizetxData[0..txSize-1]

where

  • TID : transaction ID.
  • payload: amount of data in report.
  • stream status : a non-zero value indicates that a previous command could not be processed
  • protocol : defines to which action the transmitted data belongs
  • prot status : a non-zero value indicates error condition of command (return value of function commands())
  • txprot: size of data in response
  • data: response data for command

Example for the antenna power command, handled by callAntennaPower():

Request from host (Reader Suite):

Byte01234..56..78
ContentTIDpayloadreservedprotocoltxprotrxprotdata
Value0x0F0x070x000x010x00020x00010xFF

where:

The reader answer with this report:

Byte0123456..78
ContentTIDpayloadstream statusprotocolreservedprot statustxprotdata
Value0xF00x060x000x010x000x000x00010x00
  • 0x00 (txData[0]): the data this command produced.
  • 0x00 (status): ERR_NONE

Protocol for UART:

A simple UART stream packet is shown in the following table, which maps the transmitted data to the function parameters of commands().

Byte012..345..67..89..9+txprot-1
ContentTIDStatuspayloadprotocoltxprotrxprotdata
ParameterprotocolrxSizetxSizerxData[0..rxSize-1]

where

  • TID : transaction ID.
  • Status : Uart Status
  • payload: amount of data in report.
  • protocol: defines which action should be triggered. If commands() is is called it refers to a firmware application command (no generic stream command).
  • txprot: amount of data which has been received and should be forwarded to command function.
  • rxprot: This variable contains the expected size of data this command will return and will be set to the size of the actual data to be tx-ed back to host.
  • data: input data for command

The response will look like this:

Byte012..34567..89..9+txprot-1
ContentTIDStatuspayloadprotocolreservedprot statustxprotdata
ParameterprotocolstatustxSizetxData[0..txSize-1]

where

  • TID : transaction ID.
  • Status : Uart Status
  • payload: amount of data in report.
  • protocol : defines to which action the transmitted data belongs
  • prot status : a non-zero value indicates error condition of command (return value of function commands())
  • txprot: size of data in response
  • data: response data for command

UART Settings:

  • BAUD RATE: 115200
  • DATA BITS: 8
  • PARITY: NONE
  • STOP BITS: 1
  • FLOW CONTROL: NONE

Example for the config TX RX command, handled by callConfigTxRx():

Request from host (Reader Suite):

Byte0 12..345..67..89..12
ContentTID Statuspayloadprotocoltxprot rxprot data
Parameter0x200x00 0x00 090x04 0x00 040x00 040x00 00 01 01

where:

  • 0x04: command ID for callConfigTxRx(), is also used as index in call_fkt_() table.
  • 0x00 00 01 01 : parameter for callConfigTxRx() (set_sensitivity = false and sensitivity = 0; set_antenna = true and antenna id = 1)

The reader answer with this report:

Byte012..34567..8 9..12
ContentTID Statuspayloadprotocolreservedprot statustxprot data
Parameter0x010x00 0x00 090x04 0x00 0x00 0x00 040x00 0B 00 01
  • 0x00 0B 00 01: reserved bytes are 0x00, sensitivity is 0x0B and antenna id is 0x01

Example for the Inventory Gen2 command, handled by callInventoryGen2():

Request from host (Reader Suite):

Byte0 12..345..67..89..12
ContentTID Statuspayloadprotocoltxprot rxprot data
Parameter0x070x00 0x00 080x85 0x00 030x00 000x00 01 06

where:

The reader answer with this report:

Byte012..34567..8 9..12
ContentTID Statuspayloadprotocolreservedprot statustxprot data
Parameter0x760x00 0x00 140x05 0x00 0x00 0x00 0F00 00 01 8f ff ac 3c 0d 06 10 00 ba ba 77 77
  • 0xba ba 77 77: epc of tag

Example for the Read from Tag command, handled by callReadFromTag():

Request from host (Reader Suite):

Byte0 12..345..67..89..17
ContentTID Statuspayloadprotocoltxprot rxprot data
Parameter0x3E0x00 0x00 0e0x08 0x00 090x00 090x00 00 00 00 00 00 00 00 00

where:

The reader answer with this report:

Byte012..34567..8 9..16
ContentTID Statuspayloadprotocolreservedprot statustxprot data
Parameter0xE70x00 0x00 0D0x08 0x00 0x00 0x00 0800 00 00 00 55 55 55 55
  • 00 00 00 00 55 55 55 55: reserved memory of the tag

Implemented commands

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.

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.

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.

Parameters
addrregister address
txSizeexpected tx size
txDatabuffer for reply
Returns
error code

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.

Parameters
txSizeexpected tx size
txDatabuffer for reply
Returns
error code

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()

Parameters
protocolProtocol byte for the stream packet
txDataBuffer to use for tx data
txSizeNumber of bytes which have been copied into the buffer.
remainingSizeNumber of available bytes in the tx buffer.
Returns
Status of the command.

The fixed size part of a tag data reply payload (as described in callInventoryGen2()) consists of:
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
followed by an epc with variable length.
If the parameter readTIDinInventoryRound is set to 1, one byte with the tidlen and the tid with variable length will follow.

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.

Parameters
addrregister address
valuethe value to write
txSizeexpected tx size
txDatabuffer for reply
Returns
error code

Definition at line 1097 of file appl_commands.c.

Variable Documentation

struct callFunction call_fkt_[CALL_FKT_SIZE]

Table of function pointers. The offset in the table matches the command identifier. When a command is received the corresponding function will be called via this table.

Definition at line 67 of file appl_commands_table.c.