as3993 ST25RU3993 Firmware
gen2.h
Go to the documentation of this file.
1 /*
2  *****************************************************************************
3  * AS3993/ST25RU3993 Firmware tech@eleckits.com http://iot.eleckits.com *
4  * STMicroelectronics ST25RU3993 is an EPC Class 1 Gen 2 RFID reader IC *
5  * *
6  * IMPORTANT - PLEASE READ CAREFULLY BEFORE COPYING, INSTALLING OR USING *
7  * THE SOFTWARE. *
8  * *
9  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS *
10  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT *
11  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS *
12  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT *
13  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, *
14  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT *
15  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, *
16  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY *
17  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *
18  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE *
19  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
20  *****************************************************************************
21  */
105 #ifndef __GEN2_H__
106 #define __GEN2_H__
107 
108 #include "as3993_public.h"
109 #include "ams_types.h"
110 #include "errno_as3993.h"
111 
112 /* Protocol configuration settings */
113 #define GEN2_LF_40 0
114 #define GEN2_LF_160 6
115 #define GEN2_LF_213 8
116 #define GEN2_LF_256 9
117 #define GEN2_LF_320 12
118 #define GEN2_LF_640 15
121 #define GEN2_COD_FM0 0
122 #define GEN2_COD_MILLER2 1
123 #define GEN2_COD_MILLER4 2
124 #define GEN2_COD_MILLER8 3
126 /* TrExt defines */
127 #define TREXT_OFF 0
128 #define TREXT_ON 1
130 /* Tari defines */
131 #define TARI_625 0
132 #define TARI_125 1
133 #define TARI_25 2
135 /*EPC Mem Banks */
136 
137 #define MEM_RES 0x00
138 
139 #define MEM_EPC 0x01
140 
141 #define MEM_TID 0x02
142 
143 #define MEM_USER 0x03
144 
145 /*EPC Wordpointer Addresses */
147 #define MEMADR_CRC 0x00
148 
149 #define MEMADR_PC 0x01
150 
151 #define MEMADR_EPC 0x02
152 
154 #define MEMADR_KILLPWD 0x00
155 
156 #define MEMADR_ACCESSPWD 0x02
157 
159 #define MEMADR_TID 0x00
160 
161 /*EPC SELECT TARGET */
163 #define GEN2_IINV_S0 0x00 /*Inventoried (S0) */
164 
165 #define GEN2_IINV_S1 0x01 /*001: Inventoried (S1) */
166 
167 #define GEN2_IINV_S2 0x02 /*010: Inventoried (S2) */
168 
169 #define GEN2_IINV_S3 0x03 /*011: Inventoried (S3) */
170 
171 #define GEN2_IINV_SL 0x04 /*100: SL */
172 
173 #define GEN2_SESSION_S0 0x00
174 #define GEN2_SESSION_S1 0x01
175 #define GEN2_SESSION_S2 0x02
176 #define GEN2_SESSION_S3 0x03
177 
179 #define GEN2_OK ERR_NONE
180 #define GEN2_ERR_REQRN ERR_GEN2_REQRN
181 #define GEN2_ERR_ACCESS ERR_GEN2_ACCESS
182 #define GEN2_ERR_SELECT ERR_GEN2_SELECT
183 #define GEN2_ERR_CHANNEL_TIMEOUT ERR_GEN2_CHANNEL_TIMEOUT
185 struct gen2Config{
186  u8 tari; /*< Tari setting */
187  u8 linkFreq; /*< GEN2_LF_40, ... */
188  u8 miller; /*< GEN2_COD_FM0, ... */
189  u8 trext; /*< 1 if the preamble is long, i.e. with pilot tone */
190  u8 sel; /*< For QUERY Sel field */
191  u8 session; /*< GEN2_SESSION_S0, ... */
192  u8 target; /*< For QUERY Target field */
193 };
194 
195 struct gen2SelectParams{
196  u8 target;
197  u8 action;
198  u8 mem_bank;
199  u8 mask[32];
200  u32 mask_address;
201  u8 mask_len;
202  u8 truncation;
203 };
204 
205 /*------------------------------------------------------------------------- */
229 unsigned gen2SearchForTags(Tag *tags
230  , u8 maxtags
231  , u8 q
232  , u8 addRounds
233  , u8 queryAdjustUpTh
234  , u8 queryAdjustDownTh
235  , BOOL (*cbContinueScanning)(void)
236  , BOOL singulate
237  , BOOL toggleSession
238  , s8 (*followTagCommand)(Tag *tag)
239  );
240 
241 
246  , u8 maxtags
247  , u8 q
248  , BOOL (*cbContinueScanning)(void)
249  , BOOL singulate
250  , BOOL toggleSession
251  , s8 (*followTagCommand)(Tag *tag)
252  );
253 /*------------------------------------------------------------------------- */
267 s8 gen2AccessTag(Tag const * tag, u8 const * password);
268 
269 /*------------------------------------------------------------------------- */
285 s8 gen2LockTag(Tag *tag, const u8 *mask_action, u8 *tag_reply);
286 
287 /*------------------------------------------------------------------------- */
305 s8 gen2KillTag(Tag const * tag, u8 const * password, u8 rfu, u8 recom, u8 *tag_error);
306 
307 /*------------------------------------------------------------------------- */
327 s8 gen2WriteWordToTag(Tag const * tag, u8 memBank, u32 wordPtr, u8 const * databuf, u8 * tag_error);
328 
329 /*------------------------------------------------------------------------- */
345 s8 gen2ReadFromTag(Tag *tag, u8 memBank, u32 wordPtr,
346  u8 wordCount, u8 *destbuf);
347 
348 /*------------------------------------------------------------------------- */
352 void gen2Select(struct gen2SelectParams *p);
353 
354 /*------------------------------------------------------------------------------ */
355 /*Sends the tags EPC via the UART to the host */
356 /*The function needs the tags structure */
357 void gen2PrintEPC(Tag *tag);
358 
359 /*------------------------------------------------------------------------- */
365 void gen2PrintTagInfo(Tag *tag, u8 epclen, u8 tagNr);
366 
375 void gen2Configure(const struct gen2Config *config);
376 
386 void gen2Open(const struct gen2Config * config);
387 
395 void gen2Close(void);
396 
403 s8 gen2QueryMeasureRSSI(u8 *agc, u8 *log_rssis, s8 *irssi, s8 *qrssi);
404 
412 struct gen2Config *getGen2IntConfig();
413 
414 
415 #endif
This file provides defines for error codes reported by the FW to the host.
s8 gen2LockTag(Tag *tag, const u8 *mask_action, u8 *tag_reply)
Definition: gen2.c:485
s8 gen2KillTag(Tag const *tag, u8 const *password, u8 rfu, u8 recom, u8 *tag_error)
Definition: gen2.c:519
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))
Definition: gen2.c:679
unsigned gen2SearchForTagsAutoAck(Tag *tags_, u8 maxtags, u8 q, BOOL(*cbContinueScanning)(void), BOOL singulate, BOOL toggleSession, s8(*followTagCommand)(Tag *tag))
Definition: gen2.c:861
void gen2PrintTagInfo(Tag *tag, u8 epclen, u8 tagNr)
Definition: gen2.c:655
void gen2Close(void)
Close a session.
Definition: gen2.c:1174
s8 gen2AccessTag(Tag const *tag, u8 const *password)
Definition: gen2.c:438
void gen2Configure(const struct gen2Config *config)
Set the link frequency.
Definition: gen2.c:994
struct gen2Config * getGen2IntConfig()
Returns the Gen2 Configuration.
Definition: gen2.c:1178
s8 gen2QueryMeasureRSSI(u8 *agc, u8 *log_rssis, s8 *irssi, s8 *qrssi)
Perform a gen2 QUERY command and measure received signal strength.
Definition: gen2.c:205
s8 gen2WriteWordToTag(Tag const *tag, u8 memBank, u32 wordPtr, u8 const *databuf, u8 *tag_error)
Definition: gen2.c:566
void gen2Select(struct gen2SelectParams *p)
Definition: gen2.c:142
Tag tags_[MAXTAG]
void gen2Open(const struct gen2Config *config)
Open a session.
Definition: gen2.c:1169
Declaration of public functions provided by the AS3993 series chips.
s8 gen2ReadFromTag(Tag *tag, u8 memBank, u32 wordPtr, u8 wordCount, u8 *destbuf)
Definition: gen2.c:611