SRD Standelone programmation box: RFIDManager.h Source File

| 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
RFIDManager.h
Go to the documentation of this file.
1 /*############################################################################################*/
2 /*############################################################################################*/
3 /**
4 * \file RFIDManager.h
5 * \author Thibaut LALUQUE 3D-Ouest
6 * \date 25/11/2014
7 * \version 1.0
8 * \brief Headerfile for RFID management.
9 * \details All Right Reserved.
10 */
11 /*############################################################################################*/
12 /*############################################################################################*/
13 #ifndef __RFIDMANAGER_H__
14 #define __RFIDMANAGER_H__
15
16 /*############################################################################################*/
17 /*## INCLUDES ################################################################################*/
18 /*############################################################################################*/
19 #include "CR95HF.h"
20 #include "PowerManager.h"
21 #include "SRDMemoryMapping.h"
22 #include "UsbManager.h"
23 /*############################################################################################*/
24 /*## END INCLUDES ############################################################################*/
25 /*############################################################################################*/
26
27
28 /*############################################################################################*/
29 /*## DEFINES #################################################################################*/
30 /*############################################################################################*/
31 /*----------------------------------------------------------------------------*/
32 /**
33 * \def RFIDMANAGER_BRIDGE_MAX_COMMAND_LENGTH
34 * \brief Define the maximum length of a command send to the RFID bridge.
35 */
36 /*----------------------------------------------------------------------------*/
37 #define RFIDMANAGER_BRIDGE_MAX_COMMAND_LENGTH (64U)
38 /*############################################################################################*/
39 /*## END DEFINES #############################################################################*/
40 /*############################################################################################*/
41
42
43
44 /*############################################################################################*/
45 /*## TYPEDEF/STRUCT/ENUM/UNION ###############################################################*/
46 /*############################################################################################*/
47 /*----------------------------------------------------------------------------*/
48 /**
49 * \enum tRFIDLpm
50 * \brief Define RFID low power mode.
51 */
52 /*----------------------------------------------------------------------------*/
53 typedef enum {
54 RFID_READY_FOR_LPM = 1, /*!< RFID Low Power mode */
55 RFID_WORKING = 0 /*!<RFID working mode */
56 }tRFIDLpm;
57
58 /*----------------------------------------------------------------------------*/
59 /**
60 * \enum tRFIDPowerMode
61 * \brief Define RFID power mode.
62 */
63 /*----------------------------------------------------------------------------*/
64 typedef enum {
65 RFID_POWERED, /*!< RFID powered */
66 RFID_HIBERNATE /*!< RFID hibernate */
67 }tRFIDPowerMode;
68
69 /*----------------------------------------------------------------------------*/
70 /**
71 * \enum tRFIDState
72 * \brief Define RFID global state.
73 */
74 /*----------------------------------------------------------------------------*/
75 typedef enum {
76 RFID_STATE_LOW_POWER_INT = 1, /*!< Initiate internal CR95HF communication state */
77 RFID_STATE_LOW_POWER_EXT = 2, /*!< initiatee external CR95HF communication state */
78 RFID_STATE_STANDBY = 4, /*!< Standby state */
79 RFID_STATE_WRITE = 8, /*!< write state */
80 RFID_STATE_READ = 16, /*!< read state */
81 RFID_STATE_BRIDGE = 32 /*!< Bridge state */
82 }tRFIDState;
83
84 /*----------------------------------------------------------------------------*/
85 /**
86 * \enum tRFIDStateIntLPM
87 * \brief Define internal low power mode state.
88 */
89 /*----------------------------------------------------------------------------*/
90 typedef enum {
91 RFID_State_IntLpm_Start, /*!< Start */
92 RFID_State_IntLpm_Echo, /*!< Send echo */
93 RFID_State_IntLpm_WaitEcho, /*!< Wait echo */
94 RFID_State_IntLpm_FieldOff, /*!< Field off */
95 RFID_State_IntLpm_WaitFieldOff, /*!< Wait field off */
96 RFID_State_IntLpm_Hibernate, /*!< hibernate */
97 RFID_State_IntLpm_WaitHibernate, /*!< Wait hibernate */
98 RFID_State_IntLpm_Finish /*!< Finish */
99 }tRFIDStateIntLPM;
100
101 /*----------------------------------------------------------------------------*/
102 /**
103 * \enum tRFIDStateExtLPM
104 * \brief Define external low power mode state.
105 */
106 /*----------------------------------------------------------------------------*/
107 typedef enum {
108 RFID_State_ExtLpm_Start, /*!< Start */
109 RFID_State_ExtLpm_Echo, /*!< Send echo */
110 RFID_State_ExtLpm_WaitEcho, /*!< Wait echo */
111 RFID_State_ExtLpm_FieldOff, /*!< Field off */
112 RFID_State_ExtLpm_WaitFieldOff, /*!< Wait field off */
113 RFID_State_ExtLpm_Hibernate, /*!< hibernate */
114 RFID_State_ExtLpm_WaitHibernate,/*!< Wait hibernate */
115 RFID_State_ExtLpm_Finish /*!< Finish */
116 }tRFIDStateExtLPM;
117
118 /*----------------------------------------------------------------------------*/
119 /**
120 * \enum tRFIDStateBridge
121 * \brief Define bridge mode state.
122 */
123 /*----------------------------------------------------------------------------*/
124 typedef enum {
125 RFID_State_Bridge_Start, /*!< Start */
126 RFID_State_Bridge_Antenna, /*!< Antenna selection */
127 RFID_State_Bridge_WaitAntenna, /*!< Wait antenna selection */
128 RFID_State_Bridge_Echo, /*!< Send echo */
129 RFID_State_Bridge_WaitEcho, /*!< Wait echo */
130 RFID_State_Bridge_FieldOn, /*!< Field on */
131 RFID_State_Bridge_WaitFieldOn, /*!< Wait field on */
132 RFID_State_Bridge_Transfert, /*!< trnasfert data */
133 RFID_State_Bridge_WaitTransfert, /*!< Wait transfert data */
134 RFID_State_Bridge_SendResult, /*!< Send result */
135 RFID_State_Bridge_SendError, /*!< Send error */
136 RFID_State_Bridge_Finish /*!< Finish */
137 }tRFIDStateBridge;
138
139 /*----------------------------------------------------------------------------*/
140 /**
141 * \enum tRFIDStateRead
142 * \brief Define read mode state.
143 */
144 /*----------------------------------------------------------------------------*/
145 typedef enum {
146 RFID_State_Read_Start, /*!< Start */
147 RFID_State_Read_Antenna, /*!< Antenna selection */
148 RFID_State_Read_WaitAntenna, /*!< Wait antenna selection */
149 RFID_State_Read_Echo, /*!< send echo */
150 RFID_State_Read_WaitEcho, /*!< wait echo */
151 RFID_State_Read_FieldOn, /*!< field on */
152 RFID_State_Read_WaitFieldOn, /*!< wait field on */
153 RFID_State_Read_Read, /*!< read */
154 RFID_State_Read_WaitRead, /*!< wait read */
155 RFID_State_Read_Finish, /*!< finish */
156 }tRFIDStateRead;
157
158 /*----------------------------------------------------------------------------*/
159 /**
160 * \enum tRFIDStateWrite
161 * \brief Define write mode state.
162 */
163 /*----------------------------------------------------------------------------*/
164 typedef enum {
165 RFID_State_Write_Start, /*!< Start */
166 RFID_State_Write_Antenna, /*!< antenna selection */
167 RFID_State_Write_WaitAntenna, /*!< wait antenna selection */
168 RFID_State_Write_Echo, /*!< Send echo */
169 RFID_State_Write_WaitEcho, /*!< Wait echo */
170 RFID_State_Write_FieldOn, /*!< Filed on */
171 RFID_State_Write_WaitFieldOn, /*!< Wait field on */
172 RFID_State_Write_ReadSerial, /*!< Read serial */
173 RFID_State_Write_WaitReadSerial, /*!< Wait read serial */
174 RFID_State_Write_IsWritable, /*!< Check if device is writable */
175 RFID_State_Write_Lock, /*!< lock device */
176 RFID_State_Write_WaitLock, /*!< wait lock */
177 RFID_State_Write_Write, /*!< Write data */
178 RFID_State_Write_WaitWrite, /*!< Wait data written */
179 RFID_State_Write_WriteChecksum, /*!< Write checksum */
180 RFID_State_Write_WaitWriteChecksum, /*!< Wait checksum written */
181 RFID_State_Write_Unlock, /*!< unlock device */
182 RFID_State_Write_WaitUnlock, /*!< Wait unlock */
183 RFID_State_Write_Read, /*!< Read back result */
184 RFID_State_Write_WaitRead, /*!< Wait read */
185 RFID_State_Write_Finish, /*!< Finish */
186 }tRFIDStateWrite;
187
188 /*----------------------------------------------------------------------------*/
189 /**
190 * \enum tRFIDResultError
191 * \brief Define the RFID errors.
192 */
193 /*----------------------------------------------------------------------------*/
194 typedef enum {
195 RFID_RESULT_OK = 0, /*!< Result is valid */
196 RFID_RESULT_INTLPM_ERROR = 1, /*!< Internal lpm error */
197 RFID_RESULT_EXTLPM_ERROR = 2, /*!< External lpm error */
198 RFID_RESULT_WRITE_ERROR = 3, /*!< write error */
199 RFID_RESULT_READ_ERROR = 4, /*!< read error */
200 RFID_RESULT_BRIDGE_ERROR = 5 /*!< Bridge error */
201 }tRFIDResultError;
202
203 /*----------------------------------------------------------------------------*/
204 /**
205 * \struct tRFIDCtrl
206 * \brief Define a structure to control the RFID operation.
207 */
208 /*----------------------------------------------------------------------------*/
209 typedef struct {
210 union {
211 struct {
212 unsigned short write : 1; /*!< RFID write operation */
213 unsigned short read : 1; /*!< RFID read operation */
214 unsigned short bridge : 1; /*!< RFID bridge operation */
215 unsigned short RSVD : 13; /*!< RESERVED */
216 }bits; /*!< bits access */
217 unsigned short all; /*!< gloal access */
218 }request; /*!< current RFID request */
219 tRFIDState state; /*!< RFID manager global current state */
220 unsigned long subState; /*!< RFID manager sub current state */
221 tRFIDResultError result; /*!< RFID error */
222
223 tRFIDLpm lpm; /*!< RFID low power mode */
224
225 unsigned char bridgeCommand[RFIDMANAGER_BRIDGE_MAX_COMMAND_LENGTH]; /*!< Bridge command buffer */
226
227 unsigned short bridgeCommandLength; /*!< Bridge command length */
228
229 unsigned long msRef; /*!< millisenconds reference time use to control the manager */
230
231 }tRFIDCtrl;
232 /*############################################################################################*/
233 /*## END TYPEDEF/STRUCT/ENUM/UNION ###########################################################*/
234 /*############################################################################################*/
235
236
237
238 /*############################################################################################*/
239 /*## VARIABLES ###############################################################################*/
240 /*############################################################################################*/
241 /*----------------------------------------------------------------------------*/
242 /**
243 * \var RFIDCtrl
244 * \brief Variable used to control the RFID manager.
245 */
246 /*----------------------------------------------------------------------------*/
247 extern tRFIDCtrl RFIDCtrl;
248
249 /*----------------------------------------------------------------------------*/
250 /**
251 * \var RFIDCtSRDEepromrl
252 * \brief SRD eeprom memory variable used to store the copy of the SRD in communication with the box.
253 */
254 /*----------------------------------------------------------------------------*/
255 extern tSRDEeprom SRDEeprom;
256 /*############################################################################################*/
257 /*## END VARIABLES ###########################################################################*/
258 /*############################################################################################*/
259
260
261
262 /*############################################################################################*/
263 /*## DECLARATION FONCTIONS ###################################################################*/
264 /*############################################################################################*/
265 /*----------------------------------------------------------------------------*/
266 /**
267 * \fn void RFIDManagerInit (void)
268 * \brief Function used to initialize the RFID manager.
269 */
270 /*----------------------------------------------------------------------------*/
271 extern void RFIDManagerInit (void);
272
273 /*----------------------------------------------------------------------------*/
274 /**
275 * \fn void RFIDManager (void)
276 * \brief RFID manager.
277 */
278 /*----------------------------------------------------------------------------*/
279 extern void RFIDManager (void);
280
281 /*----------------------------------------------------------------------------*/
282 /**
283 * \fn signed short RFIDManagerSendBridgeCommand (char* command, unsigned short commandSize)
284 * \brief function used to send a bridge command.
285 * \param[in] command (char*) : pointer on data to send over the bridge.
286 * \param[in] commandSize (unsigned short) : data length to send over the bridge interface.
287 */
288 /*----------------------------------------------------------------------------*/
289 extern signed short RFIDManagerSendBridgeCommand (char* command, unsigned short commandSize);
290 /*############################################################################################*/
291 /*## END DECLARATION FONCTIONS ###############################################################*/
292 /*############################################################################################*/
293 #endif
RFID_State_Write_WaitWrite
Definition: RFIDManager.h:178
RFID_State_Write_WaitAntenna
Definition: RFIDManager.h:167
RFID_RESULT_READ_ERROR
Definition: RFIDManager.h:199
RFID_STATE_READ
Definition: RFIDManager.h:80
RFID_State_Read_WaitAntenna
Definition: RFIDManager.h:148
RFID_State_Write_WaitEcho
Definition: RFIDManager.h:169
RFID_State_Read_Start
Definition: RFIDManager.h:146
tRFIDStateWrite
tRFIDStateWrite
Define write mode state.
Definition: RFIDManager.h:164
RFID_State_Bridge_Start
Definition: RFIDManager.h:125
PowerManager.h
Headerfile for Power manager.
RFID_State_Read_FieldOn
Definition: RFIDManager.h:151
RFID_State_ExtLpm_Start
Definition: RFIDManager.h:108
RFID_State_Bridge_WaitTransfert
Definition: RFIDManager.h:133
tRFIDCtrl::bridgeCommandLength
unsigned short bridgeCommandLength
Definition: RFIDManager.h:227
RFID_STATE_WRITE
Definition: RFIDManager.h:79
RFID_State_ExtLpm_Hibernate
Definition: RFIDManager.h:113
RFID_State_IntLpm_Start
Definition: RFIDManager.h:91
RFID_State_Read_Read
Definition: RFIDManager.h:153
RFID_State_Bridge_FieldOn
Definition: RFIDManager.h:130
RFID_WORKING
Definition: RFIDManager.h:55
tRFIDPowerMode
tRFIDPowerMode
Define RFID power mode.
Definition: RFIDManager.h:64
RFID_State_ExtLpm_WaitEcho
Definition: RFIDManager.h:110
RFID_State_Write_WaitWriteChecksum
Definition: RFIDManager.h:180
RFID_State_Write_WriteChecksum
Definition: RFIDManager.h:179
RFIDCtrl
tRFIDCtrl RFIDCtrl
Variable used to control the RFID manager.
Definition: RFIDManager.c:59
tRFIDCtrl::lpm
tRFIDLpm lpm
Definition: RFIDManager.h:223
RFID_State_Read_Antenna
Definition: RFIDManager.h:147
tRFIDResultError
tRFIDResultError
Define the RFID errors.
Definition: RFIDManager.h:194
RFID_State_Write_WaitFieldOn
Definition: RFIDManager.h:171
RFID_State_Bridge_SendResult
Definition: RFIDManager.h:134
RFID_State_Write_WaitUnlock
Definition: RFIDManager.h:182
tRFIDStateBridge
tRFIDStateBridge
Define bridge mode state.
Definition: RFIDManager.h:124
RFID_State_IntLpm_WaitEcho
Definition: RFIDManager.h:93
tRFIDLpm
tRFIDLpm
Define RFID low power mode.
Definition: RFIDManager.h:53
RFID_State_Write_Lock
Definition: RFIDManager.h:175
RFID_HIBERNATE
Definition: RFIDManager.h:66
RFID_State_ExtLpm_Finish
Definition: RFIDManager.h:115
RFID_State_ExtLpm_Echo
Definition: RFIDManager.h:109
tRFIDCtrl::result
tRFIDResultError result
Definition: RFIDManager.h:221
tRFIDStateRead
tRFIDStateRead
Define read mode state.
Definition: RFIDManager.h:145
RFIDMANAGER_BRIDGE_MAX_COMMAND_LENGTH
#define RFIDMANAGER_BRIDGE_MAX_COMMAND_LENGTH
Define the maximum length of a command send to the RFID bridge.
Definition: RFIDManager.h:37
RFID_State_IntLpm_WaitFieldOff
Definition: RFIDManager.h:95
tRFIDCtrl::msRef
unsigned long msRef
Definition: RFIDManager.h:229
RFID_State_IntLpm_Finish
Definition: RFIDManager.h:98
RFID_State_Read_WaitRead
Definition: RFIDManager.h:154
RFID_State_Write_WaitRead
Definition: RFIDManager.h:184
RFID_State_Bridge_SendError
Definition: RFIDManager.h:135
RFID_State_ExtLpm_FieldOff
Definition: RFIDManager.h:111
RFID_State_Write_WaitReadSerial
Definition: RFIDManager.h:173
RFID_RESULT_WRITE_ERROR
Definition: RFIDManager.h:198
RFID_State_Bridge_WaitAntenna
Definition: RFIDManager.h:127
RFIDManager
void RFIDManager(void)
RFID manager.
Definition: RFIDManager.c:93
RFID_State_Bridge_Transfert
Definition: RFIDManager.h:132
RFID_State_Read_Finish
Definition: RFIDManager.h:155
tRFIDCtrl::all
unsigned short all
Definition: RFIDManager.h:217
RFID_State_Write_FieldOn
Definition: RFIDManager.h:170
RFIDManagerInit
void RFIDManagerInit(void)
Function used to initialize the RFID manager.
Definition: RFIDManager.c:79
RFID_RESULT_EXTLPM_ERROR
Definition: RFIDManager.h:197
tRFIDState
tRFIDState
Define RFID global state.
Definition: RFIDManager.h:75
RFID_State_Write_Read
Definition: RFIDManager.h:183
RFID_State_IntLpm_Echo
Definition: RFIDManager.h:92
RFID_STATE_BRIDGE
Definition: RFIDManager.h:81
RFID_State_Write_Unlock
Definition: RFIDManager.h:181
RFID_State_Read_Echo
Definition: RFIDManager.h:149
RFID_READY_FOR_LPM
Definition: RFIDManager.h:54
RFID_STATE_STANDBY
Definition: RFIDManager.h:78
tRFIDStateIntLPM
tRFIDStateIntLPM
Define internal low power mode state.
Definition: RFIDManager.h:90
SRDMemoryMapping.h
Headerfile for SRD Memory Mapping.
RFID_State_IntLpm_FieldOff
Definition: RFIDManager.h:94
RFID_STATE_LOW_POWER_EXT
Definition: RFIDManager.h:77
tSRDEeprom
Structure used to represent and store SRD RFID memory.
Definition: SRDMemoryMapping.h:130
RFID_State_Write_IsWritable
Definition: RFIDManager.h:174
RFID_State_ExtLpm_WaitFieldOff
Definition: RFIDManager.h:112
RFID_State_Write_Write
Definition: RFIDManager.h:177
RFIDManagerSendBridgeCommand
signed short RFIDManagerSendBridgeCommand(char *command, unsigned short commandSize)
function used to send a bridge command.
Definition: RFIDManager.c:763
SRDEeprom
tSRDEeprom SRDEeprom
Definition: RFIDManager.c:61
RFID_State_Write_Start
Definition: RFIDManager.h:165
RFID_State_Bridge_WaitEcho
Definition: RFIDManager.h:129
tRFIDCtrl::state
tRFIDState state
Definition: RFIDManager.h:219
RFID_State_Read_WaitFieldOn
Definition: RFIDManager.h:152
CR95HF.h
Headerfile for CR95HF driver.
RFID_State_Write_Echo
Definition: RFIDManager.h:168
RFID_STATE_LOW_POWER_INT
Definition: RFIDManager.h:76
UsbManager.h
Headerfile for Usb Uart Management (with FTDI).
tRFIDCtrl::subState
unsigned long subState
Definition: RFIDManager.h:220
RFID_State_IntLpm_Hibernate
Definition: RFIDManager.h:96
RFID_State_Write_ReadSerial
Definition: RFIDManager.h:172
RFID_State_Bridge_Finish
Definition: RFIDManager.h:136
RFID_State_Write_WaitLock
Definition: RFIDManager.h:176
RFID_State_Write_Antenna
Definition: RFIDManager.h:166
RFID_State_Bridge_WaitFieldOn
Definition: RFIDManager.h:131
RFID_State_ExtLpm_WaitHibernate
Definition: RFIDManager.h:114
tRFIDStateExtLPM
tRFIDStateExtLPM
Define external low power mode state.
Definition: RFIDManager.h:107
tRFIDCtrl
Define a structure to control the RFID operation.
Definition: RFIDManager.h:209
RFID_RESULT_INTLPM_ERROR
Definition: RFIDManager.h:196
RFID_POWERED
Definition: RFIDManager.h:65
RFID_State_Write_Finish
Definition: RFIDManager.h:185
RFID_State_Read_WaitEcho
Definition: RFIDManager.h:150
RFID_State_Bridge_Antenna
Definition: RFIDManager.h:126
RFID_RESULT_OK
Definition: RFIDManager.h:195
RFID_State_IntLpm_WaitHibernate
Definition: RFIDManager.h:97
RFID_RESULT_BRIDGE_ERROR
Definition: RFIDManager.h:200
RFID_State_Bridge_Echo
Definition: RFIDManager.h:128