SRD Standelone programmation box: CR95HF.c File Reference

| SRD Standelone programmation box 2.0 (16/11/15 10:00:00) Documentation of the SRD standelone programmation box

- Main Page
- Data Structures
- Files

- File List
- Globals

All Data Structures Files Functions Variables Enumerations Enumerator Macros Pages
Macros | Functions | Variables
CR95HF.c File Reference

Source file for CR95HF Driver. More...

`#include "CR95HF.h"`
Include dependency graph for CR95HF.c:

Go to the source code of this file.

## Macros

#define | CR95HF_FRAME_CMD_ECHO ({0x55})
#define | CR95HF_FRAME_CMD_ECHO_SIZE (1)
#define | CR95HF_FRAME_ANS_ECHO ({0x55})
#define | CR95HF_FRAME_ANS_ECHO_SIZE (1)

## Functions

void | CR95HFWriteCommand (char *command, unsigned short commandSize, char *answerExpected, unsigned short answerSize, unsigned short timeoutMs, unsigned short completionTimeMs, unsigned short waitForNbrRx)
void | CR95HFReadAnswer (void)
signed short | CR95HFBufCompare (char *dataBuf, unsigned short dataBufSize, char *dataBufRef, unsigned short dataBufRefSize)
void | CR95HFCommandManager (void)
void | CR95HFEchoStateMachine (void)
void | CR95HFFieldOffStateMachine (void)
void | CR95HFField15693StateMachine (void)
void | CR95HFHibernateStateMachine (void)
void | CR95HFReadStateMachine (void)
void | CR95HFWriteStateMachine (void)
void | CR95HFBridgeStateMachine (void)
void | CR95HFInit (void)
| Function used to initialize the CR95HF global manager. More...
void | CR95HFManager (void)
| Global manager of the CR95HF module. More...
void | CR95HFStartEcho (void)
| Manager used to deal each specific state. More...
void | CR95HFStartFieldOff (void)
void | CR95HFStartField15693 (void)
void | CR95HFStartHibernate (void)
void | CR95HFStartRead (unsigned short addr)
void | CR95HFStartWrite (unsigned short addr, unsigned long data)
void | CR95HFStartBridge (char *data, unsigned short dataLength)
tCR95HFIsReady | CR95HFManagerIsReady (void)
| Return the current state of the CR95HF module in it's manager. More...

## Variables

tCR95HFCtrl | CR95HFCtrl
| Variable used by the state machine of the CR95HF. More...

## Detailed Description

Source file for CR95HF Driver.

Author
  Thibaut LALUQUE 3D-Ouest

Date
  25/11/2014

Version
  1.0

All Right Reserved.

Definition in file CR95HF.c.

## Macro Definition Documentation

#define CR95HF_FRAME_ANS_ECHO ({0x55})

Definition at line 29 of file CR95HF.c.

#define CR95HF_FRAME_ANS_ECHO_SIZE (1)

Definition at line 30 of file CR95HF.c.

#define CR95HF_FRAME_CMD_ECHO ({0x55})

Definition at line 27 of file CR95HF.c.

#define CR95HF_FRAME_CMD_ECHO_SIZE (1)

Definition at line 28 of file CR95HF.c.

## Function Documentation

void CR95HFBridgeStateMachine | ( | void |  | ) |

Definition at line 535 of file CR95HF.c.

References tCR95HFCtrl::all, tCR95HFCtrl::bridgeCommand, tCR95HFCtrl::bridgeCommandLength, tCR95HFCtrl::command, tCR95HFCtrl::commandState, tCR95HFCtrl::completionTimeMs, CR95HF_BridgeState_Finish, CR95HF_BridgeState_Send, CR95HF_BridgeState_Start, CR95HF_BridgeState_WaitAnswer, CR95HF_COMMAND_NONE, CR95HF_RETURN_OK, CR95HF_RETURN_STATEMACHINE_ERROR, CR95HFWriteCommand(), tCR95HFCtrl::flags, tCR95HFCtrl::refMs, tCR95HFCtrl::resultCode, tCR95HFCtrl::rxPos, and tCR95HFCtrl::timeoutMs.

Referenced by CR95HFCommandManager().

535 {
536 char dataResult[2];
537
538 switch(CR95HFCtrl.commandState) {
539
540 case CR95HF_BridgeState_Start:
541 CR95HFCtrl.commandState = CR95HF_BridgeState_Send;
542 // No break;
543
544 case CR95HF_BridgeState_Send:
545
546 dataResult[0] = 0x87;
547 dataResult[1] = 0x00;
548
549 CR95HFWriteCommand(CR95HFCtrl.bridgeCommand,CR95HFCtrl.bridgeCommandLength,dataResult,2,50,25,0);
550
551 CR95HFCtrl.commandState = CR95HF_BridgeState_WaitAnswer;
552 break;
553
554 case CR95HF_BridgeState_WaitAnswer:
555 CR95HFCtrl.commandState = CR95HF_BridgeState_Finish;
556 CR95HFCtrl.resultCode = CR95HF_RETURN_OK;
557 break;
558
559 case CR95HF_BridgeState_Finish:
560 CR95HFCtrl.commandState = 0;
561 CR95HFCtrl.command = CR95HF_COMMAND_NONE;
562 CR95HFCtrl.flags.all = 0;
563 break;
564
565 default: //ERROR
566 CR95HFCtrl.flags.all = 0;
567 CR95HFCtrl.rxPos = 0;
568 CR95HFCtrl.refMs = 0;
569 CR95HFCtrl.timeoutMs = 0;
570 CR95HFCtrl.completionTimeMs = 0;
571 CR95HFCtrl.command = CR95HF_COMMAND_NONE;
572 CR95HFCtrl.commandState = 0;
573 CR95HFCtrl.resultCode = CR95HF_RETURN_STATEMACHINE_ERROR;
574 break;
575 }
576 }
tCR95HFCtrl::completionTimeMs
unsigned short completionTimeMs
Definition: CR95HF.h:218
tCR95HFCtrl::bridgeCommand
char bridgeCommand[CR95HF_ANSWER_BUF_SIZE]
Definition: CR95HF.h:224
tCR95HFCtrl::refMs
unsigned long refMs
Definition: CR95HF.h:216
tCR95HFCtrl::all
unsigned short all
Definition: CR95HF.h:208
tCR95HFCtrl::flags
union tCR95HFCtrl::@17 flags
CR95HF_BridgeState_Send
Definition: CR95HF.h:168
CR95HFCtrl
tCR95HFCtrl CR95HFCtrl
Variable used by the state machine of the CR95HF.
Definition: CR95HF.c:67
CR95HF_BridgeState_WaitAnswer
Definition: CR95HF.h:169
CR95HF_RETURN_STATEMACHINE_ERROR
Definition: CR95HF.h:189
CR95HFWriteCommand
void CR95HFWriteCommand(char *command, unsigned short commandSize, char *answerExpected, unsigned short answerSize, unsigned short timeoutMs, unsigned short completionTimeMs, unsigned short waitForNbrRx)
Definition: CR95HF.c:76
tCR95HFCtrl::resultCode
unsigned long resultCode
Definition: CR95HF.h:221
tCR95HFCtrl::bridgeCommandLength
unsigned short bridgeCommandLength
Definition: CR95HF.h:225
CR95HF_COMMAND_NONE
Definition: CR95HF.h:72
CR95HF_BridgeState_Finish
Definition: CR95HF.h:170
tCR95HFCtrl::rxPos
unsigned short rxPos
Definition: CR95HF.h:212
tCR95HFCtrl::commandState
unsigned long commandState
Definition: CR95HF.h:220
CR95HF_RETURN_OK
Definition: CR95HF.h:182
CR95HF_BridgeState_Start
Definition: CR95HF.h:167
tCR95HFCtrl::command
tCR95HFCommand command
Definition: CR95HF.h:219
tCR95HFCtrl::timeoutMs
unsigned long timeoutMs
Definition: CR95HF.h:217

Here is the call graph for this function:

Here is the caller graph for this function:

signed short CR95HFBufCompare | ( | char * | dataBuf,
|  | unsigned short | dataBufSize,
|  | char * | dataBufRef,
|  | unsigned short | dataBufRefSize
| ) |  |

Definition at line 129 of file CR95HF.c.

Referenced by CR95HFManager().

129 {
130
131 unsigned short findId = 0;
132 unsigned short id = 0;
133 unsigned short eqId = 0xFFFF;
134
135 while( id < dataBufSize) {
136
137 if(findId < dataBufRefSize) {
138
139 if(*(dataBufRef+findId) == *(dataBuf+id)) {
140 findId++;
141 if(eqId == 0xFFFF){
142 eqId = id;
143 }
144 } else {
145 eqId = 0xFFFF;
146 findId = 0;
147 }
148 } else {
149 return eqId;
150 }
151 id++;
152 }
153 if(findId == dataBufRefSize) {
154 return eqId;
155 } else {
156 return -1;
157 }
158 }

Here is the caller graph for this function:

void CR95HFCommandManager | ( | void |  | ) |

Definition at line 161 of file CR95HF.c.

References tCR95HFCtrl::all, tCR95HFCtrl::command, tCR95HFCtrl::commandState, tCR95HFCtrl::completionTimeMs, CR95HF_COMMAND_BRIDGE, CR95HF_COMMAND_ECHO, CR95HF_COMMAND_FIELD15693, CR95HF_COMMAND_FIELDOFF, CR95HF_COMMAND_HIBERNATE, CR95HF_COMMAND_NONE, CR95HF_COMMAND_READ, CR95HF_COMMAND_WRITE, CR95HFBridgeStateMachine(), CR95HFEchoStateMachine(), CR95HFField15693StateMachine(), CR95HFFieldOffStateMachine(), CR95HFHibernateStateMachine(), CR95HFReadStateMachine(), CR95HFWriteStateMachine(), tCR95HFCtrl::flags, tCR95HFCtrl::refMs, tCR95HFCtrl::rxPos, and tCR95HFCtrl::timeoutMs.

Referenced by CR95HFManager().

161 {
162
163 switch(CR95HFCtrl.command) {
164
165 case CR95HF_COMMAND_NONE :
166 //Wait State -> Do nothing
167 break;
168
169 case CR95HF_COMMAND_ECHO :
170 CR95HFEchoStateMachine();
171 break;
172
173 case CR95HF_COMMAND_FIELDOFF :
174 CR95HFFieldOffStateMachine();
175 break;
176
177 case CR95HF_COMMAND_FIELD15693 :
178 CR95HFField15693StateMachine();
179 break;
180
181 case CR95HF_COMMAND_HIBERNATE :
182 CR95HFHibernateStateMachine();
183 break;
184
185 case CR95HF_COMMAND_READ :
186 CR95HFReadStateMachine();
187 break;
188
189 case CR95HF_COMMAND_WRITE :
190 CR95HFWriteStateMachine();
191 break;
192
193 case CR95HF_COMMAND_BRIDGE :
194 CR95HFBridgeStateMachine();
195 break;
196
197 default :
198 CR95HFCtrl.flags.all = 0;
199 CR95HFCtrl.rxPos = 0;
200 CR95HFCtrl.refMs = 0;
201 CR95HFCtrl.timeoutMs = 0;
202 CR95HFCtrl.completionTimeMs = 0;
203 CR95HFCtrl.command = CR95HF_COMMAND_NONE;
204 CR95HFCtrl.commandState = 0;
205 break;
206
207 }
208 }
tCR95HFCtrl::completionTimeMs
unsigned short completionTimeMs
Definition: CR95HF.h:218
CR95HFField15693StateMachine
void CR95HFField15693StateMachine(void)
Definition: CR95HF.c:311
CR95HFReadStateMachine
void CR95HFReadStateMachine(void)
Definition: CR95HF.c:416
CR95HFHibernateStateMachine
void CR95HFHibernateStateMachine(void)
Definition: CR95HF.c:360
tCR95HFCtrl::refMs
unsigned long refMs
Definition: CR95HF.h:216
tCR95HFCtrl::all
unsigned short all
Definition: CR95HF.h:208
CR95HF_COMMAND_WRITE
Definition: CR95HF.h:78
CR95HF_COMMAND_READ
Definition: CR95HF.h:77
tCR95HFCtrl::flags
union tCR95HFCtrl::@17 flags
CR95HFCtrl
tCR95HFCtrl CR95HFCtrl
Variable used by the state machine of the CR95HF.
Definition: CR95HF.c:67
CR95HF_COMMAND_FIELD15693
Definition: CR95HF.h:75
CR95HFBridgeStateMachine
void CR95HFBridgeStateMachine(void)
Definition: CR95HF.c:535
CR95HFFieldOffStateMachine
void CR95HFFieldOffStateMachine(void)
Definition: CR95HF.c:261
CR95HF_COMMAND_NONE
Definition: CR95HF.h:72
CR95HF_COMMAND_HIBERNATE
Definition: CR95HF.h:76
tCR95HFCtrl::rxPos
unsigned short rxPos
Definition: CR95HF.h:212
tCR95HFCtrl::commandState
unsigned long commandState
Definition: CR95HF.h:220
CR95HF_COMMAND_ECHO
Definition: CR95HF.h:73
tCR95HFCtrl::command
tCR95HFCommand command
Definition: CR95HF.h:219
CR95HFEchoStateMachine
void CR95HFEchoStateMachine(void)
Definition: CR95HF.c:210
CR95HF_COMMAND_BRIDGE
Definition: CR95HF.h:79
CR95HF_COMMAND_FIELDOFF
Definition: CR95HF.h:74
tCR95HFCtrl::timeoutMs
unsigned long timeoutMs
Definition: CR95HF.h:217
CR95HFWriteStateMachine
void CR95HFWriteStateMachine(void)
Definition: CR95HF.c:471

Here is the call graph for this function:

Here is the caller graph for this function:

void CR95HFEchoStateMachine | ( | void |  | ) |

Definition at line 210 of file CR95HF.c.

References tCR95HFCtrl::all, tCR95HFCtrl::bits, tCR95HFCtrl::command, tCR95HFCtrl::commandState, tCR95HFCtrl::completionTimeMs, CR95HF_COMMAND_NONE, CR95HF_ECHO_MAX_TRY, CR95HF_EchoState_Finish, CR95HF_EchoState_Send, CR95HF_EchoState_Start, CR95HF_EchoState_WaitAnswer, CR95HF_RETURN_ECHO_ERROR, CR95HF_RETURN_OK, CR95HF_RETURN_STATEMACHINE_ERROR, CR95HFWriteCommand(), tCR95HFCtrl::flags, tCR95HFCtrl::refMs, tCR95HFCtrl::resultCode, tCR95HFCtrl::rxPos, and tCR95HFCtrl::timeoutMs.

Referenced by CR95HFCommandManager().

210 {
211 static unsigned char tryCounter = 0;
212 char data[1];
213
214 switch(CR95HFCtrl.commandState) {
215
216 case CR95HF_EchoState_Start:
217 tryCounter = 0;
218 CR95HFCtrl.commandState = CR95HF_EchoState_Send;
219 // No break;
220
221 case CR95HF_EchoState_Send:
222 data[0] = 0x55;
223 CR95HFWriteCommand(data,1,data,1,50,0,0);
224 CR95HFCtrl.commandState = CR95HF_EchoState_WaitAnswer;
225 break;
226
227 case CR95HF_EchoState_WaitAnswer:
228 if(CR95HFCtrl.flags.bits.timeout) {
229 tryCounter++;
230 if(tryCounter < CR95HF_ECHO_MAX_TRY) {
231 CR95HFCtrl.commandState = CR95HF_EchoState_Send;
232 } else {
233 CR95HFCtrl.resultCode = CR95HF_RETURN_ECHO_ERROR;
234 CR95HFCtrl.commandState = CR95HF_EchoState_Finish;
235 }
236 } else { //Answer receive
237 CR95HFCtrl.resultCode = CR95HF_RETURN_OK;
238 CR95HFCtrl.commandState = CR95HF_EchoState_Finish;
239 }
240 break;
241
242 case CR95HF_EchoState_Finish:
243 CR95HFCtrl.commandState = 0;
244 CR95HFCtrl.command = CR95HF_COMMAND_NONE;
245 CR95HFCtrl.flags.all = 0;
246 break;
247
248 default: //ERROR
249 CR95HFCtrl.flags.all = 0;
250 CR95HFCtrl.rxPos = 0;
251 CR95HFCtrl.refMs = 0;
252 CR95HFCtrl.timeoutMs = 0;
253 CR95HFCtrl.completionTimeMs = 0;
254 CR95HFCtrl.command = CR95HF_COMMAND_NONE;
255 CR95HFCtrl.commandState = 0;
256 CR95HFCtrl.resultCode = CR95HF_RETURN_STATEMACHINE_ERROR;
257 break;
258 }
259 }
tCR95HFCtrl::completionTimeMs
unsigned short completionTimeMs
Definition: CR95HF.h:218
tCR95HFCtrl::refMs
unsigned long refMs
Definition: CR95HF.h:216
tCR95HFCtrl::all
unsigned short all
Definition: CR95HF.h:208
tCR95HFCtrl::flags
union tCR95HFCtrl::@17 flags
CR95HF_EchoState_Finish
Definition: CR95HF.h:92
CR95HFCtrl
tCR95HFCtrl CR95HFCtrl
Variable used by the state machine of the CR95HF.
Definition: CR95HF.c:67
CR95HF_RETURN_STATEMACHINE_ERROR
Definition: CR95HF.h:189
CR95HFWriteCommand
void CR95HFWriteCommand(char *command, unsigned short commandSize, char *answerExpected, unsigned short answerSize, unsigned short timeoutMs, unsigned short completionTimeMs, unsigned short waitForNbrRx)
Definition: CR95HF.c:76
tCR95HFCtrl::bits
struct tCR95HFCtrl::@17::@18 bits
tCR95HFCtrl::resultCode
unsigned long resultCode
Definition: CR95HF.h:221
CR95HF_EchoState_Send
Definition: CR95HF.h:90
CR95HF_COMMAND_NONE
Definition: CR95HF.h:72
CR95HF_ECHO_MAX_TRY
#define CR95HF_ECHO_MAX_TRY
Define the maximum number of echo sended to try to establish a communication with the CR95HF...
Definition: CR95HF.h:54
tCR95HFCtrl::rxPos
unsigned short rxPos
Definition: CR95HF.h:212
tCR95HFCtrl::commandState
unsigned long commandState
Definition: CR95HF.h:220
CR95HF_RETURN_OK
Definition: CR95HF.h:182
CR95HF_EchoState_Start
Definition: CR95HF.h:89
tCR95HFCtrl::command
tCR95HFCommand command
Definition: CR95HF.h:219
CR95HF_EchoState_WaitAnswer
Definition: CR95HF.h:91
CR95HF_RETURN_ECHO_ERROR
Definition: CR95HF.h:183
tCR95HFCtrl::timeoutMs
unsigned long timeoutMs
Definition: CR95HF.h:217

Here is the call graph for this function:

Here is the caller graph for this function:

void CR95HFField15693StateMachine | ( | void |  | ) |

Definition at line 311 of file CR95HF.c.

References tCR95HFCtrl::all, tCR95HFCtrl::bits, tCR95HFCtrl::command, tCR95HFCtrl::commandState, tCR95HFCtrl::completionTimeMs, CR95HF_COMMAND_NONE, CR95HF_Field15693State_Finish, CR95HF_Field15693State_Send, CR95HF_Field15693State_Start, CR95HF_Field15693State_WaitAnswer, CR95HF_RETURN_FIELD15693_ERROR, CR95HF_RETURN_OK, CR95HF_RETURN_STATEMACHINE_ERROR, CR95HFWriteCommand(), tCR95HFCtrl::flags, tCR95HFCtrl::refMs, tCR95HFCtrl::resultCode, tCR95HFCtrl::rxPos, and tCR95HFCtrl::timeoutMs.

Referenced by CR95HFCommandManager().

311 {
312 char data[4];
313 char dataResult[2];
314
315 switch(CR95HFCtrl.commandState) {
316
317 case CR95HF_Field15693State_Start:
318 CR95HFCtrl.commandState = CR95HF_Field15693State_Send;
319 // No break;
320
321 case CR95HF_Field15693State_Send:
322 data[0] = 0x02;
323 data[1] = 0x02;
324 data[2] = 0x01;
325 data[3] = 0x0D;
326 dataResult[0] = 0x00;
327 dataResult[1] = 0x00;
328 CR95HFWriteCommand(data,4,dataResult,2,500,0,0);
329 CR95HFCtrl.commandState = CR95HF_Field15693State_WaitAnswer;
330 break;
331
332 case CR95HF_Field15693State_WaitAnswer:
333 CR95HFCtrl.commandState = CR95HF_Field15693State_Finish;
334 if(CR95HFCtrl.flags.bits.timeout) {
335 CR95HFCtrl.resultCode = CR95HF_RETURN_FIELD15693_ERROR;
336 } else { //Answer receive
337 CR95HFCtrl.resultCode = CR95HF_RETURN_OK;
338 }
339 break;
340
341 case CR95HF_Field15693State_Finish:
342 CR95HFCtrl.commandState = 0;
343 CR95HFCtrl.command = CR95HF_COMMAND_NONE;
344 CR95HFCtrl.flags.all = 0;
345 break;
346
347 default: //ERROR
348 CR95HFCtrl.flags.all = 0;
349 CR95HFCtrl.rxPos = 0;
350 CR95HFCtrl.refMs = 0;
351 CR95HFCtrl.timeoutMs = 0;
352 CR95HFCtrl.completionTimeMs = 0;
353 CR95HFCtrl.command = CR95HF_COMMAND_NONE;
354 CR95HFCtrl.commandState = 0;
355 CR95HFCtrl.resultCode = CR95HF_RETURN_STATEMACHINE_ERROR;
356 break;
357 }
358 }
tCR95HFCtrl::completionTimeMs
unsigned short completionTimeMs
Definition: CR95HF.h:218
tCR95HFCtrl::refMs
unsigned long refMs
Definition: CR95HF.h:216
CR95HF_RETURN_FIELD15693_ERROR
Definition: CR95HF.h:185
tCR95HFCtrl::all
unsigned short all
Definition: CR95HF.h:208
tCR95HFCtrl::flags
union tCR95HFCtrl::@17 flags
CR95HFCtrl
tCR95HFCtrl CR95HFCtrl
Variable used by the state machine of the CR95HF.
Definition: CR95HF.c:67
CR95HF_Field15693State_Start
Definition: CR95HF.h:115
CR95HF_Field15693State_Send
Definition: CR95HF.h:116
CR95HF_RETURN_STATEMACHINE_ERROR
Definition: CR95HF.h:189
CR95HFWriteCommand
void CR95HFWriteCommand(char *command, unsigned short commandSize, char *answerExpected, unsigned short answerSize, unsigned short timeoutMs, unsigned short completionTimeMs, unsigned short waitForNbrRx)
Definition: CR95HF.c:76
tCR95HFCtrl::bits
struct tCR95HFCtrl::@17::@18 bits
tCR95HFCtrl::resultCode
unsigned long resultCode
Definition: CR95HF.h:221
CR95HF_Field15693State_WaitAnswer
Definition: CR95HF.h:117
CR95HF_COMMAND_NONE
Definition: CR95HF.h:72
tCR95HFCtrl::rxPos
unsigned short rxPos
Definition: CR95HF.h:212
tCR95HFCtrl::commandState
unsigned long commandState
Definition: CR95HF.h:220
CR95HF_RETURN_OK
Definition: CR95HF.h:182
CR95HF_Field15693State_Finish
Definition: CR95HF.h:118
tCR95HFCtrl::command
tCR95HFCommand command
Definition: CR95HF.h:219
tCR95HFCtrl::timeoutMs
unsigned long timeoutMs
Definition: CR95HF.h:217

Here is the call graph for this function:

Here is the caller graph for this function:

void CR95HFFieldOffStateMachine | ( | void |  | ) |

Definition at line 261 of file CR95HF.c.

References tCR95HFCtrl::all, tCR95HFCtrl::bits, tCR95HFCtrl::command, tCR95HFCtrl::commandState, tCR95HFCtrl::completionTimeMs, CR95HF_COMMAND_NONE, CR95HF_EchoState_Finish, CR95HF_FieldOffState_Finish, CR95HF_FieldOffState_Send, CR95HF_FieldOffState_Start, CR95HF_FieldOffState_WaitAnswer, CR95HF_RETURN_FIELDOFF_ERROR, CR95HF_RETURN_OK, CR95HF_RETURN_STATEMACHINE_ERROR, CR95HFWriteCommand(), tCR95HFCtrl::flags, tCR95HFCtrl::refMs, tCR95HFCtrl::resultCode, tCR95HFCtrl::rxPos, and tCR95HFCtrl::timeoutMs.

Referenced by CR95HFCommandManager().

261 {
262 char data[4];
263 char dataResult[2];
264
265 switch(CR95HFCtrl.commandState) {
266
267 case CR95HF_FieldOffState_Start:
268 CR95HFCtrl.commandState = CR95HF_FieldOffState_Send;
269 // No break;
270
271 case CR95HF_FieldOffState_Send:
272 data[0] = 0x02;
273 data[1] = 0x02;
274 data[2] = 0x00;
275 data[3] = 0x00;
276 dataResult[0] = 0x00;
277 dataResult[1] = 0x00;
278 CR95HFWriteCommand(data,4,dataResult,2,500,0,0);
279 CR95HFCtrl.commandState = CR95HF_FieldOffState_WaitAnswer;
280 break;
281
282 case CR95HF_FieldOffState_WaitAnswer:
283 CR95HFCtrl.commandState = CR95HF_EchoState_Finish;
284 if(CR95HFCtrl.flags.bits.timeout) {
285 CR95HFCtrl.resultCode = CR95HF_RETURN_FIELDOFF_ERROR;
286 } else { //Answer receive
287 CR95HFCtrl.resultCode = CR95HF_RETURN_OK;
288 }
289 break;
290
291 case CR95HF_FieldOffState_Finish:
292 CR95HFCtrl.commandState = 0;
293 CR95HFCtrl.command = CR95HF_COMMAND_NONE;
294 CR95HFCtrl.flags.all = 0;
295 break;
296
297 default: //ERROR
298 CR95HFCtrl.flags.all = 0;
299 CR95HFCtrl.rxPos = 0;
300 CR95HFCtrl.refMs = 0;
301 CR95HFCtrl.timeoutMs = 0;
302 CR95HFCtrl.completionTimeMs = 0;
303 CR95HFCtrl.command = CR95HF_COMMAND_NONE;
304 CR95HFCtrl.commandState = 0;
305 CR95HFCtrl.resultCode = CR95HF_RETURN_STATEMACHINE_ERROR;
306 break;
307 }
308 }
tCR95HFCtrl::completionTimeMs
unsigned short completionTimeMs
Definition: CR95HF.h:218
CR95HF_FieldOffState_Finish
Definition: CR95HF.h:105
CR95HF_FieldOffState_WaitAnswer
Definition: CR95HF.h:104
tCR95HFCtrl::refMs
unsigned long refMs
Definition: CR95HF.h:216
tCR95HFCtrl::all
unsigned short all
Definition: CR95HF.h:208
tCR95HFCtrl::flags
union tCR95HFCtrl::@17 flags
CR95HF_RETURN_FIELDOFF_ERROR
Definition: CR95HF.h:184
CR95HF_EchoState_Finish
Definition: CR95HF.h:92
CR95HFCtrl
tCR95HFCtrl CR95HFCtrl
Variable used by the state machine of the CR95HF.
Definition: CR95HF.c:67
CR95HF_RETURN_STATEMACHINE_ERROR
Definition: CR95HF.h:189
CR95HFWriteCommand
void CR95HFWriteCommand(char *command, unsigned short commandSize, char *answerExpected, unsigned short answerSize, unsigned short timeoutMs, unsigned short completionTimeMs, unsigned short waitForNbrRx)
Definition: CR95HF.c:76
tCR95HFCtrl::bits
struct tCR95HFCtrl::@17::@18 bits
tCR95HFCtrl::resultCode
unsigned long resultCode
Definition: CR95HF.h:221
CR95HF_COMMAND_NONE
Definition: CR95HF.h:72
tCR95HFCtrl::rxPos
unsigned short rxPos
Definition: CR95HF.h:212
tCR95HFCtrl::commandState
unsigned long commandState
Definition: CR95HF.h:220
CR95HF_RETURN_OK
Definition: CR95HF.h:182
CR95HF_FieldOffState_Send
Definition: CR95HF.h:103
tCR95HFCtrl::command
tCR95HFCommand command
Definition: CR95HF.h:219
tCR95HFCtrl::timeoutMs
unsigned long timeoutMs
Definition: CR95HF.h:217
CR95HF_FieldOffState_Start
Definition: CR95HF.h:102

Here is the call graph for this function:

Here is the caller graph for this function:

void CR95HFHibernateStateMachine | ( | void |  | ) |

Definition at line 360 of file CR95HF.c.

References tCR95HFCtrl::all, tCR95HFCtrl::command, tCR95HFCtrl::commandState, tCR95HFCtrl::completionTimeMs, CR95HF_COMMAND_NONE, CR95HF_HibernateState_Finish, CR95HF_HibernateState_Send, CR95HF_HibernateState_Start, CR95HF_HibernateState_WaitAnswer, CR95HF_RETURN_OK, CR95HF_RETURN_STATEMACHINE_ERROR, CR95HFWriteCommand(), CR95UartDisableReceiver(), tCR95HFCtrl::flags, tCR95HFCtrl::refMs, tCR95HFCtrl::resultCode, tCR95HFCtrl::rxPos, and tCR95HFCtrl::timeoutMs.

Referenced by CR95HFCommandManager().

360 {
361 char data[16];
362
363 switch(CR95HFCtrl.commandState) {
364
365 case CR95HF_HibernateState_Start:
366 CR95HFCtrl.commandState = CR95HF_HibernateState_Send;
367 // No break;
368
369 case CR95HF_HibernateState_Send:
370 data[0] = 0x07;
371 data[1] = 0x0E;
372 data[2] = 0x08;
373 data[3] = 0x04;
374 data[4] = 0x00;
375 data[5] = 0x04;
376 data[6] = 0x00;
377 data[7] = 0x18;
378 data[8] = 0x00;
379 data[9] = 0x00;
380 data[10] = 0x00;
381 data[11] = 0x00;
382 data[12] = 0x00;
383 data[13] = 0x00;
384 data[14] = 0x00;
385 data[15] = 0x00;
386 CR95HFWriteCommand(data,16,data,0,50,150,0); //End with timeout
387 CR95UartDisableReceiver(); //Disable Uart to rpevent loop interrupt
388 CR95HFCtrl.commandState = CR95HF_HibernateState_WaitAnswer;
389 break;
390
391 case CR95HF_HibernateState_WaitAnswer:
392 CR95HFCtrl.commandState = CR95HF_HibernateState_Finish;
393 CR95HFCtrl.resultCode = CR95HF_RETURN_OK;
394 break;
395
396 case CR95HF_HibernateState_Finish:
397 CR95HFCtrl.commandState = 0;
398 CR95HFCtrl.command = CR95HF_COMMAND_NONE;
399 CR95HFCtrl.flags.all = 0;
400 break;
401
402 default: //ERROR
403 CR95HFCtrl.flags.all = 0;
404 CR95HFCtrl.rxPos = 0;
405 CR95HFCtrl.refMs = 0;
406 CR95HFCtrl.timeoutMs = 0;
407 CR95HFCtrl.completionTimeMs = 0;
408 CR95HFCtrl.command = CR95HF_COMMAND_NONE;
409 CR95HFCtrl.commandState = 0;
410 CR95HFCtrl.resultCode = CR95HF_RETURN_STATEMACHINE_ERROR;
411 break;
412 }
413 }
tCR95HFCtrl::completionTimeMs
unsigned short completionTimeMs
Definition: CR95HF.h:218
tCR95HFCtrl::refMs
unsigned long refMs
Definition: CR95HF.h:216
tCR95HFCtrl::all
unsigned short all
Definition: CR95HF.h:208
CR95HF_HibernateState_Finish
Definition: CR95HF.h:131
tCR95HFCtrl::flags
union tCR95HFCtrl::@17 flags
CR95HF_HibernateState_Start
Definition: CR95HF.h:128
CR95HFCtrl
tCR95HFCtrl CR95HFCtrl
Variable used by the state machine of the CR95HF.
Definition: CR95HF.c:67
CR95HF_RETURN_STATEMACHINE_ERROR
Definition: CR95HF.h:189
CR95UartDisableReceiver
void CR95UartDisableReceiver(void)
Definition: CR95UartMapper.c:119
CR95HFWriteCommand
void CR95HFWriteCommand(char *command, unsigned short commandSize, char *answerExpected, unsigned short answerSize, unsigned short timeoutMs, unsigned short completionTimeMs, unsigned short waitForNbrRx)
Definition: CR95HF.c:76
tCR95HFCtrl::resultCode
unsigned long resultCode
Definition: CR95HF.h:221
CR95HF_COMMAND_NONE
Definition: CR95HF.h:72
CR95HF_HibernateState_Send
Definition: CR95HF.h:129
tCR95HFCtrl::rxPos
unsigned short rxPos
Definition: CR95HF.h:212
tCR95HFCtrl::commandState
unsigned long commandState
Definition: CR95HF.h:220
CR95HF_RETURN_OK
Definition: CR95HF.h:182
tCR95HFCtrl::command
tCR95HFCommand command
Definition: CR95HF.h:219
tCR95HFCtrl::timeoutMs
unsigned long timeoutMs
Definition: CR95HF.h:217
CR95HF_HibernateState_WaitAnswer
Definition: CR95HF.h:130

Here is the call graph for this function:

Here is the caller graph for this function:

void CR95HFInit | ( | void |  | ) |

Function used to initialize the CR95HF global manager.

Definition at line 585 of file CR95HF.c.

References tCR95HFCtrl::all, tCR95HFCtrl::command, tCR95HFCtrl::commandState, tCR95HFCtrl::completionTimeMs, CR95HF_COMMAND_NONE, CR95HF_UART_BAUDRATE, CR95UartInit(), tCR95HFCtrl::flags, tCR95HFCtrl::refMs, tCR95HFCtrl::rxPos, and tCR95HFCtrl::timeoutMs.

Referenced by RFIDManagerInit().

585 {
586 CR95UartInit(CR95HF_UART_BAUDRATE);
587
588 CR95HFCtrl.flags.all = 0;
589 CR95HFCtrl.rxPos = 0;
590 CR95HFCtrl.refMs = 0;
591 CR95HFCtrl.timeoutMs = 0;
592 CR95HFCtrl.completionTimeMs = 0;
593 CR95HFCtrl.command = CR95HF_COMMAND_NONE;
594 CR95HFCtrl.commandState = 0;
595 }
tCR95HFCtrl::completionTimeMs
unsigned short completionTimeMs
Definition: CR95HF.h:218
tCR95HFCtrl::refMs
unsigned long refMs
Definition: CR95HF.h:216
tCR95HFCtrl::all
unsigned short all
Definition: CR95HF.h:208
tCR95HFCtrl::flags
union tCR95HFCtrl::@17 flags
CR95HFCtrl
tCR95HFCtrl CR95HFCtrl
Variable used by the state machine of the CR95HF.
Definition: CR95HF.c:67
CR95HF_UART_BAUDRATE
#define CR95HF_UART_BAUDRATE
Define the baudrate of the interface used to communicate with the CR95HF.
Definition: CR95HF.h:36
CR95UartInit
void CR95UartInit(unsigned long baudrate)
CR95HF Uart interface.
Definition: CR95UartMapper.c:84
CR95HF_COMMAND_NONE
Definition: CR95HF.h:72
tCR95HFCtrl::rxPos
unsigned short rxPos
Definition: CR95HF.h:212
tCR95HFCtrl::commandState
unsigned long commandState
Definition: CR95HF.h:220
tCR95HFCtrl::command
tCR95HFCommand command
Definition: CR95HF.h:219
tCR95HFCtrl::timeoutMs
unsigned long timeoutMs
Definition: CR95HF.h:217

Here is the call graph for this function:

Here is the caller graph for this function:

void CR95HFManager | ( | void |  | ) |

Global manager of the CR95HF module.

Definition at line 598 of file CR95HF.c.

References tCR95HFCtrl::all, tCR95HFCtrl::answerKeyWord, tCR95HFCtrl::answerSize, tCR95HFCtrl::bits, tCR95HFCtrl::completionTimeMs, CR95HFBufCompare(), CR95HFCommandManager(), CR95HFReadAnswer(), tCR95HFCtrl::flags, tCR95HFCtrl::receiveBuf, tCR95HFCtrl::refMs, tCR95HFCtrl::rxPos, TickMilliSecElapsedFrom(), tCR95HFCtrl::timeoutMs, and tCR95HFCtrl::waitForNbrRx.

Referenced by RFIDManager().

598 {
599
600 unsigned long timeElapsed = 0;
601
602 if(CR95HFCtrl.flags.bits.isWorking) {
603 timeElapsed = TickMilliSecElapsedFrom(CR95HFCtrl.refMs);
604
605 if(timeElapsed > CR95HFCtrl.timeoutMs) {
606 CR95HFCtrl.flags.bits.timeout = 1;
607 }
608 }
609
610 if(CR95HFCtrl.flags.all == 0x0001) { //Only working flag
611
612 if(timeElapsed >= CR95HFCtrl.completionTimeMs) {
613
614 CR95HFReadAnswer();
615
616 if(CR95HFCtrl.waitForNbrRx == 0) {
617
618 if(CR95HFBufCompare(CR95HFCtrl.receiveBuf, CR95HFCtrl.rxPos, CR95HFCtrl.answerKeyWord, CR95HFCtrl.answerSize) != -1) {
619 CR95HFCtrl.flags.bits.anwserReceived = 1;
620 }
621 } else {
622
623 if((CR95HFCtrl.rxPos + 1) > CR95HFCtrl.waitForNbrRx) {
624 CR95HFCtrl.flags.bits.sizeReceive = 1;
625 }
626 }
627 }
628 } else {
629 CR95HFCommandManager();
630 }
631 }
CR95HFBufCompare
signed short CR95HFBufCompare(char *dataBuf, unsigned short dataBufSize, char *dataBufRef, unsigned short dataBufRefSize)
Definition: CR95HF.c:129
tCR95HFCtrl::completionTimeMs
unsigned short completionTimeMs
Definition: CR95HF.h:218
tCR95HFCtrl::waitForNbrRx
unsigned short waitForNbrRx
Definition: CR95HF.h:215
tCR95HFCtrl::refMs
unsigned long refMs
Definition: CR95HF.h:216
tCR95HFCtrl::all
unsigned short all
Definition: CR95HF.h:208
CR95HFReadAnswer
void CR95HFReadAnswer(void)
Definition: CR95HF.c:115
tCR95HFCtrl::flags
union tCR95HFCtrl::@17 flags
CR95HFCtrl
tCR95HFCtrl CR95HFCtrl
Variable used by the state machine of the CR95HF.
Definition: CR95HF.c:67
tCR95HFCtrl::answerSize
unsigned short answerSize
Definition: CR95HF.h:214
tCR95HFCtrl::receiveBuf
char receiveBuf[CR95HF_RX_BUF_SIZE]
Definition: CR95HF.h:211
tCR95HFCtrl::bits
struct tCR95HFCtrl::@17::@18 bits
tCR95HFCtrl::rxPos
unsigned short rxPos
Definition: CR95HF.h:212
tCR95HFCtrl::answerKeyWord
char answerKeyWord[CR95HF_ANSWER_BUF_SIZE]
Definition: CR95HF.h:213
TickMilliSecElapsedFrom
unsigned long TickMilliSecElapsedFrom(unsigned long refTimeMs)
Get the milliseconds counter.
Definition: tick.c:141
CR95HFCommandManager
void CR95HFCommandManager(void)
Definition: CR95HF.c:161
tCR95HFCtrl::timeoutMs
unsigned long timeoutMs
Definition: CR95HF.h:217

Here is the call graph for this function:

Here is the caller graph for this function:

tCR95HFIsReady CR95HFManagerIsReady | ( | void |  | ) |

Return the current state of the CR95HF module in it's manager.

Definition at line 718 of file CR95HF.c.

References tCR95HFCtrl::command, CR95HF_COMMAND_NONE, CR95HF_IS_BUSY, and CR95HF_IS_READY.

Referenced by RFIDBridgeStateMachine(), RFIDExtLpmStateMachine(), RFIDIntLpmStateMachine(), RFIDReadStateMachine(), and RFIDWriteStateMachine().

718 {
719 if(CR95HFCtrl.command == CR95HF_COMMAND_NONE) {
720 return CR95HF_IS_READY;
721 } else {
722 return CR95HF_IS_BUSY;
723 }
724 }
CR95HF_IS_BUSY
Definition: CR95HF.h:235
CR95HFCtrl
tCR95HFCtrl CR95HFCtrl
Variable used by the state machine of the CR95HF.
Definition: CR95HF.c:67
CR95HF_IS_READY
Definition: CR95HF.h:236
CR95HF_COMMAND_NONE
Definition: CR95HF.h:72
tCR95HFCtrl::command
tCR95HFCommand command
Definition: CR95HF.h:219

Here is the caller graph for this function:

void CR95HFReadAnswer | ( | void |  | ) |

Definition at line 115 of file CR95HF.c.

References CR95UartGetUartStructCtrl(), CR95UartReadChar(), tUartFifo::nbrChar, tCR95HFCtrl::receiveBuf, tUartCtrl::rx, and tCR95HFCtrl::rxPos.

Referenced by CR95HFManager().

115 {
116
117 char read;
118 tUartCtrl* CR95HFUartCtrl;
119
120 CR95HFUartCtrl = CR95UartGetUartStructCtrl();
121
122 while(CR95HFUartCtrl->rx.nbrChar != 0) {
123 read = CR95UartReadChar();
124 CR95HFCtrl.receiveBuf[CR95HFCtrl.rxPos++] = read;
125 }
126 }
tUartCtrl::rx
tUartFifo rx
Definition: uart_common.h:77
CR95HFCtrl
tCR95HFCtrl CR95HFCtrl
Variable used by the state machine of the CR95HF.
Definition: CR95HF.c:67
tCR95HFCtrl::receiveBuf
char receiveBuf[CR95HF_RX_BUF_SIZE]
Definition: CR95HF.h:211
CR95UartReadChar
char CR95UartReadChar(void)
Definition: CR95UartMapper.c:145
CR95UartGetUartStructCtrl
tUartCtrl * CR95UartGetUartStructCtrl(void)
Return the structure control of the CR95HF uart.
Definition: CR95UartMapper.c:166
tUartCtrl
Define the Uart control structure.
Definition: uart_common.h:76
tCR95HFCtrl::rxPos
unsigned short rxPos
Definition: CR95HF.h:212
tUartFifo::nbrChar
unsigned short nbrChar
Definition: uart_common.h:49

Here is the call graph for this function:

Here is the caller graph for this function:

void CR95HFReadStateMachine | ( | void |  | ) |

Definition at line 416 of file CR95HF.c.

References tCR95HFCtrl::all, tCR95HFCtrl::bits, tCR95HFCtrl::command, tCR95HFCtrl::commandState, tCR95HFCtrl::completionTimeMs, CR95HF_COMMAND_NONE, CR95HF_ReadState_Finish, CR95HF_ReadState_Send, CR95HF_ReadState_Start, CR95HF_ReadState_WaitAnswer, CR95HF_RETURN_OK, CR95HF_RETURN_READ_ERROR, CR95HF_RETURN_STATEMACHINE_ERROR, CR95HFWriteCommand(), tCR95HFCtrl::deviceReg, tCR95HFCtrl::deviceRegAddr, tCR95HFCtrl::flags, tCR95HFCtrl::receiveBuf, tCR95HFCtrl::refMs, tCR95HFCtrl::resultCode, tCR95HFCtrl::rxPos, and tCR95HFCtrl::timeoutMs.

Referenced by CR95HFCommandManager().

416 {
417 char data[6];
418
419 switch(CR95HFCtrl.commandState) {
420
421 case CR95HF_ReadState_Start:
422 CR95HFCtrl.commandState = CR95HF_ReadState_Send;
423 // No break;
424
425 case CR95HF_ReadState_Send:
426 data[0] = 0x04;
427 data[1] = 0x04;
428 data[2] = 0x0A;
429 data[3] = 0x20;
430 data[4] = (char)((CR95HFCtrl.deviceRegAddr >> 0) & 0xFF);
431 data[5] = (char)((CR95HFCtrl.deviceRegAddr >> 8) & 0xFF);
432
433 CR95HFWriteCommand(data,6,data,0,200,25,10); //End with nbr Rx
434
435 CR95HFCtrl.commandState = CR95HF_ReadState_WaitAnswer;
436 break;
437
438 case CR95HF_ReadState_WaitAnswer:
439 if(CR95HFCtrl.flags.bits.sizeReceive) {
440 CR95HFCtrl.deviceReg = ((((unsigned long)CR95HFCtrl.receiveBuf[3]) << 0) & 0x000000FF) |
441 ((((unsigned long)CR95HFCtrl.receiveBuf[4]) << 8) & 0x0000FF00) |
442 ((((unsigned long)CR95HFCtrl.receiveBuf[5]) << 16) & 0x00FF0000) |
443 ((((unsigned long)CR95HFCtrl.receiveBuf[6]) << 24) & 0xFF000000);
444 CR95HFCtrl.commandState = CR95HF_ReadState_Finish;
445 CR95HFCtrl.resultCode = CR95HF_RETURN_OK;
446 } else {
447 CR95HFCtrl.commandState = CR95HF_ReadState_Finish;
448 CR95HFCtrl.resultCode = CR95HF_RETURN_READ_ERROR;
449 }
450 break;
451
452 case CR95HF_ReadState_Finish:
453 CR95HFCtrl.commandState = 0;
454 CR95HFCtrl.command = CR95HF_COMMAND_NONE;
455 CR95HFCtrl.flags.all = 0;
456 break;
457
458 default: //ERROR
459 CR95HFCtrl.flags.all = 0;
460 CR95HFCtrl.rxPos = 0;
461 CR95HFCtrl.refMs = 0;
462 CR95HFCtrl.timeoutMs = 0;
463 CR95HFCtrl.completionTimeMs = 0;
464 CR95HFCtrl.command = CR95HF_COMMAND_NONE;
465 CR95HFCtrl.commandState = 0;
466 CR95HFCtrl.resultCode = CR95HF_RETURN_STATEMACHINE_ERROR;
467 break;
468 }
469 }
tCR95HFCtrl::completionTimeMs
unsigned short completionTimeMs
Definition: CR95HF.h:218
tCR95HFCtrl::refMs
unsigned long refMs
Definition: CR95HF.h:216
tCR95HFCtrl::deviceReg
unsigned long deviceReg
Definition: CR95HF.h:223
tCR95HFCtrl::deviceRegAddr
unsigned short deviceRegAddr
Definition: CR95HF.h:222
tCR95HFCtrl::all
unsigned short all
Definition: CR95HF.h:208
tCR95HFCtrl::flags
union tCR95HFCtrl::@17 flags
CR95HF_RETURN_READ_ERROR
Definition: CR95HF.h:187
CR95HFCtrl
tCR95HFCtrl CR95HFCtrl
Variable used by the state machine of the CR95HF.
Definition: CR95HF.c:67
CR95HF_ReadState_Finish
Definition: CR95HF.h:144
CR95HF_RETURN_STATEMACHINE_ERROR
Definition: CR95HF.h:189
CR95HF_ReadState_Start
Definition: CR95HF.h:141
CR95HF_ReadState_WaitAnswer
Definition: CR95HF.h:143
tCR95HFCtrl::receiveBuf
char receiveBuf[CR95HF_RX_BUF_SIZE]
Definition: CR95HF.h:211
CR95HFWriteCommand
void CR95HFWriteCommand(char *command, unsigned short commandSize, char *answerExpected, unsigned short answerSize, unsigned short timeoutMs, unsigned short completionTimeMs, unsigned short waitForNbrRx)
Definition: CR95HF.c:76
tCR95HFCtrl::bits
struct tCR95HFCtrl::@17::@18 bits
tCR95HFCtrl::resultCode
unsigned long resultCode
Definition: CR95HF.h:221
CR95HF_COMMAND_NONE
Definition: CR95HF.h:72
CR95HF_ReadState_Send
Definition: CR95HF.h:142
tCR95HFCtrl::rxPos
unsigned short rxPos
Definition: CR95HF.h:212
tCR95HFCtrl::commandState
unsigned long commandState
Definition: CR95HF.h:220
CR95HF_RETURN_OK
Definition: CR95HF.h:182
tCR95HFCtrl::command
tCR95HFCommand command
Definition: CR95HF.h:219
tCR95HFCtrl::timeoutMs
unsigned long timeoutMs
Definition: CR95HF.h:217

Here is the call graph for this function:

Here is the caller graph for this function:

void CR95HFStartBridge | ( | char * | data,
|  | unsigned short | dataLength
| ) |  |

Definition at line 699 of file CR95HF.c.

References tCR95HFCtrl::all, tCR95HFCtrl::bridgeCommand, tCR95HFCtrl::bridgeCommandLength, tCR95HFCtrl::command, tCR95HFCtrl::commandState, CR95HF_BridgeState_Start, CR95HF_COMMAND_BRIDGE, CR95HF_COMMAND_NONE, CR95HF_RETURN_WORKING, tCR95HFCtrl::flags, and tCR95HFCtrl::resultCode.

Referenced by RFIDBridgeStateMachine().

699 {
700
701 if(CR95HFCtrl.command == CR95HF_COMMAND_NONE) {
702
703 unsigned char i;
704
705 for(i=0 ; i<dataLength ; i++) {
706 CR95HFCtrl.bridgeCommand[i] = *(data+i);
707 }
708
709 CR95HFCtrl.bridgeCommandLength = dataLength;
710
711 CR95HFCtrl.resultCode = CR95HF_RETURN_WORKING;
712 CR95HFCtrl.command = CR95HF_COMMAND_BRIDGE;
713 CR95HFCtrl.commandState = CR95HF_BridgeState_Start;
714 CR95HFCtrl.flags.all = 0;
715 }
716 }
tCR95HFCtrl::bridgeCommand
char bridgeCommand[CR95HF_ANSWER_BUF_SIZE]
Definition: CR95HF.h:224
tCR95HFCtrl::all
unsigned short all
Definition: CR95HF.h:208
tCR95HFCtrl::flags
union tCR95HFCtrl::@17 flags
CR95HFCtrl
tCR95HFCtrl CR95HFCtrl
Variable used by the state machine of the CR95HF.
Definition: CR95HF.c:67
CR95HF_RETURN_WORKING
Definition: CR95HF.h:181
tCR95HFCtrl::resultCode
unsigned long resultCode
Definition: CR95HF.h:221
tCR95HFCtrl::bridgeCommandLength
unsigned short bridgeCommandLength
Definition: CR95HF.h:225
CR95HF_COMMAND_NONE
Definition: CR95HF.h:72
tCR95HFCtrl::commandState
unsigned long commandState
Definition: CR95HF.h:220
CR95HF_BridgeState_Start
Definition: CR95HF.h:167
tCR95HFCtrl::command
tCR95HFCommand command
Definition: CR95HF.h:219
CR95HF_COMMAND_BRIDGE
Definition: CR95HF.h:79

Here is the caller graph for this function:

void CR95HFStartEcho | ( | void |  | ) |

Manager used to deal each specific state.

Definition at line 635 of file CR95HF.c.

References tCR95HFCtrl::all, tCR95HFCtrl::command, tCR95HFCtrl::commandState, CR95HF_COMMAND_ECHO, CR95HF_COMMAND_NONE, CR95HF_EchoState_Start, CR95HF_RETURN_WORKING, tCR95HFCtrl::flags, and tCR95HFCtrl::resultCode.

Referenced by RFIDBridgeStateMachine(), RFIDExtLpmStateMachine(), RFIDIntLpmStateMachine(), RFIDReadStateMachine(), and RFIDWriteStateMachine().

635 {
636
637 if(CR95HFCtrl.command == CR95HF_COMMAND_NONE) {
638 CR95HFCtrl.resultCode = CR95HF_RETURN_WORKING;
639 CR95HFCtrl.command = CR95HF_COMMAND_ECHO;
640 CR95HFCtrl.commandState = CR95HF_EchoState_Start;
641 CR95HFCtrl.flags.all = 0;
642 }
643 }
tCR95HFCtrl::all
unsigned short all
Definition: CR95HF.h:208
tCR95HFCtrl::flags
union tCR95HFCtrl::@17 flags
CR95HFCtrl
tCR95HFCtrl CR95HFCtrl
Variable used by the state machine of the CR95HF.
Definition: CR95HF.c:67
CR95HF_RETURN_WORKING
Definition: CR95HF.h:181
tCR95HFCtrl::resultCode
unsigned long resultCode
Definition: CR95HF.h:221
CR95HF_COMMAND_NONE
Definition: CR95HF.h:72
tCR95HFCtrl::commandState
unsigned long commandState
Definition: CR95HF.h:220
CR95HF_COMMAND_ECHO
Definition: CR95HF.h:73
CR95HF_EchoState_Start
Definition: CR95HF.h:89
tCR95HFCtrl::command
tCR95HFCommand command
Definition: CR95HF.h:219

Here is the caller graph for this function:

void CR95HFStartField15693 | ( | void |  | ) |

Definition at line 655 of file CR95HF.c.

References tCR95HFCtrl::all, tCR95HFCtrl::command, tCR95HFCtrl::commandState, CR95HF_COMMAND_FIELD15693, CR95HF_COMMAND_NONE, CR95HF_Field15693State_Start, CR95HF_RETURN_WORKING, tCR95HFCtrl::flags, and tCR95HFCtrl::resultCode.

Referenced by RFIDBridgeStateMachine(), RFIDReadStateMachine(), and RFIDWriteStateMachine().

655 {
656
657 if(CR95HFCtrl.command == CR95HF_COMMAND_NONE) {
658 CR95HFCtrl.resultCode = CR95HF_RETURN_WORKING;
659 CR95HFCtrl.command = CR95HF_COMMAND_FIELD15693;
660 CR95HFCtrl.commandState = CR95HF_Field15693State_Start;
661 CR95HFCtrl.flags.all = 0;
662 }
663 }
tCR95HFCtrl::all
unsigned short all
Definition: CR95HF.h:208
tCR95HFCtrl::flags
union tCR95HFCtrl::@17 flags
CR95HFCtrl
tCR95HFCtrl CR95HFCtrl
Variable used by the state machine of the CR95HF.
Definition: CR95HF.c:67
CR95HF_Field15693State_Start
Definition: CR95HF.h:115
CR95HF_RETURN_WORKING
Definition: CR95HF.h:181
CR95HF_COMMAND_FIELD15693
Definition: CR95HF.h:75
tCR95HFCtrl::resultCode
unsigned long resultCode
Definition: CR95HF.h:221
CR95HF_COMMAND_NONE
Definition: CR95HF.h:72
tCR95HFCtrl::commandState
unsigned long commandState
Definition: CR95HF.h:220
tCR95HFCtrl::command
tCR95HFCommand command
Definition: CR95HF.h:219

Here is the caller graph for this function:

void CR95HFStartFieldOff | ( | void |  | ) |

Definition at line 645 of file CR95HF.c.

References tCR95HFCtrl::all, tCR95HFCtrl::command, tCR95HFCtrl::commandState, CR95HF_COMMAND_FIELDOFF, CR95HF_COMMAND_NONE, CR95HF_FieldOffState_Start, CR95HF_RETURN_WORKING, tCR95HFCtrl::flags, and tCR95HFCtrl::resultCode.

Referenced by RFIDExtLpmStateMachine(), and RFIDIntLpmStateMachine().

645 {
646
647 if(CR95HFCtrl.command == CR95HF_COMMAND_NONE) {
648 CR95HFCtrl.resultCode = CR95HF_RETURN_WORKING;
649 CR95HFCtrl.command = CR95HF_COMMAND_FIELDOFF;
650 CR95HFCtrl.commandState = CR95HF_FieldOffState_Start;
651 CR95HFCtrl.flags.all = 0;
652 }
653 }
tCR95HFCtrl::all
unsigned short all
Definition: CR95HF.h:208
tCR95HFCtrl::flags
union tCR95HFCtrl::@17 flags
CR95HFCtrl
tCR95HFCtrl CR95HFCtrl
Variable used by the state machine of the CR95HF.
Definition: CR95HF.c:67
CR95HF_RETURN_WORKING
Definition: CR95HF.h:181
tCR95HFCtrl::resultCode
unsigned long resultCode
Definition: CR95HF.h:221
CR95HF_COMMAND_NONE
Definition: CR95HF.h:72
tCR95HFCtrl::commandState
unsigned long commandState
Definition: CR95HF.h:220
tCR95HFCtrl::command
tCR95HFCommand command
Definition: CR95HF.h:219
CR95HF_COMMAND_FIELDOFF
Definition: CR95HF.h:74
CR95HF_FieldOffState_Start
Definition: CR95HF.h:102

Here is the caller graph for this function:

void CR95HFStartHibernate | ( | void |  | ) |

Definition at line 666 of file CR95HF.c.

References tCR95HFCtrl::all, tCR95HFCtrl::command, tCR95HFCtrl::commandState, CR95HF_COMMAND_HIBERNATE, CR95HF_COMMAND_NONE, CR95HF_HibernateState_Start, CR95HF_RETURN_WORKING, tCR95HFCtrl::flags, and tCR95HFCtrl::resultCode.

Referenced by RFIDExtLpmStateMachine(), and RFIDIntLpmStateMachine().

666 {
667
668 if(CR95HFCtrl.command == CR95HF_COMMAND_NONE) {
669 CR95HFCtrl.resultCode = CR95HF_RETURN_WORKING;
670 CR95HFCtrl.command = CR95HF_COMMAND_HIBERNATE;
671 CR95HFCtrl.commandState = CR95HF_HibernateState_Start;
672 CR95HFCtrl.flags.all = 0;
673 }
674 }
tCR95HFCtrl::all
unsigned short all
Definition: CR95HF.h:208
tCR95HFCtrl::flags
union tCR95HFCtrl::@17 flags
CR95HF_HibernateState_Start
Definition: CR95HF.h:128
CR95HFCtrl
tCR95HFCtrl CR95HFCtrl
Variable used by the state machine of the CR95HF.
Definition: CR95HF.c:67
CR95HF_RETURN_WORKING
Definition: CR95HF.h:181
tCR95HFCtrl::resultCode
unsigned long resultCode
Definition: CR95HF.h:221
CR95HF_COMMAND_NONE
Definition: CR95HF.h:72
CR95HF_COMMAND_HIBERNATE
Definition: CR95HF.h:76
tCR95HFCtrl::commandState
unsigned long commandState
Definition: CR95HF.h:220
tCR95HFCtrl::command
tCR95HFCommand command
Definition: CR95HF.h:219

Here is the caller graph for this function:

void CR95HFStartRead | ( | unsigned short | addr | ) |

Definition at line 676 of file CR95HF.c.

References tCR95HFCtrl::all, tCR95HFCtrl::command, tCR95HFCtrl::commandState, CR95HF_COMMAND_NONE, CR95HF_COMMAND_READ, CR95HF_ReadState_Start, CR95HF_RETURN_WORKING, tCR95HFCtrl::deviceRegAddr, tCR95HFCtrl::flags, and tCR95HFCtrl::resultCode.

Referenced by RFIDReadStateMachine(), and RFIDWriteStateMachine().

676 {
677
678 if(CR95HFCtrl.command == CR95HF_COMMAND_NONE) {
679 CR95HFCtrl.deviceRegAddr = addr;
680 CR95HFCtrl.resultCode = CR95HF_RETURN_WORKING;
681 CR95HFCtrl.command = CR95HF_COMMAND_READ;
682 CR95HFCtrl.commandState = CR95HF_ReadState_Start;
683 CR95HFCtrl.flags.all = 0;
684 }
685 }
tCR95HFCtrl::deviceRegAddr
unsigned short deviceRegAddr
Definition: CR95HF.h:222
tCR95HFCtrl::all
unsigned short all
Definition: CR95HF.h:208
CR95HF_COMMAND_READ
Definition: CR95HF.h:77
tCR95HFCtrl::flags
union tCR95HFCtrl::@17 flags
CR95HFCtrl
tCR95HFCtrl CR95HFCtrl
Variable used by the state machine of the CR95HF.
Definition: CR95HF.c:67
CR95HF_RETURN_WORKING
Definition: CR95HF.h:181
CR95HF_ReadState_Start
Definition: CR95HF.h:141
tCR95HFCtrl::resultCode
unsigned long resultCode
Definition: CR95HF.h:221
CR95HF_COMMAND_NONE
Definition: CR95HF.h:72
tCR95HFCtrl::commandState
unsigned long commandState
Definition: CR95HF.h:220
tCR95HFCtrl::command
tCR95HFCommand command
Definition: CR95HF.h:219

Here is the caller graph for this function:

void CR95HFStartWrite | ( | unsigned short | addr,
|  | unsigned long | data
| ) |  |

Definition at line 687 of file CR95HF.c.

References tCR95HFCtrl::all, tCR95HFCtrl::command, tCR95HFCtrl::commandState, CR95HF_COMMAND_NONE, CR95HF_COMMAND_WRITE, CR95HF_RETURN_WORKING, CR95HF_WriteState_Start, tCR95HFCtrl::deviceReg, tCR95HFCtrl::deviceRegAddr, tCR95HFCtrl::flags, and tCR95HFCtrl::resultCode.

Referenced by RFIDWriteStateMachine().

687 {
688
689 if(CR95HFCtrl.command == CR95HF_COMMAND_NONE) {
690 CR95HFCtrl.deviceRegAddr = addr;
691 CR95HFCtrl.deviceReg = data;
692 CR95HFCtrl.resultCode = CR95HF_RETURN_WORKING;
693 CR95HFCtrl.command = CR95HF_COMMAND_WRITE;
694 CR95HFCtrl.commandState = CR95HF_WriteState_Start;
695 CR95HFCtrl.flags.all = 0;
696 }
697 }
tCR95HFCtrl::deviceReg
unsigned long deviceReg
Definition: CR95HF.h:223
tCR95HFCtrl::deviceRegAddr
unsigned short deviceRegAddr
Definition: CR95HF.h:222
tCR95HFCtrl::all
unsigned short all
Definition: CR95HF.h:208
CR95HF_COMMAND_WRITE
Definition: CR95HF.h:78
CR95HF_WriteState_Start
Definition: CR95HF.h:154
tCR95HFCtrl::flags
union tCR95HFCtrl::@17 flags
CR95HFCtrl
tCR95HFCtrl CR95HFCtrl
Variable used by the state machine of the CR95HF.
Definition: CR95HF.c:67
CR95HF_RETURN_WORKING
Definition: CR95HF.h:181
tCR95HFCtrl::resultCode
unsigned long resultCode
Definition: CR95HF.h:221
CR95HF_COMMAND_NONE
Definition: CR95HF.h:72
tCR95HFCtrl::commandState
unsigned long commandState
Definition: CR95HF.h:220
tCR95HFCtrl::command
tCR95HFCommand command
Definition: CR95HF.h:219

Here is the caller graph for this function:

void CR95HFWriteCommand | ( | char * | command,
|  | unsigned short | commandSize,
|  | char * | answerExpected,
|  | unsigned short | answerSize,
|  | unsigned short | timeoutMs,
|  | unsigned short | completionTimeMs,
|  | unsigned short | waitForNbrRx
| ) |  |

Definition at line 76 of file CR95HF.c.

References tCR95HFCtrl::answerKeyWord, tCR95HFCtrl::answerSize, tCR95HFCtrl::bits, tCR95HFCtrl::completionTimeMs, CR95HF_RX_BUF_SIZE, CR95UartDisableReceiver(), CR95UartEnableReceiver(), CR95UartResetReceiver(), CR95UartSendData(), tCR95HFCtrl::flags, tCR95HFCtrl::receiveBuf, tCR95HFCtrl::refMs, tCR95HFCtrl::rxPos, StrTool_ClearString(), TickGetMsCounter(), tCR95HFCtrl::timeoutMs, and tCR95HFCtrl::waitForNbrRx.

Referenced by CR95HFBridgeStateMachine(), CR95HFEchoStateMachine(), CR95HFField15693StateMachine(), CR95HFFieldOffStateMachine(), CR95HFHibernateStateMachine(), CR95HFReadStateMachine(), and CR95HFWriteStateMachine().

76 {
77
78 /*=== Copy answer expected into working buffer ===*/
79 unsigned short i;
80 for(i=0 ; i<answerSize ; i++) {
81 CR95HFCtrl.answerKeyWord[i] = *(answerExpected+i);
82 }
83 CR95HFCtrl.answerSize = answerSize;
84
85 /*=== set completion time ===*/
86 CR95HFCtrl.completionTimeMs = completionTimeMs;
87
88 /*=== Set timeout ===*/
89 CR95HFCtrl.timeoutMs = timeoutMs;
90
91
92 /*=== Clear Rx receiver ===*/
93 CR95UartDisableReceiver();
94 CR95UartResetReceiver();
95 StrTool_ClearString(CR95HFCtrl.receiveBuf, CR95HF_RX_BUF_SIZE);
96 CR95HFCtrl.rxPos = 0;
97
98 /*=== Set nbr Rx Byte ===*/
99 CR95HFCtrl.waitForNbrRx = waitForNbrRx;
100
101 /*=== Get time (ms) ref ===*/
102 CR95HFCtrl.refMs = TickGetMsCounter();
103
104 /*=== Set Working flag ===*/
105 CR95HFCtrl.flags.bits.isWorking =1;
106 CR95HFCtrl.flags.bits.timeout = 0;
107 CR95HFCtrl.flags.bits.anwserReceived = 0;
108 CR95HFCtrl.flags.bits.sizeReceive = 0;
109
110 CR95UartEnableReceiver();
111
112 CR95UartSendData(command, commandSize);
113 }
tCR95HFCtrl::completionTimeMs
unsigned short completionTimeMs
Definition: CR95HF.h:218
tCR95HFCtrl::waitForNbrRx
unsigned short waitForNbrRx
Definition: CR95HF.h:215
tCR95HFCtrl::refMs
unsigned long refMs
Definition: CR95HF.h:216
tCR95HFCtrl::flags
union tCR95HFCtrl::@17 flags
CR95HFCtrl
tCR95HFCtrl CR95HFCtrl
Variable used by the state machine of the CR95HF.
Definition: CR95HF.c:67
tCR95HFCtrl::answerSize
unsigned short answerSize
Definition: CR95HF.h:214
CR95UartDisableReceiver
void CR95UartDisableReceiver(void)
Definition: CR95UartMapper.c:119
CR95UartEnableReceiver
void CR95UartEnableReceiver(void)
Definition: CR95UartMapper.c:111
TickGetMsCounter
unsigned long TickGetMsCounter(void)
Get the milliseconds counter.
Definition: tick.c:137
CR95UartSendData
void CR95UartSendData(char *data, unsigned short dataLength)
Definition: CR95UartMapper.c:129
tCR95HFCtrl::receiveBuf
char receiveBuf[CR95HF_RX_BUF_SIZE]
Definition: CR95HF.h:211
tCR95HFCtrl::bits
struct tCR95HFCtrl::@17::@18 bits
StrTool_ClearString
void StrTool_ClearString(char *str, unsigned short strLength)
Clear a string (reset all char to '\0').
Definition: StringTools.c:66
CR95HF_RX_BUF_SIZE
#define CR95HF_RX_BUF_SIZE
Define the buffer size.
Definition: CR95HF.h:44
tCR95HFCtrl::rxPos
unsigned short rxPos
Definition: CR95HF.h:212
tCR95HFCtrl::answerKeyWord
char answerKeyWord[CR95HF_ANSWER_BUF_SIZE]
Definition: CR95HF.h:213
CR95UartResetReceiver
void CR95UartResetReceiver(void)
Reset the CR95HF Uart interface.
Definition: CR95UartMapper.c:153
tCR95HFCtrl::timeoutMs
unsigned long timeoutMs
Definition: CR95HF.h:217

Here is the call graph for this function:

Here is the caller graph for this function:

void CR95HFWriteStateMachine | ( | void |  | ) |

Definition at line 471 of file CR95HF.c.

References tCR95HFCtrl::all, tCR95HFCtrl::bits, tCR95HFCtrl::command, tCR95HFCtrl::commandState, tCR95HFCtrl::completionTimeMs, CR95HF_COMMAND_NONE, CR95HF_RETURN_OK, CR95HF_RETURN_STATEMACHINE_ERROR, CR95HF_RETURN_WRITE_ERROR, CR95HF_WriteState_Finish, CR95HF_WriteState_Send, CR95HF_WriteState_Start, CR95HF_WriteState_WaitAnswer, CR95HFWriteCommand(), tCR95HFCtrl::deviceReg, tCR95HFCtrl::deviceRegAddr, tCR95HFCtrl::flags, tCR95HFCtrl::refMs, tCR95HFCtrl::resultCode, tCR95HFCtrl::rxPos, and tCR95HFCtrl::timeoutMs.

Referenced by CR95HFCommandManager().

471 {
472 char data[10];
473 char dataResult[6];
474
475 switch(CR95HFCtrl.commandState) {
476
477 case CR95HF_WriteState_Start:
478 CR95HFCtrl.commandState = CR95HF_WriteState_Send;
479 // No break;
480
481 case CR95HF_WriteState_Send:
482 data[0] = 0x04;
483 data[1] = 0x08;
484 data[2] = 0x0A;
485 data[3] = 0x21;
486 data[4] = (char)((CR95HFCtrl.deviceRegAddr >> 0) & 0xFF);
487 data[5] = (char)((CR95HFCtrl.deviceRegAddr >> 8) & 0xFF);
488 data[6] = (char)((CR95HFCtrl.deviceReg >> 0) & 0xFF);
489 data[7] = (char)((CR95HFCtrl.deviceReg >> 8) & 0xFF);
490 data[8] = (char)((CR95HFCtrl.deviceReg >> 16) & 0xFF);
491 data[9] = (char)((CR95HFCtrl.deviceReg >> 24) & 0xFF);
492
493 dataResult[0] = 0x80;
494 dataResult[1] = 0x04;
495 dataResult[2] = 0x00;
496 dataResult[3] = 0x78;
497 dataResult[4] = 0xF0;
498 dataResult[5] = 0x00;
499
500 CR95HFWriteCommand(data,10,dataResult,6,200,25,0); //End with nbr Rx
501
502 CR95HFCtrl.commandState = CR95HF_WriteState_WaitAnswer;
503 break;
504
505 case CR95HF_WriteState_WaitAnswer:
506 if(CR95HFCtrl.flags.bits.timeout) {
507 CR95HFCtrl.commandState = CR95HF_WriteState_Finish;
508 CR95HFCtrl.resultCode = CR95HF_RETURN_WRITE_ERROR;
509 } else {
510 CR95HFCtrl.commandState = CR95HF_WriteState_Finish;
511 CR95HFCtrl.resultCode = CR95HF_RETURN_OK;
512 }
513 break;
514
515 case CR95HF_WriteState_Finish:
516 CR95HFCtrl.commandState = 0;
517 CR95HFCtrl.command = CR95HF_COMMAND_NONE;
518 CR95HFCtrl.flags.all = 0;
519 break;
520
521 default: //ERROR
522 CR95HFCtrl.flags.all = 0;
523 CR95HFCtrl.rxPos = 0;
524 CR95HFCtrl.refMs = 0;
525 CR95HFCtrl.timeoutMs = 0;
526 CR95HFCtrl.completionTimeMs = 0;
527 CR95HFCtrl.command = CR95HF_COMMAND_NONE;
528 CR95HFCtrl.commandState = 0;
529 CR95HFCtrl.resultCode = CR95HF_RETURN_STATEMACHINE_ERROR;
530 break;
531 }
532 }
tCR95HFCtrl::completionTimeMs
unsigned short completionTimeMs
Definition: CR95HF.h:218
CR95HF_WriteState_WaitAnswer
Definition: CR95HF.h:156
CR95HF_RETURN_WRITE_ERROR
Definition: CR95HF.h:188
tCR95HFCtrl::refMs
unsigned long refMs
Definition: CR95HF.h:216
tCR95HFCtrl::deviceReg
unsigned long deviceReg
Definition: CR95HF.h:223
tCR95HFCtrl::deviceRegAddr
unsigned short deviceRegAddr
Definition: CR95HF.h:222
tCR95HFCtrl::all
unsigned short all
Definition: CR95HF.h:208
CR95HF_WriteState_Start
Definition: CR95HF.h:154
tCR95HFCtrl::flags
union tCR95HFCtrl::@17 flags
CR95HFCtrl
tCR95HFCtrl CR95HFCtrl
Variable used by the state machine of the CR95HF.
Definition: CR95HF.c:67
CR95HF_RETURN_STATEMACHINE_ERROR
Definition: CR95HF.h:189
CR95HFWriteCommand
void CR95HFWriteCommand(char *command, unsigned short commandSize, char *answerExpected, unsigned short answerSize, unsigned short timeoutMs, unsigned short completionTimeMs, unsigned short waitForNbrRx)
Definition: CR95HF.c:76
tCR95HFCtrl::bits
struct tCR95HFCtrl::@17::@18 bits
tCR95HFCtrl::resultCode
unsigned long resultCode
Definition: CR95HF.h:221
CR95HF_COMMAND_NONE
Definition: CR95HF.h:72
CR95HF_WriteState_Send
Definition: CR95HF.h:155
tCR95HFCtrl::rxPos
unsigned short rxPos
Definition: CR95HF.h:212
tCR95HFCtrl::commandState
unsigned long commandState
Definition: CR95HF.h:220
CR95HF_RETURN_OK
Definition: CR95HF.h:182
tCR95HFCtrl::command
tCR95HFCommand command
Definition: CR95HF.h:219
CR95HF_WriteState_Finish
Definition: CR95HF.h:157
tCR95HFCtrl::timeoutMs
unsigned long timeoutMs
Definition: CR95HF.h:217

Here is the call graph for this function:

Here is the caller graph for this function:

## Variable Documentation

CR95HFCtrl

Variable used by the state machine of the CR95HF.

Definition at line 67 of file CR95HF.c.

Referenced by RFIDBridgeStateMachine(), RFIDExtLpmStateMachine(), RFIDIntLpmStateMachine(), RFIDReadStateMachine(), and RFIDWriteStateMachine().