SRD Standelone programmation box: RFIDManager.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
Functions | Variables
RFIDManager.c File Reference

Source file for RFID management. More...

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

Go to the source code of this file.

## Functions

void | RFIDDealer (void)
void | RFIDIntLpmStateMachine (void)
void | RFIDExtLpmStateMachine (void)
void | RFIDBridgeStateMachine (void)
void | RFIDReadStateMachine (void)
void | RFIDWriteStateMachine (void)
void | RFIDManagerInit (void)
| Function used to initialize the RFID manager. More...
void | RFIDManager (void)
| RFID manager. More...
signed short | RFIDManagerSendBridgeCommand (char *command, unsigned short commandSize)
| function used to send a bridge command. More...

## Variables

tRFIDPowerMode | RFIDInternalPowerMode = RFID_POWERED
tRFIDPowerMode | RFIDExternalPowerMode = RFID_POWERED
tRFIDCtrl | RFIDCtrl
| Variable used to control the RFID manager. More...
tSRDEeprom | SRDEeprom

## Detailed Description

Source file for RFID management.

Author
  Thibaut LALUQUE 3D-Ouest

Date
  25/11/2014

Version
  1.0

All Right Reserved.

Definition in file RFIDManager.c.

## Function Documentation

void RFIDBridgeStateMachine | ( | void |  | ) |

Definition at line 335 of file RFIDManager.c.

References tRFIDCtrl::bits, tRFIDCtrl::bridgeCommand, tRFIDCtrl::bridgeCommandLength, CR95_EXT_CONNECTED, CR95_SELECT_EXTERNAL, CR95_SELECT_INTERNAL, CR95ExtGetConnectionState(), CR95HF_IS_READY, CR95HF_RETURN_ECHO_ERROR, CR95HF_RETURN_FIELD15693_ERROR, CR95HF_RETURN_OK, CR95HFCtrl, CR95HFManagerIsReady(), CR95HFStartBridge(), CR95HFStartEcho(), CR95HFStartField15693(), CR95SelectDevice(), CR95UartDisableReceiver(), CR95UartSendData(), tRFIDCtrl::msRef, tCR95HFCtrl::receiveBuf, tRFIDCtrl::request, tRFIDCtrl::result, tCR95HFCtrl::resultCode, RFID_POWERED, RFID_RESULT_BRIDGE_ERROR, RFID_State_Bridge_Antenna, RFID_State_Bridge_Echo, RFID_State_Bridge_FieldOn, RFID_State_Bridge_Finish, RFID_State_Bridge_SendError, RFID_State_Bridge_SendResult, RFID_State_Bridge_Start, RFID_State_Bridge_Transfert, RFID_State_Bridge_WaitAntenna, RFID_State_Bridge_WaitEcho, RFID_State_Bridge_WaitFieldOn, RFID_State_Bridge_WaitTransfert, RFID_STATE_STANDBY, RFIDExternalPowerMode, RFIDInternalPowerMode, tCR95HFCtrl::rxPos, tRFIDCtrl::state, tRFIDCtrl::subState, TickGetMsCounter(), TickMilliSecElapsedFrom(), UsbManagerSendCR95Error(), and UsbManagerSendCR95Result().

Referenced by RFIDDealer().

335 {
336 static unsigned long msRef = 0;
337
338 switch(RFIDCtrl.subState) {
339
340 case RFID_State_Bridge_Start :
341 RFIDCtrl.subState = RFID_State_Bridge_Antenna;
342
343 case RFID_State_Bridge_Antenna :
344 CR95SelectDevice(CR95_SELECT_EXTERNAL);
345 CR95UartDisableReceiver();
346 char data[1] = {0x55};
347 CR95UartSendData(data,1); //Try to wake up external
348 msRef = TickGetMsCounter();
349 RFIDCtrl.subState = RFID_State_Bridge_WaitAntenna;
350 break;
351
352 case RFID_State_Bridge_WaitAntenna :
353 if(TickMilliSecElapsedFrom(msRef)>10) {
354 if(CR95ExtGetConnectionState() == CR95_EXT_CONNECTED) {
355 CR95SelectDevice(CR95_SELECT_EXTERNAL);
356 RFIDExternalPowerMode = RFID_POWERED;
357 } else {
358 CR95SelectDevice(CR95_SELECT_INTERNAL);
359 RFIDInternalPowerMode = RFID_POWERED;
360 }
361 RFIDCtrl.subState = RFID_State_Bridge_Echo;
362 }
363 break;
364
365
366 case RFID_State_Bridge_Echo :
367 CR95HFStartEcho();
368 RFIDCtrl.subState = RFID_State_Bridge_WaitEcho;
369 break;
370
371 case RFID_State_Bridge_WaitEcho :
372 if(CR95HFManagerIsReady() == CR95HF_IS_READY) {
373 if(CR95HFCtrl.resultCode == CR95HF_RETURN_OK ) {
374 RFIDCtrl.subState = RFID_State_Bridge_FieldOn;
375 } else if (CR95HFCtrl.resultCode == CR95HF_RETURN_ECHO_ERROR) {
376 RFIDCtrl.subState = RFID_State_Bridge_SendError;
377 RFIDCtrl.result = RFID_RESULT_BRIDGE_ERROR;
378 }
379 }
380 break;
381
382 case RFID_State_Bridge_FieldOn :
383 CR95HFStartField15693();
384 RFIDCtrl.subState = RFID_State_Bridge_WaitFieldOn;
385 break;
386
387 case RFID_State_Bridge_WaitFieldOn :
388 if(CR95HFManagerIsReady() == CR95HF_IS_READY) {
389 if(CR95HFCtrl.resultCode == CR95HF_RETURN_OK) {
390 RFIDCtrl.subState = RFID_State_Bridge_Transfert;
391 } else if (CR95HFCtrl.resultCode == CR95HF_RETURN_FIELD15693_ERROR) {
392 RFIDCtrl.subState = RFID_State_Bridge_SendError;
393 RFIDCtrl.result = RFID_RESULT_BRIDGE_ERROR;
394 }
395 }
396 break;
397
398 case RFID_State_Bridge_Transfert :
399 CR95HFStartBridge(RFIDCtrl.bridgeCommand, RFIDCtrl.bridgeCommandLength);
400 RFIDCtrl.subState = RFID_State_Bridge_WaitTransfert;
401 break;
402
403 case RFID_State_Bridge_WaitTransfert :
404 if(CR95HFManagerIsReady() == CR95HF_IS_READY) {
405 if(CR95HFCtrl.resultCode == CR95HF_RETURN_OK) {
406 RFIDCtrl.subState = RFID_State_Bridge_SendResult;
407 } else {
408 RFIDCtrl.subState = RFID_State_Bridge_SendError;
409 RFIDCtrl.result = RFID_RESULT_BRIDGE_ERROR;
410 }
411 }
412 break;
413
414 case RFID_State_Bridge_SendResult :
415 UsbManagerSendCR95Result(CR95HFCtrl.receiveBuf, CR95HFCtrl.rxPos);
416 RFIDCtrl.subState = RFID_State_Bridge_Finish;
417 break;
418
419 case RFID_State_Bridge_SendError :
420 UsbManagerSendCR95Error();
421 RFIDCtrl.subState = RFID_State_Bridge_Finish;
422 break;
423
424 case RFID_State_Bridge_Finish :
425 RFIDCtrl.request.bits.bridge = 0;
426 RFIDCtrl.msRef = TickGetMsCounter();
427 RFIDCtrl.state = RFID_STATE_STANDBY;
428 break;
429
430 default :
431 RFIDCtrl.subState = RFID_State_Bridge_Start;
432 break;
433 }
434 }
RFID_State_Bridge_Start
Definition: RFIDManager.h:125
CR95ExtGetConnectionState
tCR95ExternalConnexion CR95ExtGetConnectionState(void)
Return the connection state of the CR95HF module.
Definition: CR95UartMapper.c:174
RFID_State_Bridge_WaitTransfert
Definition: RFIDManager.h:133
tRFIDCtrl::bridgeCommandLength
unsigned short bridgeCommandLength
Definition: RFIDManager.h:227
tRFIDCtrl::bits
struct tRFIDCtrl::@6::@7 bits
CR95HFStartBridge
void CR95HFStartBridge(char *data, unsigned short dataLength)
Definition: CR95HF.c:699
RFID_State_Bridge_FieldOn
Definition: RFIDManager.h:130
CR95HF_RETURN_FIELD15693_ERROR
Definition: CR95HF.h:185
RFID_State_Bridge_SendResult
Definition: RFIDManager.h:134
UsbManagerSendCR95Error
void UsbManagerSendCR95Error(void)
Function used to send the CR95 error on the USB.
Definition: UsbManager.c:590
CR95HFStartField15693
void CR95HFStartField15693(void)
Definition: CR95HF.c:655
tRFIDCtrl::result
tRFIDResultError result
Definition: RFIDManager.h:221
UsbManagerSendCR95Result
void UsbManagerSendCR95Result(char *result, unsigned short length)
Function used to send the CR95 result of last RFID operation on the USB.
Definition: UsbManager.c:604
tRFIDCtrl::msRef
unsigned long msRef
Definition: RFIDManager.h:229
RFID_State_Bridge_SendError
Definition: RFIDManager.h:135
CR95HFCtrl
tCR95HFCtrl CR95HFCtrl
Variable used by the state machine of the CR95HF.
Definition: CR95HF.c:67
tRFIDCtrl::request
union tRFIDCtrl::@6 request
CR95_SELECT_INTERNAL
Definition: CR95UartMapper.h:55
RFID_State_Bridge_WaitAntenna
Definition: RFIDManager.h:127
CR95HFStartEcho
void CR95HFStartEcho(void)
Manager used to deal each specific state.
Definition: CR95HF.c:635
RFID_State_Bridge_Transfert
Definition: RFIDManager.h:132
CR95UartDisableReceiver
void CR95UartDisableReceiver(void)
Definition: CR95UartMapper.c:119
RFIDInternalPowerMode
tRFIDPowerMode RFIDInternalPowerMode
Definition: RFIDManager.c:50
CR95HF_IS_READY
Definition: CR95HF.h:236
CR95HFManagerIsReady
tCR95HFIsReady CR95HFManagerIsReady(void)
Return the current state of the CR95HF module in it's manager.
Definition: CR95HF.c:718
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
RFID_STATE_STANDBY
Definition: RFIDManager.h:78
CR95_EXT_CONNECTED
Definition: CR95UartMapper.h:66
tCR95HFCtrl::receiveBuf
char receiveBuf[CR95HF_RX_BUF_SIZE]
Definition: CR95HF.h:211
RFIDExternalPowerMode
tRFIDPowerMode RFIDExternalPowerMode
Definition: RFIDManager.c:51
tCR95HFCtrl::resultCode
unsigned long resultCode
Definition: CR95HF.h:221
RFID_State_Bridge_WaitEcho
Definition: RFIDManager.h:129
tRFIDCtrl::state
tRFIDState state
Definition: RFIDManager.h:219
tCR95HFCtrl::rxPos
unsigned short rxPos
Definition: CR95HF.h:212
tRFIDCtrl::subState
unsigned long subState
Definition: RFIDManager.h:220
CR95_SELECT_EXTERNAL
Definition: CR95UartMapper.h:56
CR95HF_RETURN_OK
Definition: CR95HF.h:182
RFID_State_Bridge_Finish
Definition: RFIDManager.h:136
tRFIDCtrl::bridgeCommand
unsigned char bridgeCommand[RFIDMANAGER_BRIDGE_MAX_COMMAND_LENGTH]
Definition: RFIDManager.h:225
RFID_State_Bridge_WaitFieldOn
Definition: RFIDManager.h:131
CR95SelectDevice
void CR95SelectDevice(tCR95UartSelect device)
Select the antenna used to communicate with the SRD.
Definition: CR95UartMapper.c:79
RFID_POWERED
Definition: RFIDManager.h:65
TickMilliSecElapsedFrom
unsigned long TickMilliSecElapsedFrom(unsigned long refTimeMs)
Get the milliseconds counter.
Definition: tick.c:141
RFIDCtrl
tRFIDCtrl RFIDCtrl
Variable used to control the RFID manager.
Definition: RFIDManager.c:59
RFID_State_Bridge_Antenna
Definition: RFIDManager.h:126
CR95HF_RETURN_ECHO_ERROR
Definition: CR95HF.h:183
RFID_RESULT_BRIDGE_ERROR
Definition: RFIDManager.h:200
RFID_State_Bridge_Echo
Definition: RFIDManager.h:128

Here is the call graph for this function:

Here is the caller graph for this function:

void RFIDDealer | ( | void |  | ) |

Definition at line 165 of file RFIDManager.c.

References tRFIDCtrl::all, tRFIDCtrl::request, RFID_STATE_BRIDGE, RFID_STATE_LOW_POWER_EXT, RFID_STATE_LOW_POWER_INT, RFID_STATE_READ, RFID_STATE_STANDBY, RFID_STATE_WRITE, RFIDBridgeStateMachine(), RFIDExtLpmStateMachine(), RFIDIntLpmStateMachine(), RFIDReadStateMachine(), RFIDWriteStateMachine(), and tRFIDCtrl::state.

Referenced by RFIDManager().

165 {
166
167 switch(RFIDCtrl.state) {
168
169 case RFID_STATE_STANDBY :
170 //Wait state -> Do nothing
171 break;
172
173 case RFID_STATE_BRIDGE :
174 RFIDBridgeStateMachine();
175 break;
176
177 case RFID_STATE_READ :
178 RFIDReadStateMachine();
179 break;
180
181 case RFID_STATE_WRITE :
182 RFIDWriteStateMachine();
183 break;
184
185 case RFID_STATE_LOW_POWER_INT :
186 RFIDIntLpmStateMachine();
187 break;
188
189 case RFID_STATE_LOW_POWER_EXT :
190 RFIDExtLpmStateMachine();
191 break;
192
193 default :
194 RFIDCtrl.request.all = 0;
195 RFIDCtrl.state = RFID_STATE_STANDBY;
196 break;
197
198 }
199 }
RFIDWriteStateMachine
void RFIDWriteStateMachine(void)
Definition: RFIDManager.c:541
RFID_STATE_READ
Definition: RFIDManager.h:80
RFID_STATE_WRITE
Definition: RFIDManager.h:79
tRFIDCtrl::request
union tRFIDCtrl::@6 request
RFIDExtLpmStateMachine
void RFIDExtLpmStateMachine(void)
Definition: RFIDManager.c:268
tRFIDCtrl::all
unsigned short all
Definition: RFIDManager.h:217
RFIDReadStateMachine
void RFIDReadStateMachine(void)
Definition: RFIDManager.c:436
RFID_STATE_BRIDGE
Definition: RFIDManager.h:81
RFID_STATE_STANDBY
Definition: RFIDManager.h:78
RFID_STATE_LOW_POWER_EXT
Definition: RFIDManager.h:77
tRFIDCtrl::state
tRFIDState state
Definition: RFIDManager.h:219
RFID_STATE_LOW_POWER_INT
Definition: RFIDManager.h:76
RFIDCtrl
tRFIDCtrl RFIDCtrl
Variable used to control the RFID manager.
Definition: RFIDManager.c:59
RFIDIntLpmStateMachine
void RFIDIntLpmStateMachine(void)
Definition: RFIDManager.c:201
RFIDBridgeStateMachine
void RFIDBridgeStateMachine(void)
Definition: RFIDManager.c:335

Here is the call graph for this function:

Here is the caller graph for this function:

void RFIDExtLpmStateMachine | ( | void |  | ) |

Definition at line 268 of file RFIDManager.c.

References CR95_SELECT_EXTERNAL, CR95HF_IS_READY, CR95HF_RETURN_ECHO_ERROR, CR95HF_RETURN_FIELDOFF_ERROR, CR95HF_RETURN_HIBERNATE_ERROR, CR95HF_RETURN_OK, CR95HFCtrl, CR95HFManagerIsReady(), CR95HFStartEcho(), CR95HFStartFieldOff(), CR95HFStartHibernate(), CR95SelectDevice(), tCR95HFCtrl::resultCode, RFID_HIBERNATE, RFID_State_ExtLpm_Echo, RFID_State_ExtLpm_FieldOff, RFID_State_ExtLpm_Finish, RFID_State_ExtLpm_Hibernate, RFID_State_ExtLpm_Start, RFID_State_ExtLpm_WaitEcho, RFID_State_ExtLpm_WaitFieldOff, RFID_State_ExtLpm_WaitHibernate, RFID_STATE_STANDBY, RFIDExternalPowerMode, tRFIDCtrl::state, and tRFIDCtrl::subState.

Referenced by RFIDDealer().

268 {
269
270 switch(RFIDCtrl.subState) {
271
272 case RFID_State_ExtLpm_Start :
273 CR95SelectDevice(CR95_SELECT_EXTERNAL);
274 RFIDCtrl.subState = RFID_State_ExtLpm_Echo;
275
276 case RFID_State_ExtLpm_Echo :
277 CR95HFStartEcho();
278 RFIDCtrl.subState = RFID_State_ExtLpm_WaitEcho;
279 break;
280
281 case RFID_State_ExtLpm_WaitEcho :
282 if(CR95HFManagerIsReady() == CR95HF_IS_READY) {
283 if(CR95HFCtrl.resultCode == CR95HF_RETURN_OK ) {
284 RFIDCtrl.subState = RFID_State_ExtLpm_FieldOff;
285 } else if (CR95HFCtrl.resultCode == CR95HF_RETURN_ECHO_ERROR) {
286 RFIDCtrl.subState = RFID_State_ExtLpm_FieldOff;
287 //RFIDCtrl.result = RFID_RESULT_EXTLPM_ERROR;
288 }
289 }
290 break;
291
292 case RFID_State_ExtLpm_FieldOff :
293 CR95HFStartFieldOff();
294 RFIDCtrl.subState = RFID_State_ExtLpm_WaitFieldOff;
295 break;
296
297 case RFID_State_ExtLpm_WaitFieldOff :
298 if(CR95HFManagerIsReady() == CR95HF_IS_READY) {
299 if(CR95HFCtrl.resultCode == CR95HF_RETURN_OK ) {
300 RFIDCtrl.subState = RFID_State_ExtLpm_Hibernate;
301 } else if (CR95HFCtrl.resultCode == CR95HF_RETURN_FIELDOFF_ERROR) {
302 RFIDCtrl.subState = RFID_State_ExtLpm_Hibernate;
303 //RFIDCtrl.result = RFID_RESULT_EXTLPM_ERROR;
304 }
305 }
306 break;
307
308 case RFID_State_ExtLpm_Hibernate :
309 CR95HFStartHibernate();
310 RFIDCtrl.subState = RFID_State_ExtLpm_WaitHibernate;
311 break;
312
313 case RFID_State_ExtLpm_WaitHibernate :
314 if(CR95HFManagerIsReady() == CR95HF_IS_READY) {
315 if(CR95HFCtrl.resultCode == CR95HF_RETURN_OK) {
316 RFIDCtrl.subState = RFID_State_ExtLpm_Finish;
317 } else if (CR95HFCtrl.resultCode == CR95HF_RETURN_HIBERNATE_ERROR) {
318 RFIDCtrl.subState = RFID_State_ExtLpm_Finish;
319 //RFIDCtrl.result = RFID_RESULT_EXTLPM_ERROR;
320 }
321 }
322 break;
323
324 case RFID_State_ExtLpm_Finish :
325 RFIDExternalPowerMode = RFID_HIBERNATE;
326 RFIDCtrl.state = RFID_STATE_STANDBY;
327 break;
328
329 default :
330 RFIDCtrl.subState = RFID_State_ExtLpm_Start;
331 break;
332 }
333 }
RFID_State_ExtLpm_Start
Definition: RFIDManager.h:108
RFID_State_ExtLpm_Hibernate
Definition: RFIDManager.h:113
RFID_State_ExtLpm_WaitEcho
Definition: RFIDManager.h:110
CR95HFStartHibernate
void CR95HFStartHibernate(void)
Definition: CR95HF.c:666
RFID_HIBERNATE
Definition: RFIDManager.h:66
RFID_State_ExtLpm_Finish
Definition: RFIDManager.h:115
RFID_State_ExtLpm_Echo
Definition: RFIDManager.h:109
CR95HF_RETURN_FIELDOFF_ERROR
Definition: CR95HF.h:184
CR95HFCtrl
tCR95HFCtrl CR95HFCtrl
Variable used by the state machine of the CR95HF.
Definition: CR95HF.c:67
RFID_State_ExtLpm_FieldOff
Definition: RFIDManager.h:111
CR95HFStartEcho
void CR95HFStartEcho(void)
Manager used to deal each specific state.
Definition: CR95HF.c:635
CR95HF_IS_READY
Definition: CR95HF.h:236
CR95HFManagerIsReady
tCR95HFIsReady CR95HFManagerIsReady(void)
Return the current state of the CR95HF module in it's manager.
Definition: CR95HF.c:718
RFID_STATE_STANDBY
Definition: RFIDManager.h:78
CR95HFStartFieldOff
void CR95HFStartFieldOff(void)
Definition: CR95HF.c:645
CR95HF_RETURN_HIBERNATE_ERROR
Definition: CR95HF.h:186
RFIDExternalPowerMode
tRFIDPowerMode RFIDExternalPowerMode
Definition: RFIDManager.c:51
tCR95HFCtrl::resultCode
unsigned long resultCode
Definition: CR95HF.h:221
RFID_State_ExtLpm_WaitFieldOff
Definition: RFIDManager.h:112
tRFIDCtrl::state
tRFIDState state
Definition: RFIDManager.h:219
tRFIDCtrl::subState
unsigned long subState
Definition: RFIDManager.h:220
CR95_SELECT_EXTERNAL
Definition: CR95UartMapper.h:56
CR95HF_RETURN_OK
Definition: CR95HF.h:182
RFID_State_ExtLpm_WaitHibernate
Definition: RFIDManager.h:114
CR95SelectDevice
void CR95SelectDevice(tCR95UartSelect device)
Select the antenna used to communicate with the SRD.
Definition: CR95UartMapper.c:79
RFIDCtrl
tRFIDCtrl RFIDCtrl
Variable used to control the RFID manager.
Definition: RFIDManager.c:59
CR95HF_RETURN_ECHO_ERROR
Definition: CR95HF.h:183

Here is the call graph for this function:

Here is the caller graph for this function:

void RFIDIntLpmStateMachine | ( | void |  | ) |

Definition at line 201 of file RFIDManager.c.

References CR95_SELECT_INTERNAL, CR95HF_IS_READY, CR95HF_RETURN_ECHO_ERROR, CR95HF_RETURN_FIELDOFF_ERROR, CR95HF_RETURN_HIBERNATE_ERROR, CR95HF_RETURN_OK, CR95HFCtrl, CR95HFManagerIsReady(), CR95HFStartEcho(), CR95HFStartFieldOff(), CR95HFStartHibernate(), CR95SelectDevice(), tCR95HFCtrl::resultCode, RFID_HIBERNATE, RFID_State_IntLpm_Echo, RFID_State_IntLpm_FieldOff, RFID_State_IntLpm_Finish, RFID_State_IntLpm_Hibernate, RFID_State_IntLpm_Start, RFID_State_IntLpm_WaitEcho, RFID_State_IntLpm_WaitFieldOff, RFID_State_IntLpm_WaitHibernate, RFID_STATE_STANDBY, RFIDInternalPowerMode, tRFIDCtrl::state, and tRFIDCtrl::subState.

Referenced by RFIDDealer().

201 {
202
203 switch(RFIDCtrl.subState) {
204
205 case RFID_State_IntLpm_Start :
206 CR95SelectDevice(CR95_SELECT_INTERNAL);
207 RFIDCtrl.subState = RFID_State_IntLpm_Echo;
208
209 case RFID_State_IntLpm_Echo :
210 CR95HFStartEcho();
211 RFIDCtrl.subState = RFID_State_IntLpm_WaitEcho;
212 break;
213
214 case RFID_State_IntLpm_WaitEcho :
215 if(CR95HFManagerIsReady() == CR95HF_IS_READY) {
216 if(CR95HFCtrl.resultCode == CR95HF_RETURN_OK) {
217 RFIDCtrl.subState = RFID_State_IntLpm_FieldOff;
218 } else if (CR95HFCtrl.resultCode == CR95HF_RETURN_ECHO_ERROR) {
219 RFIDCtrl.subState = RFID_State_IntLpm_FieldOff;
220 //RFIDCtrl.result = RFID_RESULT_INTLPM_ERROR;
221 }
222 }
223 break;
224
225 case RFID_State_IntLpm_FieldOff :
226 CR95HFStartFieldOff();
227 RFIDCtrl.subState = RFID_State_IntLpm_WaitFieldOff;
228 break;
229
230 case RFID_State_IntLpm_WaitFieldOff :
231 if(CR95HFManagerIsReady() == CR95HF_IS_READY) {
232 if(CR95HFCtrl.resultCode == CR95HF_RETURN_OK) {
233 RFIDCtrl.subState = RFID_State_IntLpm_Hibernate;
234 } else if (CR95HFCtrl.resultCode == CR95HF_RETURN_FIELDOFF_ERROR) {
235 RFIDCtrl.subState = RFID_State_IntLpm_Hibernate;
236 //RFIDCtrl.result = RFID_RESULT_INTLPM_ERROR;
237 }
238 }
239 break;
240
241 case RFID_State_IntLpm_Hibernate :
242 CR95HFStartHibernate();
243 RFIDCtrl.subState = RFID_State_IntLpm_WaitHibernate;
244 break;
245
246 case RFID_State_IntLpm_WaitHibernate :
247 if(CR95HFManagerIsReady() == CR95HF_IS_READY) {
248 if(CR95HFCtrl.resultCode == CR95HF_RETURN_OK) {
249 RFIDCtrl.subState = RFID_State_IntLpm_Finish;
250 } else if (CR95HFCtrl.resultCode == CR95HF_RETURN_HIBERNATE_ERROR) {
251 RFIDCtrl.subState = RFID_State_IntLpm_Finish;
252 //RFIDCtrl.result = RFID_RESULT_INTLPM_ERROR;
253 }
254 }
255 break;
256
257 case RFID_State_IntLpm_Finish :
258 RFIDInternalPowerMode = RFID_HIBERNATE;
259 RFIDCtrl.state = RFID_STATE_STANDBY;
260 break;
261
262 default :
263 RFIDCtrl.subState = RFID_State_IntLpm_Start;
264 break;
265 }
266 }
RFID_State_IntLpm_Start
Definition: RFIDManager.h:91
CR95HFStartHibernate
void CR95HFStartHibernate(void)
Definition: CR95HF.c:666
RFID_State_IntLpm_WaitEcho
Definition: RFIDManager.h:93
RFID_HIBERNATE
Definition: RFIDManager.h:66
CR95HF_RETURN_FIELDOFF_ERROR
Definition: CR95HF.h:184
RFID_State_IntLpm_WaitFieldOff
Definition: RFIDManager.h:95
RFID_State_IntLpm_Finish
Definition: RFIDManager.h:98
CR95HFCtrl
tCR95HFCtrl CR95HFCtrl
Variable used by the state machine of the CR95HF.
Definition: CR95HF.c:67
CR95_SELECT_INTERNAL
Definition: CR95UartMapper.h:55
CR95HFStartEcho
void CR95HFStartEcho(void)
Manager used to deal each specific state.
Definition: CR95HF.c:635
RFID_State_IntLpm_Echo
Definition: RFIDManager.h:92
RFIDInternalPowerMode
tRFIDPowerMode RFIDInternalPowerMode
Definition: RFIDManager.c:50
CR95HF_IS_READY
Definition: CR95HF.h:236
CR95HFManagerIsReady
tCR95HFIsReady CR95HFManagerIsReady(void)
Return the current state of the CR95HF module in it's manager.
Definition: CR95HF.c:718
RFID_STATE_STANDBY
Definition: RFIDManager.h:78
CR95HFStartFieldOff
void CR95HFStartFieldOff(void)
Definition: CR95HF.c:645
CR95HF_RETURN_HIBERNATE_ERROR
Definition: CR95HF.h:186
RFID_State_IntLpm_FieldOff
Definition: RFIDManager.h:94
tCR95HFCtrl::resultCode
unsigned long resultCode
Definition: CR95HF.h:221
tRFIDCtrl::state
tRFIDState state
Definition: RFIDManager.h:219
tRFIDCtrl::subState
unsigned long subState
Definition: RFIDManager.h:220
RFID_State_IntLpm_Hibernate
Definition: RFIDManager.h:96
CR95HF_RETURN_OK
Definition: CR95HF.h:182
CR95SelectDevice
void CR95SelectDevice(tCR95UartSelect device)
Select the antenna used to communicate with the SRD.
Definition: CR95UartMapper.c:79
RFIDCtrl
tRFIDCtrl RFIDCtrl
Variable used to control the RFID manager.
Definition: RFIDManager.c:59
RFID_State_IntLpm_WaitHibernate
Definition: RFIDManager.h:97
CR95HF_RETURN_ECHO_ERROR
Definition: CR95HF.h:183

Here is the call graph for this function:

Here is the caller graph for this function:

void RFIDManager | ( | void |  | ) |

RFID manager.

Definition at line 93 of file RFIDManager.c.

References tRFIDCtrl::all, tRFIDCtrl::bits, CR95_EXT_CONNECTED, CR95ExtGetConnectionState(), CR95HFManager(), tRFIDCtrl::lpm, tRFIDCtrl::msRef, tRFIDCtrl::request, tRFIDCtrl::result, RFID_HIBERNATE, RFID_POWERED, RFID_READY_FOR_LPM, RFID_RESULT_OK, RFID_STATE_BRIDGE, RFID_State_Bridge_Start, RFID_State_ExtLpm_Start, RFID_State_IntLpm_Start, RFID_STATE_LOW_POWER_EXT, RFID_STATE_LOW_POWER_INT, RFID_STATE_READ, RFID_State_Read_Start, RFID_STATE_STANDBY, RFID_STATE_WRITE, RFID_State_Write_Start, RFID_WORKING, RFIDDealer(), RFIDExternalPowerMode, RFIDInternalPowerMode, tRFIDCtrl::state, tRFIDCtrl::subState, and TickMilliSecElapsedFrom().

Referenced by taskBackground().

93 {
94
95 /*=== Wait for RFID ready ===*/
96 if(RFIDCtrl.state == RFID_STATE_STANDBY) {
97
98 /*=== If no request for the moment ===*/
99 if(RFIDCtrl.request.all == 0) {
100
101 if(RFIDCtrl.msRef == 0) {
102
103 /*-- Try to put all device in LPM --*/
104 if(RFIDInternalPowerMode == RFID_POWERED) {
105 RFIDCtrl.state = RFID_STATE_LOW_POWER_INT;
106 RFIDCtrl.subState = RFID_State_IntLpm_Start;
107 //RFIDCtrl.result = RFID_RESULT_OK;
108
109 } else if (CR95ExtGetConnectionState() == CR95_EXT_CONNECTED) {
110 if(RFIDExternalPowerMode == RFID_POWERED) {
111 RFIDCtrl.state = RFID_STATE_LOW_POWER_EXT;
112 RFIDCtrl.subState = RFID_State_ExtLpm_Start;
113 //RFIDCtrl.result = RFID_RESULT_OK;
114 }
115 } else {
116 RFIDExternalPowerMode = RFID_HIBERNATE;
117 }
118
119 if(RFIDExternalPowerMode == RFID_HIBERNATE && RFIDInternalPowerMode == RFID_HIBERNATE) {
120 RFIDCtrl.lpm = RFID_READY_FOR_LPM;
121 }
122
123 } else {
124
125 if(TickMilliSecElapsedFrom(RFIDCtrl.msRef) > 1000) {
126 RFIDCtrl.msRef = 0;
127 }
128
129 }
130
131 /*=== Deal request ===*/
132 } else {
133
134 RFIDCtrl.lpm = RFID_WORKING;
135
136 if(RFIDCtrl.request.bits.read) {
137 RFIDCtrl.state = RFID_STATE_READ;
138 RFIDCtrl.subState = RFID_State_Read_Start;
139 RFIDCtrl.result = RFID_RESULT_OK;
140 }
141
142 else if(RFIDCtrl.request.bits.write) {
143 RFIDCtrl.state = RFID_STATE_WRITE;
144 RFIDCtrl.subState = RFID_State_Write_Start;
145 RFIDCtrl.result = RFID_RESULT_OK;
146 }
147
148 else if(RFIDCtrl.request.bits.bridge) {
149 RFIDCtrl.state = RFID_STATE_BRIDGE;
150 RFIDCtrl.subState = RFID_State_Bridge_Start;
151 RFIDCtrl.result = RFID_RESULT_OK;
152 }
153 }
154 } else {
155 RFIDCtrl.lpm = RFID_WORKING;
156 }
157
158 RFIDDealer();
159
160 /*=== Deal CR95 Manager ===*/
161 CR95HFManager();
162 }
RFID_STATE_READ
Definition: RFIDManager.h:80
RFID_State_Read_Start
Definition: RFIDManager.h:146
RFID_State_Bridge_Start
Definition: RFIDManager.h:125
RFIDDealer
void RFIDDealer(void)
Definition: RFIDManager.c:165
CR95ExtGetConnectionState
tCR95ExternalConnexion CR95ExtGetConnectionState(void)
Return the connection state of the CR95HF module.
Definition: CR95UartMapper.c:174
RFID_State_ExtLpm_Start
Definition: RFIDManager.h:108
RFID_STATE_WRITE
Definition: RFIDManager.h:79
CR95HFManager
void CR95HFManager(void)
Global manager of the CR95HF module.
Definition: CR95HF.c:598
RFID_State_IntLpm_Start
Definition: RFIDManager.h:91
tRFIDCtrl::bits
struct tRFIDCtrl::@6::@7 bits
RFID_WORKING
Definition: RFIDManager.h:55
tRFIDCtrl::lpm
tRFIDLpm lpm
Definition: RFIDManager.h:223
RFID_HIBERNATE
Definition: RFIDManager.h:66
tRFIDCtrl::result
tRFIDResultError result
Definition: RFIDManager.h:221
tRFIDCtrl::msRef
unsigned long msRef
Definition: RFIDManager.h:229
tRFIDCtrl::request
union tRFIDCtrl::@6 request
tRFIDCtrl::all
unsigned short all
Definition: RFIDManager.h:217
RFIDInternalPowerMode
tRFIDPowerMode RFIDInternalPowerMode
Definition: RFIDManager.c:50
RFID_STATE_BRIDGE
Definition: RFIDManager.h:81
RFID_READY_FOR_LPM
Definition: RFIDManager.h:54
RFID_STATE_STANDBY
Definition: RFIDManager.h:78
CR95_EXT_CONNECTED
Definition: CR95UartMapper.h:66
RFID_STATE_LOW_POWER_EXT
Definition: RFIDManager.h:77
RFIDExternalPowerMode
tRFIDPowerMode RFIDExternalPowerMode
Definition: RFIDManager.c:51
RFID_State_Write_Start
Definition: RFIDManager.h:165
tRFIDCtrl::state
tRFIDState state
Definition: RFIDManager.h:219
RFID_STATE_LOW_POWER_INT
Definition: RFIDManager.h:76
tRFIDCtrl::subState
unsigned long subState
Definition: RFIDManager.h:220
RFID_POWERED
Definition: RFIDManager.h:65
TickMilliSecElapsedFrom
unsigned long TickMilliSecElapsedFrom(unsigned long refTimeMs)
Get the milliseconds counter.
Definition: tick.c:141
RFIDCtrl
tRFIDCtrl RFIDCtrl
Variable used to control the RFID manager.
Definition: RFIDManager.c:59
RFID_RESULT_OK
Definition: RFIDManager.h:195

Here is the call graph for this function:

Here is the caller graph for this function:

void RFIDManagerInit | ( | void |  | ) |

Function used to initialize the RFID manager.

Definition at line 79 of file RFIDManager.c.

References CR95HFInit(), tRFIDCtrl::lpm, tRFIDCtrl::msRef, RFID_POWERED, RFID_STATE_STANDBY, RFID_WORKING, RFIDExternalPowerMode, RFIDInternalPowerMode, and tRFIDCtrl::state.

Referenced by Setup().

79 {
80
81 CR95HFInit();
82 RFIDInternalPowerMode = RFID_POWERED;
83 RFIDExternalPowerMode = RFID_POWERED;
84
85 RFIDCtrl.state = RFID_STATE_STANDBY;
86
87 RFIDCtrl.lpm = RFID_WORKING;
88
89 RFIDCtrl.msRef = 0;
90
91 }
RFID_WORKING
Definition: RFIDManager.h:55
tRFIDCtrl::lpm
tRFIDLpm lpm
Definition: RFIDManager.h:223
tRFIDCtrl::msRef
unsigned long msRef
Definition: RFIDManager.h:229
RFIDInternalPowerMode
tRFIDPowerMode RFIDInternalPowerMode
Definition: RFIDManager.c:50
RFID_STATE_STANDBY
Definition: RFIDManager.h:78
RFIDExternalPowerMode
tRFIDPowerMode RFIDExternalPowerMode
Definition: RFIDManager.c:51
tRFIDCtrl::state
tRFIDState state
Definition: RFIDManager.h:219
RFID_POWERED
Definition: RFIDManager.h:65
RFIDCtrl
tRFIDCtrl RFIDCtrl
Variable used to control the RFID manager.
Definition: RFIDManager.c:59
CR95HFInit
void CR95HFInit(void)
Function used to initialize the CR95HF global manager.
Definition: CR95HF.c:585

Here is the call graph for this function:

Here is the caller graph for this function:

signed short RFIDManagerSendBridgeCommand | ( | char * | command,
|  | unsigned short | commandSize
| ) |  |

function used to send a bridge command.

Parameters

  [in] | command | (char*) : pointer on data to send over the bridge.
  [in] | commandSize | (unsigned short) : data length to send over the bridge interface.

Definition at line 763 of file RFIDManager.c.

References tRFIDCtrl::bits, tRFIDCtrl::bridgeCommand, tRFIDCtrl::bridgeCommandLength, and tRFIDCtrl::request.

Referenced by UsbManagerCmdDealer().

763 {
764
765 //if(RFIDCtrl.state == RFID_STATE_STANDBY) {
766 unsigned short i;
767
768 for(i=0 ; i<commandSize ; i++) {
769 RFIDCtrl.bridgeCommand[i] = *(command+i);
770 }
771
772 RFIDCtrl.bridgeCommandLength = commandSize;
773
774 RFIDCtrl.request.bits.bridge = 1;
775
776 return 0;
777
778 //} else {
779 // return -1; //Error
780 //}
781 }
tRFIDCtrl::bridgeCommandLength
unsigned short bridgeCommandLength
Definition: RFIDManager.h:227
tRFIDCtrl::bits
struct tRFIDCtrl::@6::@7 bits
tRFIDCtrl::request
union tRFIDCtrl::@6 request
tRFIDCtrl::bridgeCommand
unsigned char bridgeCommand[RFIDMANAGER_BRIDGE_MAX_COMMAND_LENGTH]
Definition: RFIDManager.h:225
RFIDCtrl
tRFIDCtrl RFIDCtrl
Variable used to control the RFID manager.
Definition: RFIDManager.c:59

Here is the caller graph for this function:

void RFIDReadStateMachine | ( | void |  | ) |

Definition at line 436 of file RFIDManager.c.

References tRFIDCtrl::bits, BUTTON_PRESSED, ButtonReadGetState, CR95_EXT_CONNECTED, CR95_SELECT_EXTERNAL, CR95_SELECT_INTERNAL, CR95ExtGetConnectionState(), CR95HF_IS_READY, CR95HF_RETURN_ECHO_ERROR, CR95HF_RETURN_FIELD15693_ERROR, CR95HF_RETURN_OK, CR95HF_RETURN_READ_ERROR, CR95HFCtrl, CR95HFManagerIsReady(), CR95HFStartEcho(), CR95HFStartField15693(), CR95HFStartRead(), CR95SelectDevice(), CR95UartDisableReceiver(), CR95UartSendData(), tCR95HFCtrl::deviceReg, tRFIDCtrl::request, tRFIDCtrl::result, tCR95HFCtrl::resultCode, RFID_POWERED, RFID_RESULT_OK, RFID_RESULT_READ_ERROR, RFID_State_Bridge_Start, RFID_State_Read_Antenna, RFID_State_Read_Echo, RFID_State_Read_FieldOn, RFID_State_Read_Finish, RFID_State_Read_Read, RFID_State_Read_Start, RFID_State_Read_WaitAntenna, RFID_State_Read_WaitEcho, RFID_State_Read_WaitFieldOn, RFID_State_Read_WaitRead, RFID_STATE_STANDBY, RFIDExternalPowerMode, RFIDInternalPowerMode, SRD_MEMORY_NBR_BLOCK, tRFIDCtrl::state, tRFIDCtrl::subState, TickGetMsCounter(), and TickMilliSecElapsedFrom().

Referenced by RFIDDealer().

436 {
437 static unsigned short addr = 0;
438 static unsigned long msRef = 0;
439
440 switch(RFIDCtrl.subState) {
441
442 case RFID_State_Read_Start :
443 addr = 0;
444 RFIDCtrl.subState = RFID_State_Read_Antenna;
445
446 case RFID_State_Read_Antenna :
447 CR95SelectDevice(CR95_SELECT_EXTERNAL);
448 CR95UartDisableReceiver();
449 char data[1] = {0x55};
450 CR95UartSendData(data,1); //Try to wake up external
451 msRef = TickGetMsCounter();
452 RFIDCtrl.subState = RFID_State_Read_WaitAntenna;
453 break;
454
455 case RFID_State_Read_WaitAntenna :
456 if(TickMilliSecElapsedFrom(msRef)>10) {
457 if(CR95ExtGetConnectionState() == CR95_EXT_CONNECTED) {
458 CR95SelectDevice(CR95_SELECT_EXTERNAL);
459 RFIDExternalPowerMode = RFID_POWERED;
460 } else {
461 CR95SelectDevice(CR95_SELECT_INTERNAL);
462 RFIDInternalPowerMode = RFID_POWERED;
463 }
464 RFIDCtrl.subState = RFID_State_Read_Echo;
465 }
466 break;
467
468 case RFID_State_Read_Echo :
469 CR95HFStartEcho();
470 RFIDCtrl.subState = RFID_State_Read_WaitEcho;
471 break;
472
473 case RFID_State_Read_WaitEcho :
474 if(CR95HFManagerIsReady() == CR95HF_IS_READY) {
475 if(CR95HFCtrl.resultCode == CR95HF_RETURN_OK) {
476 RFIDCtrl.subState = RFID_State_Read_FieldOn;
477 } else if (CR95HFCtrl.resultCode == CR95HF_RETURN_ECHO_ERROR) {
478 RFIDCtrl.subState = RFID_State_Read_Finish;
479 RFIDCtrl.result = RFID_RESULT_READ_ERROR;
480 }
481 }
482 break;
483
484 case RFID_State_Read_FieldOn :
485 CR95HFStartField15693();
486 RFIDCtrl.subState = RFID_State_Read_WaitFieldOn;
487 break;
488
489 case RFID_State_Read_WaitFieldOn :
490 if(CR95HFManagerIsReady() == CR95HF_IS_READY) {
491 if(CR95HFCtrl.resultCode == CR95HF_RETURN_OK) {
492 RFIDCtrl.subState = RFID_State_Read_Read;
493 //RFIDCtrl.subState =RFID_State_Read_FieldOn;
494 } else if (CR95HFCtrl.resultCode == CR95HF_RETURN_FIELD15693_ERROR) {
495 RFIDCtrl.subState = RFID_State_Read_Finish;
496 RFIDCtrl.result = RFID_RESULT_READ_ERROR;
497 }
498 }
499 break;
500
501 case RFID_State_Read_Read :
502 CR95HFStartRead(addr);
503 RFIDCtrl.subState = RFID_State_Read_WaitRead;
504 break;
505
506 case RFID_State_Read_WaitRead :
507 if(CR95HFManagerIsReady() == CR95HF_IS_READY) {
508 if(CR95HFCtrl.resultCode == CR95HF_RETURN_OK) {
509 *(((unsigned long*)&SRDEeprom) + addr ) = CR95HFCtrl.deviceReg;
510 if(addr < (SRD_MEMORY_NBR_BLOCK-1)) {
511 addr++;
512 RFIDCtrl.subState = RFID_State_Read_Read;
513 } else {
514 RFIDCtrl.subState = RFID_State_Read_Finish;
515 }
516 } else if (CR95HFCtrl.resultCode == CR95HF_RETURN_READ_ERROR) {
517 RFIDCtrl.subState = RFID_State_Read_Finish;
518 RFIDCtrl.result = RFID_RESULT_READ_ERROR;
519 }
520 }
521 break;
522
523
524 case RFID_State_Read_Finish :
525 if(RFIDCtrl.result != RFID_RESULT_OK && ButtonReadGetState() == BUTTON_PRESSED) {
526 RFIDCtrl.result = RFID_RESULT_OK;
527 RFIDCtrl.subState = RFID_State_Read_Echo;
528 } else {
529 RFIDCtrl.request.bits.read = 0;
530 RFIDCtrl.state = RFID_STATE_STANDBY;
531 }
532 break;
533
534 default :
535 RFIDCtrl.subState = RFID_State_Bridge_Start;
536 break;
537 }
538 }
RFID_RESULT_READ_ERROR
Definition: RFIDManager.h:199
RFID_State_Read_WaitAntenna
Definition: RFIDManager.h:148
RFID_State_Read_Start
Definition: RFIDManager.h:146
RFID_State_Bridge_Start
Definition: RFIDManager.h:125
CR95ExtGetConnectionState
tCR95ExternalConnexion CR95ExtGetConnectionState(void)
Return the connection state of the CR95HF module.
Definition: CR95UartMapper.c:174
RFID_State_Read_FieldOn
Definition: RFIDManager.h:151
SRDEeprom
tSRDEeprom SRDEeprom
Definition: RFIDManager.c:61
tRFIDCtrl::bits
struct tRFIDCtrl::@6::@7 bits
RFID_State_Read_Read
Definition: RFIDManager.h:153
CR95HF_RETURN_FIELD15693_ERROR
Definition: CR95HF.h:185
tCR95HFCtrl::deviceReg
unsigned long deviceReg
Definition: CR95HF.h:223
RFID_State_Read_Antenna
Definition: RFIDManager.h:147
BUTTON_PRESSED
Definition: button.h:67
CR95HFStartField15693
void CR95HFStartField15693(void)
Definition: CR95HF.c:655
CR95HF_RETURN_READ_ERROR
Definition: CR95HF.h:187
tRFIDCtrl::result
tRFIDResultError result
Definition: RFIDManager.h:221
RFID_State_Read_WaitRead
Definition: RFIDManager.h:154
CR95HFStartRead
void CR95HFStartRead(unsigned short addr)
Definition: CR95HF.c:676
CR95HFCtrl
tCR95HFCtrl CR95HFCtrl
Variable used by the state machine of the CR95HF.
Definition: CR95HF.c:67
tRFIDCtrl::request
union tRFIDCtrl::@6 request
CR95_SELECT_INTERNAL
Definition: CR95UartMapper.h:55
CR95HFStartEcho
void CR95HFStartEcho(void)
Manager used to deal each specific state.
Definition: CR95HF.c:635
RFID_State_Read_Finish
Definition: RFIDManager.h:155
CR95UartDisableReceiver
void CR95UartDisableReceiver(void)
Definition: CR95UartMapper.c:119
RFIDInternalPowerMode
tRFIDPowerMode RFIDInternalPowerMode
Definition: RFIDManager.c:50
CR95HF_IS_READY
Definition: CR95HF.h:236
CR95HFManagerIsReady
tCR95HFIsReady CR95HFManagerIsReady(void)
Return the current state of the CR95HF module in it's manager.
Definition: CR95HF.c:718
TickGetMsCounter
unsigned long TickGetMsCounter(void)
Get the milliseconds counter.
Definition: tick.c:137
RFID_State_Read_Echo
Definition: RFIDManager.h:149
CR95UartSendData
void CR95UartSendData(char *data, unsigned short dataLength)
Definition: CR95UartMapper.c:129
RFID_STATE_STANDBY
Definition: RFIDManager.h:78
CR95_EXT_CONNECTED
Definition: CR95UartMapper.h:66
RFIDExternalPowerMode
tRFIDPowerMode RFIDExternalPowerMode
Definition: RFIDManager.c:51
tCR95HFCtrl::resultCode
unsigned long resultCode
Definition: CR95HF.h:221
tRFIDCtrl::state
tRFIDState state
Definition: RFIDManager.h:219
RFID_State_Read_WaitFieldOn
Definition: RFIDManager.h:152
tRFIDCtrl::subState
unsigned long subState
Definition: RFIDManager.h:220
CR95_SELECT_EXTERNAL
Definition: CR95UartMapper.h:56
CR95HF_RETURN_OK
Definition: CR95HF.h:182
CR95SelectDevice
void CR95SelectDevice(tCR95UartSelect device)
Select the antenna used to communicate with the SRD.
Definition: CR95UartMapper.c:79
RFID_POWERED
Definition: RFIDManager.h:65
TickMilliSecElapsedFrom
unsigned long TickMilliSecElapsedFrom(unsigned long refTimeMs)
Get the milliseconds counter.
Definition: tick.c:141
RFIDCtrl
tRFIDCtrl RFIDCtrl
Variable used to control the RFID manager.
Definition: RFIDManager.c:59
SRD_MEMORY_NBR_BLOCK
#define SRD_MEMORY_NBR_BLOCK
Define the number of block used in the SRD RFID memory.
Definition: SRDMemoryMapping.h:114
RFID_State_Read_WaitEcho
Definition: RFIDManager.h:150
RFID_RESULT_OK
Definition: RFIDManager.h:195
ButtonReadGetState
#define ButtonReadGetState()
Macro used to get the button status.
Definition: button.h:103
CR95HF_RETURN_ECHO_ERROR
Definition: CR95HF.h:183

Here is the call graph for this function:

Here is the caller graph for this function:

void RFIDWriteStateMachine | ( | void |  | ) |

Definition at line 541 of file RFIDManager.c.

References tSRDEeprom::activationDepth, tSRDEeprom::all, tRFIDCtrl::bits, BUTTON_PRESSED, ButtonWriteGetState, ChecksumByteOnShortCompute(), tSRDEeprom::checksumGenLSB, tSRDEeprom::checksumGenMSB, CR95_EXT_CONNECTED, CR95_SELECT_EXTERNAL, CR95_SELECT_INTERNAL, CR95ExtGetConnectionState(), CR95HF_IS_READY, CR95HF_RETURN_ECHO_ERROR, CR95HF_RETURN_FIELD15693_ERROR, CR95HF_RETURN_OK, CR95HF_RETURN_READ_ERROR, CR95HF_RETURN_WRITE_ERROR, CR95HFCtrl, CR95HFManagerIsReady(), CR95HFStartEcho(), CR95HFStartField15693(), CR95HFStartRead(), CR95HFStartWrite(), CR95SelectDevice(), CR95UartDisableReceiver(), CR95UartSendData(), tSRDEeprom::ctrlModule, tSRDEeprom::debug, tMemoryManagerDiving::depth, tCR95HFCtrl::deviceReg, DivingParameters, tMemoryManagerDiving::filterLSB, tSRDEeprom::filterLSB, tMemoryManagerDiving::filterMSB, tSRDEeprom::filterMSB, tRFIDCtrl::request, tRFIDCtrl::result, tCR95HFCtrl::resultCode, RFID_POWERED, RFID_RESULT_OK, RFID_RESULT_WRITE_ERROR, RFID_STATE_STANDBY, RFID_State_Write_Antenna, RFID_State_Write_Echo, RFID_State_Write_FieldOn, RFID_State_Write_Finish, RFID_State_Write_IsWritable, RFID_State_Write_Lock, RFID_State_Write_Read, RFID_State_Write_ReadSerial, RFID_State_Write_Start, RFID_State_Write_Unlock, RFID_State_Write_WaitAntenna, RFID_State_Write_WaitEcho, RFID_State_Write_WaitFieldOn, RFID_State_Write_WaitLock, RFID_State_Write_WaitRead, RFID_State_Write_WaitReadSerial, RFID_State_Write_WaitUnlock, RFID_State_Write_WaitWrite, RFID_State_Write_WaitWriteChecksum, RFID_State_Write_Write, RFID_State_Write_WriteChecksum, RFIDExternalPowerMode, RFIDInternalPowerMode, tSRDEeprom::serial0, SRD_MEMORY_NBR_BLOCK, tRFIDCtrl::state, tSRDEeprom::statusModule, tRFIDCtrl::subState, TickGetMsCounter(), and TickMilliSecElapsedFrom().

Referenced by RFIDDealer().

541 {
542 static unsigned short addr = 0;
543 static unsigned long msRef = 0;
544
545 switch(RFIDCtrl.subState) {
546
547 case RFID_State_Write_Start :
548 addr = 0;
549 RFIDCtrl.subState = RFID_State_Write_Antenna;
550
551 case RFID_State_Write_Antenna :
552 CR95SelectDevice(CR95_SELECT_EXTERNAL);
553 CR95UartDisableReceiver();
554 char data[1] = {0x55};
555 CR95UartSendData(data,1); //Try to wake up external
556 msRef = TickGetMsCounter();
557 RFIDCtrl.subState = RFID_State_Write_WaitAntenna;
558 break;
559
560 case RFID_State_Write_WaitAntenna :
561 if(TickMilliSecElapsedFrom(msRef)>10) {
562 if(CR95ExtGetConnectionState() == CR95_EXT_CONNECTED) {
563 CR95SelectDevice(CR95_SELECT_EXTERNAL);
564 RFIDExternalPowerMode = RFID_POWERED;
565 } else {
566 CR95SelectDevice(CR95_SELECT_INTERNAL);
567 RFIDInternalPowerMode = RFID_POWERED;
568 }
569 RFIDCtrl.subState = RFID_State_Write_Echo;
570 }
571 break;
572
573 case RFID_State_Write_Echo :
574 CR95HFStartEcho();
575 RFIDCtrl.subState = RFID_State_Write_WaitEcho;
576 break;
577
578 case RFID_State_Write_WaitEcho :
579 if(CR95HFManagerIsReady() == CR95HF_IS_READY) {
580 if(CR95HFCtrl.resultCode == CR95HF_RETURN_OK) {
581 RFIDCtrl.subState = RFID_State_Write_FieldOn;
582 } else if (CR95HFCtrl.resultCode == CR95HF_RETURN_ECHO_ERROR) {
583 RFIDCtrl.subState = RFID_State_Write_Finish;
584 RFIDCtrl.result = RFID_RESULT_WRITE_ERROR;
585 }
586 }
587 break;
588
589 case RFID_State_Write_FieldOn :
590 CR95HFStartField15693();
591 RFIDCtrl.subState = RFID_State_Write_WaitFieldOn;
592 break;
593
594 case RFID_State_Write_WaitFieldOn :
595 if(CR95HFManagerIsReady() == CR95HF_IS_READY) {
596 if(CR95HFCtrl.resultCode == CR95HF_RETURN_OK) {
597 RFIDCtrl.subState = RFID_State_Write_ReadSerial;
598 } else if (CR95HFCtrl.resultCode == CR95HF_RETURN_FIELD15693_ERROR) {
599 RFIDCtrl.subState = RFID_State_Write_Finish;
600 RFIDCtrl.result = RFID_RESULT_WRITE_ERROR;
601 }
602 }
603 break;
604
605 case RFID_State_Write_ReadSerial :
606 CR95HFStartRead(addr);
607 RFIDCtrl.subState = RFID_State_Write_WaitReadSerial;
608 break;
609
610 case RFID_State_Write_WaitReadSerial :
611 if(CR95HFManagerIsReady() == CR95HF_IS_READY) {
612 if(CR95HFCtrl.resultCode == CR95HF_RETURN_OK) {
613 *(((unsigned long*)&SRDEeprom) + addr ) = CR95HFCtrl.deviceReg;
614 if(addr < 7) {
615 addr++;
616 RFIDCtrl.subState = RFID_State_Write_ReadSerial;
617 } else {
618 RFIDCtrl.subState = RFID_State_Write_IsWritable;
619 }
620 } else if (CR95HFCtrl.resultCode == CR95HF_RETURN_READ_ERROR) {
621 RFIDCtrl.subState = RFID_State_Write_Finish;
622 RFIDCtrl.result = RFID_RESULT_WRITE_ERROR;
623 }
624 }
625 break;
626
627 case RFID_State_Write_IsWritable :
628 if(SRDEeprom.statusModule.all != 0) {
629 RFIDCtrl.subState = RFID_State_Write_Finish;
630 RFIDCtrl.result = RFID_RESULT_WRITE_ERROR;
631 } else {
632 RFIDCtrl.subState = RFID_State_Write_Lock;
633 }
634 break;
635
636 case RFID_State_Write_Lock :
637 SRDEeprom.ctrlModule.all = 0x01;
638 CR95HFStartWrite(0,*((unsigned long*)&SRDEeprom) );
639 RFIDCtrl.subState = RFID_State_Write_WaitLock;
640 break;
641
642 case RFID_State_Write_WaitLock :
643 if(CR95HFManagerIsReady() == CR95HF_IS_READY) {
644 if(CR95HFCtrl.resultCode == CR95HF_RETURN_OK) {
645 RFIDCtrl.subState = RFID_State_Write_Write;
646 } else if (CR95HFCtrl.resultCode == CR95HF_RETURN_WRITE_ERROR) {
647 RFIDCtrl.subState = RFID_State_Write_Finish;
648 RFIDCtrl.result = RFID_RESULT_WRITE_ERROR;
649 }
650 }
651 break;
652
653 case RFID_State_Write_Write :
654
655 SRDEeprom.debug = 0;
656 SRDEeprom.activationDepth = DivingParameters.depth;
657 SRDEeprom.filterMSB = DivingParameters.filterMSB;
658 SRDEeprom.filterLSB = DivingParameters.filterLSB;
659
660 unsigned short checksum = ChecksumByteOnShortCompute(&SRDEeprom.serial0,10);
661 checksum += DivingParameters.depth;
662 checksum += DivingParameters.filterMSB;
663 checksum += DivingParameters.filterLSB;
664
665 SRDEeprom.checksumGenMSB = (unsigned char)((checksum >> 8) & 0x00FF);
666 SRDEeprom.checksumGenLSB = (unsigned char)((checksum >> 0) & 0x00FF);
667
668 CR95HFStartWrite(1,*( ((unsigned long*)&SRDEeprom) + 1) );
669 RFIDCtrl.subState = RFID_State_Write_WaitWrite;
670 break;
671
672
673 case RFID_State_Write_WaitWrite :
674 if(CR95HFManagerIsReady() == CR95HF_IS_READY) {
675 if(CR95HFCtrl.resultCode == CR95HF_RETURN_OK) {
676 RFIDCtrl.subState = RFID_State_Write_WriteChecksum;
677 } else if (CR95HFCtrl.resultCode == CR95HF_RETURN_WRITE_ERROR) {
678 RFIDCtrl.subState = RFID_State_Write_Unlock; //Make sure to unlock
679 RFIDCtrl.result = RFID_RESULT_WRITE_ERROR;
680 }
681 }
682 break;
683
684 case RFID_State_Write_WriteChecksum :
685 CR95HFStartWrite(7,*( ((unsigned long*)&SRDEeprom) + 7) );
686 RFIDCtrl.subState = RFID_State_Write_WaitWriteChecksum;
687 break;
688
689 case RFID_State_Write_WaitWriteChecksum :
690 if(CR95HFManagerIsReady() == CR95HF_IS_READY) {
691 if(CR95HFCtrl.resultCode == CR95HF_RETURN_OK) {
692 RFIDCtrl.subState = RFID_State_Write_Unlock;
693 } else if (CR95HFCtrl.resultCode == CR95HF_RETURN_WRITE_ERROR) {
694 RFIDCtrl.subState = RFID_State_Write_Unlock; //Make sure to unlock
695 RFIDCtrl.result = RFID_RESULT_WRITE_ERROR;
696 }
697 }
698 break;
699
700 case RFID_State_Write_Unlock :
701 SRDEeprom.ctrlModule.all = 0x00;
702 CR95HFStartWrite(0,*((unsigned long*)&SRDEeprom) );
703 RFIDCtrl.subState = RFID_State_Write_WaitUnlock;
704 break;
705
706 case RFID_State_Write_WaitUnlock :
707 if(CR95HFManagerIsReady() == CR95HF_IS_READY) {
708 if(CR95HFCtrl.resultCode == CR95HF_RETURN_OK) {
709 if(RFIDCtrl.result == RFID_RESULT_WRITE_ERROR) {
710 RFIDCtrl.subState = RFID_State_Write_Finish;
711 } else {
712 RFIDCtrl.subState = RFID_State_Write_Read;
713 addr = 0;
714 }
715 } else if (CR95HFCtrl.resultCode == CR95HF_RETURN_WRITE_ERROR) {
716 RFIDCtrl.subState = RFID_State_Write_Finish;
717 RFIDCtrl.result = RFID_RESULT_WRITE_ERROR;
718 }
719 }
720 break;
721
722 case RFID_State_Write_Read :
723 CR95HFStartRead(addr);
724 RFIDCtrl.subState = RFID_State_Write_WaitRead;
725 break;
726
727 case RFID_State_Write_WaitRead :
728 if(CR95HFManagerIsReady() == CR95HF_IS_READY) {
729 if(CR95HFCtrl.resultCode == CR95HF_RETURN_OK) {
730 *(((unsigned long*)&SRDEeprom) + addr ) = CR95HFCtrl.deviceReg;
731 if(addr < (SRD_MEMORY_NBR_BLOCK-1)) {
732 addr++;
733 RFIDCtrl.subState = RFID_State_Write_Read;
734 } else {
735 RFIDCtrl.subState = RFID_State_Write_Finish;
736 }
737 } else if (CR95HFCtrl.resultCode == CR95HF_RETURN_READ_ERROR) {
738 RFIDCtrl.subState = RFID_State_Write_Finish;
739 RFIDCtrl.result = RFID_RESULT_WRITE_ERROR;
740 }
741 }
742 break;
743
744
745 case RFID_State_Write_Finish :
746 if(RFIDCtrl.result != RFID_RESULT_OK && ButtonWriteGetState() == BUTTON_PRESSED) {
747 RFIDCtrl.result = RFID_RESULT_OK;
748 RFIDCtrl.subState = RFID_State_Write_Echo;
749 } else {
750 RFIDCtrl.request.bits.write = 0;
751 RFIDCtrl.state = RFID_STATE_STANDBY;
752 }
753 break;
754
755 default :
756 RFIDCtrl.subState = RFID_State_Write_Start;
757 break;
758 }
759 }
RFID_State_Write_WaitWrite
Definition: RFIDManager.h:178
RFID_State_Write_WaitAntenna
Definition: RFIDManager.h:167
RFID_State_Write_WaitEcho
Definition: RFIDManager.h:169
CR95ExtGetConnectionState
tCR95ExternalConnexion CR95ExtGetConnectionState(void)
Return the connection state of the CR95HF module.
Definition: CR95UartMapper.c:174
SRDEeprom
tSRDEeprom SRDEeprom
Definition: RFIDManager.c:61
tMemoryManagerDiving::filterLSB
unsigned char filterLSB
Definition: MemoryManager.h:90
CR95HF_RETURN_WRITE_ERROR
Definition: CR95HF.h:188
tRFIDCtrl::bits
struct tRFIDCtrl::@6::@7 bits
tSRDEeprom::serial0
unsigned char serial0
Definition: SRDMemoryMapping.h:183
CR95HF_RETURN_FIELD15693_ERROR
Definition: CR95HF.h:185
tCR95HFCtrl::deviceReg
unsigned long deviceReg
Definition: CR95HF.h:223
RFID_State_Write_WaitWriteChecksum
Definition: RFIDManager.h:180
RFID_State_Write_WriteChecksum
Definition: RFIDManager.h:179
RFID_State_Write_WaitFieldOn
Definition: RFIDManager.h:171
RFID_State_Write_WaitUnlock
Definition: RFIDManager.h:182
BUTTON_PRESSED
Definition: button.h:67
ChecksumByteOnShortCompute
unsigned short ChecksumByteOnShortCompute(unsigned char *data, unsigned long dataLength)
Definition: checksum.c:111
RFID_State_Write_Lock
Definition: RFIDManager.h:175
CR95HFStartField15693
void CR95HFStartField15693(void)
Definition: CR95HF.c:655
tSRDEeprom::checksumGenMSB
unsigned char checksumGenMSB
Definition: SRDMemoryMapping.h:193
CR95HF_RETURN_READ_ERROR
Definition: CR95HF.h:187
tRFIDCtrl::result
tRFIDResultError result
Definition: RFIDManager.h:221
RFID_State_Write_WaitRead
Definition: RFIDManager.h:184
CR95HFStartRead
void CR95HFStartRead(unsigned short addr)
Definition: CR95HF.c:676
CR95HFCtrl
tCR95HFCtrl CR95HFCtrl
Variable used by the state machine of the CR95HF.
Definition: CR95HF.c:67
tSRDEeprom::debug
unsigned char debug
Definition: SRDMemoryMapping.h:167
tRFIDCtrl::request
union tRFIDCtrl::@6 request
CR95_SELECT_INTERNAL
Definition: CR95UartMapper.h:55
RFID_State_Write_WaitReadSerial
Definition: RFIDManager.h:173
RFID_RESULT_WRITE_ERROR
Definition: RFIDManager.h:198
CR95HFStartEcho
void CR95HFStartEcho(void)
Manager used to deal each specific state.
Definition: CR95HF.c:635
DivingParameters
tMemoryManagerDiving DivingParameters
Variable used to control the diving parameters.
Definition: MemoryManager.c:54
tSRDEeprom::ctrlModule
union tSRDEeprom::@8 ctrlModule
tSRDEeprom::filterMSB
unsigned char filterMSB
Definition: SRDMemoryMapping.h:169
RFID_State_Write_FieldOn
Definition: RFIDManager.h:170
CR95UartDisableReceiver
void CR95UartDisableReceiver(void)
Definition: CR95UartMapper.c:119
RFID_State_Write_Read
Definition: RFIDManager.h:183
RFIDInternalPowerMode
tRFIDPowerMode RFIDInternalPowerMode
Definition: RFIDManager.c:50
CR95HF_IS_READY
Definition: CR95HF.h:236
CR95HFManagerIsReady
tCR95HFIsReady CR95HFManagerIsReady(void)
Return the current state of the CR95HF module in it's manager.
Definition: CR95HF.c:718
TickGetMsCounter
unsigned long TickGetMsCounter(void)
Get the milliseconds counter.
Definition: tick.c:137
RFID_State_Write_Unlock
Definition: RFIDManager.h:181
tSRDEeprom::all
unsigned char all
Definition: SRDMemoryMapping.h:141
CR95UartSendData
void CR95UartSendData(char *data, unsigned short dataLength)
Definition: CR95UartMapper.c:129
RFID_STATE_STANDBY
Definition: RFIDManager.h:78
tMemoryManagerDiving::depth
unsigned char depth
Definition: MemoryManager.h:88
CR95_EXT_CONNECTED
Definition: CR95UartMapper.h:66
tSRDEeprom::filterLSB
unsigned char filterLSB
Definition: SRDMemoryMapping.h:170
tSRDEeprom::statusModule
union tSRDEeprom::@9 statusModule
RFIDExternalPowerMode
tRFIDPowerMode RFIDExternalPowerMode
Definition: RFIDManager.c:51
tCR95HFCtrl::resultCode
unsigned long resultCode
Definition: CR95HF.h:221
RFID_State_Write_IsWritable
Definition: RFIDManager.h:174
CR95HFStartWrite
void CR95HFStartWrite(unsigned short addr, unsigned long data)
Definition: CR95HF.c:687
RFID_State_Write_Write
Definition: RFIDManager.h:177
tMemoryManagerDiving::filterMSB
unsigned char filterMSB
Definition: MemoryManager.h:89
tSRDEeprom::checksumGenLSB
unsigned char checksumGenLSB
Definition: SRDMemoryMapping.h:194
RFID_State_Write_Start
Definition: RFIDManager.h:165
tRFIDCtrl::state
tRFIDState state
Definition: RFIDManager.h:219
RFID_State_Write_Echo
Definition: RFIDManager.h:168
tRFIDCtrl::subState
unsigned long subState
Definition: RFIDManager.h:220
CR95_SELECT_EXTERNAL
Definition: CR95UartMapper.h:56
RFID_State_Write_ReadSerial
Definition: RFIDManager.h:172
CR95HF_RETURN_OK
Definition: CR95HF.h:182
RFID_State_Write_WaitLock
Definition: RFIDManager.h:176
RFID_State_Write_Antenna
Definition: RFIDManager.h:166
CR95SelectDevice
void CR95SelectDevice(tCR95UartSelect device)
Select the antenna used to communicate with the SRD.
Definition: CR95UartMapper.c:79
RFID_POWERED
Definition: RFIDManager.h:65
TickMilliSecElapsedFrom
unsigned long TickMilliSecElapsedFrom(unsigned long refTimeMs)
Get the milliseconds counter.
Definition: tick.c:141
RFIDCtrl
tRFIDCtrl RFIDCtrl
Variable used to control the RFID manager.
Definition: RFIDManager.c:59
ButtonWriteGetState
#define ButtonWriteGetState()
Macro used to get the button status.
Definition: button.h:104
RFID_State_Write_Finish
Definition: RFIDManager.h:185
SRD_MEMORY_NBR_BLOCK
#define SRD_MEMORY_NBR_BLOCK
Define the number of block used in the SRD RFID memory.
Definition: SRDMemoryMapping.h:114
tSRDEeprom::activationDepth
unsigned char activationDepth
Definition: SRDMemoryMapping.h:168
RFID_RESULT_OK
Definition: RFIDManager.h:195
CR95HF_RETURN_ECHO_ERROR
Definition: CR95HF.h:183

Here is the call graph for this function:

Here is the caller graph for this function:

## Variable Documentation

RFIDCtrl

Variable used to control the RFID manager.

Definition at line 59 of file RFIDManager.c.

Referenced by ButtonManagerDealer(), and PowerManagerLPMController().

tRFIDPowerMode RFIDExternalPowerMode = RFID_POWERED

Definition at line 51 of file RFIDManager.c.

Referenced by RFIDBridgeStateMachine(), RFIDExtLpmStateMachine(), RFIDManager(), RFIDManagerInit(), RFIDReadStateMachine(), and RFIDWriteStateMachine().

tRFIDPowerMode RFIDInternalPowerMode = RFID_POWERED

Definition at line 50 of file RFIDManager.c.

Referenced by RFIDBridgeStateMachine(), RFIDIntLpmStateMachine(), RFIDManager(), RFIDManagerInit(), RFIDReadStateMachine(), and RFIDWriteStateMachine().

tSRDEeprom SRDEeprom

Definition at line 61 of file RFIDManager.c.

Referenced by ButtonManagerDealer(), ButtonManagerDisplayRead(), and ButtonManagerDisplayWrite().