Projet CRIC / Mbed 2 deprecated CRIC_RFID

Dependencies:   mbed

Fork of CRIC_RFID by Anthony Goncalves

Files at this revision

API Documentation at this revision

Comitter:
toni
Date:
Thu Dec 18 11:28:13 2014 +0000
Parent:
3:1a298994f6ba
Commit message:
Avec interruptions

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
main.hpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Thu Dec 11 14:31:04 2014 +0000
+++ b/main.cpp	Thu Dec 18 11:28:13 2014 +0000
@@ -1,248 +1,204 @@
 #include "mbed.h"
-
-#define HEADER      0xFF
-#define RESERVED    0x00
-
-#define ANTENNA_SWITCH_OFF  0x00
-#define ANTENNA_SWITCH_ON   0x01
-
-#define READ_MODE   0x01
-#define WRITE_MODE  0x00
-
-//COMMAND
-#define RESET           0x80
-#define FIRMWARE        0x81
-#define SEEK_FOR_TAG    0x82
-#define SELECT_TAG      0x83
-#define AUTHENTICATE    0x85
-#define READ_BLOCK      0x86
-#define WRITE_BLOCK     0x89
-#define ANTENNA_POWER   0x90
-#define SET_BAUD_RATE   0x94
-
-//STATE
-#define SET_RESET           0x00
-#define SET_ANTENNA_POWER   0x01
-#define READ_TAG            0x02
+#include "main.hpp"
 
-#define SEEK                0x80
-#define AUTHENTI            0x81
-#define READ                0x82
-#define WRITE               0x83
+//------------------------ MAIN ------------------------
+bool infosDebug = false;
+bool readOrWriteMode = READ_MODE;
+DigitalOut myled(LED1);
+Serial debugPC(USBTX, USBRX);   // tx, rx   //Communication pour le debug entre le PC et le mbed
 
-//Structures
-struct DataTrame{
-    char header;
-    char reserved;
-    char length;
-    char command;
-    char data[25]; 
-};
-
-struct InfosTag{
-    char tagType;
-    char serialNumber[7];
-};
-
-struct DonneesTag{
-    char typeTrajet;
-    char direction;
-    char distance;
-    char position;
-};
-
+//------------------------ RFID ------------------------
 //Variables globales
 struct DonneesTag structDonneesTag;
-bool infosDebug = true;
-bool readOrWriteMode = READ_MODE;
-
-DigitalOut myled(LED1);
-
-Serial debugPC(USBTX, USBRX);   // tx, rx   //Communication pour le debug entre le PC et le mbed
+struct DataTrame strucTrameRx;
 Serial comRFID(p13, p14);       // tx, rx   //Communication entre le mbed et le RFID SM130
-
-//Prototypes des fonctions
-void flashingLED();
+volatile bool frameRxComplete = false;
 
-void TxFrame(unsigned char command, unsigned char lengthData, unsigned char *data);
-unsigned int RxFrame(unsigned char *dataRx);
-unsigned char calcCSUM(unsigned char lengthData, unsigned char command, unsigned char *valData);
 
 //Main
 int main() {
-    unsigned char state = SET_RESET, stateTAG = SEEK, tabDataTx[20];
-    unsigned int valRetour;
-    
-    struct DataTrame strucTrameRx;
-    struct InfosTag structInfosTag;
-    
     //Initialisation
     //debugPC.baud(19200);
     comRFID.baud(19200);
+    comRFID.attach(&RxFrameInterrupt);
     
     debugPC.printf("\n\n\n\rAttente 2 secondes...");
     wait(2);    //Attente démarrage du mbed
     debugPC.printf("\n\rHello World!\n");
     
     while(1) {
-        switch (state){
-            case SET_RESET :
-                if(infosDebug == true)
-                    debugPC.printf("\n\rCase SET_RESET");
-                TxFrame(RESET, 0x00, tabDataTx);        
-                if(comRFID.readable() == 1){
-                    valRetour = RxFrame((unsigned char*) &strucTrameRx);
-                    if((valRetour == 0) & (strucTrameRx.command == FIRMWARE))   //Response for reset = command response FIRMWARE
-                        state = SET_ANTENNA_POWER;
-                }
-                break;
-                
-            case SET_ANTENNA_POWER :
-                if(infosDebug == true)
-                    debugPC.printf("\n\rCase SET_ANTENNA_POWER");
-                tabDataTx[0] = ANTENNA_SWITCH_ON;
-                TxFrame(ANTENNA_POWER, 0x01, tabDataTx);        
-                if(comRFID.readable() == 1){
-                    valRetour = RxFrame((unsigned char*) &strucTrameRx);
-                    if((valRetour == 0) & (strucTrameRx.command == ANTENNA_POWER) & (strucTrameRx.data[0] == ANTENNA_SWITCH_ON)){
-                        state = READ_TAG;
-                        stateTAG = SEEK;
+        RFID_Module();
+        //flashingLED();
+    }
+}
+//------------------------ MAIN ------------------------
+void flashingLED() {
+    myled = 1;
+    wait(0.2);
+    myled = 0;
+    wait(0.2);
+} 
+
+//------------------------ RFID ------------------------
+void RFID_Module(){
+    unsigned char static state = SET_RESET, stateTAG = SEEK;
+    unsigned char tabDataTx[25];
+    unsigned int valRetour;
+    
+    struct InfosTag structInfosTag;
+    
+    switch (state){
+        case SET_RESET :
+            if(infosDebug == true)
+                debugPC.printf("\n\rCase SET_RESET");
+            TxFrame(RESET, 0x00, tabDataTx);      
+            //debugPC.printf("\n\r\t\t\tframeRxComplete0 = %02x", frameRxComplete);
+            while(frameRxComplete == false);
+            frameRxComplete = false; 
+            //debugPC.printf("\n\r\t\t\tframeRxComplete1 = %02x \tcmd = %02x", frameRxComplete, strucTrameRx.command);
+            if(strucTrameRx.command == FIRMWARE)  //Response for reset = command response FIRMWARE
+                state = SET_ANTENNA_POWER;
+            break;
+            
+        case SET_ANTENNA_POWER :
+            if(infosDebug == true)
+                debugPC.printf("\n\rCase SET_ANTENNA_POWER");
+            tabDataTx[0] = ANTENNA_SWITCH_ON;
+            TxFrame(ANTENNA_POWER, 0x01, tabDataTx); 
+            while(frameRxComplete == false); 
+            frameRxComplete = false;      
+            if((strucTrameRx.command == ANTENNA_POWER) & (strucTrameRx.data[0] == ANTENNA_SWITCH_ON)){
+                state = READ_TAG;
+                stateTAG = SEEK;
+            }
+            break;
+            
+        case READ_TAG :
+            if(infosDebug == true)
+                debugPC.printf("\n\rCase READ_TAG");
+            
+            switch (stateTAG){
+                case SEEK :
+                    if(infosDebug == true)
+                        debugPC.printf("\tSEEK");
+                    TxFrame(SEEK_FOR_TAG, 0x00, tabDataTx);      
+                    while(frameRxComplete == false);
+                    frameRxComplete = false; 
+                    if(strucTrameRx.command == SEEK_FOR_TAG){
+                        if((strucTrameRx.length == 0x02) & (strucTrameRx.data[0] == 0x55)){
+                            state = SET_ANTENNA_POWER;
+                            stateTAG = SEEK;
+                        }
+                        else if(strucTrameRx.length == 0x06){
+                            structInfosTag.tagType = strucTrameRx.data[0];
+                            for(unsigned int cpt = 1; cpt < strucTrameRx.length - 1; cpt++)
+                                structInfosTag.serialNumber[cpt-1] = strucTrameRx.data[cpt];
+                            stateTAG = AUTHENTI;
+                        }
                     }
-                }
-                break;
-                
-            case READ_TAG :
-                if(infosDebug == true)
-                    debugPC.printf("\n\rCase READ_TAG");
+                    break;
                 
-                switch (stateTAG){
-                    case SEEK :
-                        if(infosDebug == true)
-                            debugPC.printf("\tSEEK");
-                        TxFrame(SEEK_FOR_TAG, 0x00, tabDataTx);        
-                        if(comRFID.readable() == 1){
-                            valRetour = RxFrame((unsigned char*) &strucTrameRx);
-                            if((valRetour == 0) & (strucTrameRx.command == SEEK_FOR_TAG)){
-                                if((strucTrameRx.length == 0x02) & (strucTrameRx.data[0] == 0x55)){
-                                    state = SET_ANTENNA_POWER;
-                                    stateTAG - SEEK;
-                                }
-                                else if(strucTrameRx.length == 0x06){
-                                    structInfosTag.tagType = strucTrameRx.data[0];
-                                    for(unsigned int cpt = 1; cpt < strucTrameRx.length - 1; cpt++)
-                                        structInfosTag.serialNumber[cpt-1] = strucTrameRx.data[cpt];
-                                    stateTAG = AUTHENTI;
-                                }
+                case AUTHENTI :
+                    if(infosDebug == true)
+                        debugPC.printf("\tAUTHENTI");
+                    tabDataTx[0] = 0x01;
+                    tabDataTx[1] = 0xFF;
+                    TxFrame(AUTHENTICATE, 0x02, tabDataTx);             
+                    while(frameRxComplete == false);
+                    frameRxComplete = false; 
+                    if(strucTrameRx.command == AUTHENTICATE){
+                        if(strucTrameRx.data[0] == 0x4C){   //Login Successful
+                            if(readOrWriteMode == READ_MODE)
+                                stateTAG = READ;
+                            else if (readOrWriteMode == WRITE_MODE)
+                                stateTAG = WRITE;
+                        }
+                        else 
+                            stateTAG = SEEK;
+                    }
+                    else 
+                        stateTAG = SEEK;
+                    break;
+                
+                case READ :
+                    if(infosDebug == true)
+                        debugPC.printf("\tREAD");
+                    tabDataTx[0] = 0x00;
+                    TxFrame(READ_BLOCK, 0x01, tabDataTx);             
+                    while(frameRxComplete == false); 
+                    frameRxComplete = false; 
+                    if(strucTrameRx.command == READ_BLOCK){
+                        if(strucTrameRx.length == 0x12){   //Read SUCCESS
+                            if(infosDebug == true)
+                                debugPC.printf("\tSUCCESS");
+                            //on recupere les données du tag
+                            structDonneesTag.typeTrajet = strucTrameRx.data[0];
+                            structDonneesTag.direction = strucTrameRx.data[1];
+                            structDonneesTag.distance = strucTrameRx.data[2];
+                            structDonneesTag.position = strucTrameRx.data[4];
+                            if(infosDebug == true){
+                                debugPC.printf("\r\nTypeTrajet :\t%02x", strucTrameRx.data[0]);
+                                debugPC.printf("\r\nDirection :\t%02x", strucTrameRx.data[1]);
+                                debugPC.printf("\r\nDistance :\t%02x", strucTrameRx.data[2]);
+                                debugPC.printf("\r\nPosition :\t%02x", strucTrameRx.data[4]);
                             }
                         }
-                        break;
-                    
-                    case AUTHENTI :
-                        if(infosDebug == true)
-                            debugPC.printf("\tAUTHENTI");
-                        tabDataTx[0] = 0x01;
-                        tabDataTx[1] = 0xFF;
-                        TxFrame(AUTHENTICATE, 0x02, tabDataTx);        
-                        if(comRFID.readable() == 1){
-                            valRetour = RxFrame((unsigned char*) &strucTrameRx);
-                            if((valRetour == 0) & (strucTrameRx.command == AUTHENTICATE)){
-                                if(strucTrameRx.data[0] == 0x4C){   //Login Successful
-                                    if(readOrWriteMode == READ_MODE)
-                                        stateTAG = READ;
-                                    else if (readOrWriteMode == WRITE_MODE)
-                                        stateTAG = WRITE;
-                                }
-                                else 
-                                    stateTAG = SEEK;
-                            }
-                            else 
-                                stateTAG = SEEK;
+                        else {
+                            if(infosDebug == true)
+                                debugPC.printf("\tFAIL");
                         }
-                        break;
+                    }
+                    stateTAG = SEEK;
+                    break;
                     
-                    case READ :
-                        if(infosDebug == true)
-                            debugPC.printf("\tREAD");
-                        tabDataTx[0] = 0x00;
-                        TxFrame(READ_BLOCK, 0x01, tabDataTx);        
-                        if(comRFID.readable() == 1){
-                            valRetour = RxFrame((unsigned char*) &strucTrameRx);
-                            if((valRetour == 0) & (strucTrameRx.command == READ_BLOCK)){
-                                if(strucTrameRx.length == 0x12){   //Read SUCCESS
-                                    if(infosDebug == true)
-                                        debugPC.printf("\tSUCCESS");
-                                    //on recupere les données du tag
-                                    structDonneesTag.typeTrajet = strucTrameRx.data[0];
-                                    structDonneesTag.direction = strucTrameRx.data[1];
-                                    structDonneesTag.distance = strucTrameRx.data[2];
-                                    structDonneesTag.position = strucTrameRx.data[4];
-                                    if(infosDebug == true){
-                                        debugPC.printf("\r\nTypeTrajet :\t%02x", strucTrameRx.data[0]);
-                                        debugPC.printf("\r\nDirection :\t%02x", strucTrameRx.data[1]);
-                                        debugPC.printf("\r\nDistance :\t%02x", strucTrameRx.data[2]);
-                                        debugPC.printf("\r\nPosition :\t%02x", strucTrameRx.data[4]);
-                                    }
-                                }
-                                else {
-                                    if(infosDebug == true)
-                                        debugPC.printf("\tFAIL");
-                                }
+                case WRITE :
+                    if(infosDebug == true)
+                        debugPC.printf("\tWRITE");
+                        
+                    tabDataTx[0] = 0x01;    //TYPE DE TRAJET
+                    tabDataTx[1] = 0x00;    //Direction
+                    tabDataTx[2] = 0x02;    //Distance
+                    tabDataTx[3] = 0x00;    //Reserved
+                    tabDataTx[4] = 0x05;    //Position
+                    tabDataTx[5] = 0x00;
+                    tabDataTx[6] = 0x00;
+                    tabDataTx[7] = 0x00;
+                    tabDataTx[8] = 0x00;
+                    tabDataTx[9] = 0x00;
+                    tabDataTx[10] = 0x00;   //Version
+                    tabDataTx[11] = 0x02;   //Type carte
+                    tabDataTx[12] = 'C';
+                    tabDataTx[13] = 'R';
+                    tabDataTx[14] = 'I';
+                    tabDataTx[15] = 'C';
+                    TxFrame(WRITE_BLOCK, 0x0F, tabDataTx);             
+                    while(frameRxComplete == false);
+                    frameRxComplete = false; 
+                    if(strucTrameRx.command == WRITE_BLOCK){
+                        if(strucTrameRx.length == 0x12){   //Read SUCCESS
+                            if(infosDebug == true)
+                                debugPC.printf("\tSUCCESS");
+                            //on recupere les données du tag
+                            structDonneesTag.typeTrajet = strucTrameRx.data[0];
+                            structDonneesTag.direction = strucTrameRx.data[1];
+                            structDonneesTag.distance = strucTrameRx.data[2];
+                            structDonneesTag.position = strucTrameRx.data[4];
+                            if(infosDebug == true){
+                                debugPC.printf("\r\nTypeTrajet :\t%02x", strucTrameRx.data[0]);
+                                debugPC.printf("\r\nDirection :\t%02x", strucTrameRx.data[1]);
+                                debugPC.printf("\r\nDistance :\t%02x", strucTrameRx.data[2]);
+                                debugPC.printf("\r\nPosition :\t%02x", strucTrameRx.data[4]);
                             }
                         }
-                        stateTAG = SEEK;
-                        break;
-                        
-                    case WRITE :
-                        if(infosDebug == true)
-                            debugPC.printf("\tWRITE");
-                            
-                        tabDataTx[0] = 0x01;    //TYPE DE TRAJET
-                        tabDataTx[1] = 0x00;    //Direction
-                        tabDataTx[2] = 0x02;    //Distance
-                        tabDataTx[3] = 0x00;    //Reserved
-                        tabDataTx[4] = 0x05;    //Position
-                        tabDataTx[5] = 0x00;
-                        tabDataTx[6] = 0x00;
-                        tabDataTx[7] = 0x00;
-                        tabDataTx[8] = 0x00;
-                        tabDataTx[9] = 0x00;
-                        tabDataTx[10] = 0x00;   //Version
-                        tabDataTx[11] = 0x02;   //Type carte
-                        tabDataTx[12] = 'C';
-                        tabDataTx[13] = 'R';
-                        tabDataTx[14] = 'I';
-                        tabDataTx[15] = 'C';
-                        TxFrame(WRITE_BLOCK, 0x0F, tabDataTx);        
-                        if(comRFID.readable() == 1){
-                            valRetour = RxFrame((unsigned char*) &strucTrameRx);
-                            if((valRetour == 0) & (strucTrameRx.command == WRITE_BLOCK)){
-                                if(strucTrameRx.length == 0x12){   //Read SUCCESS
-                                    if(infosDebug == true)
-                                        debugPC.printf("\tSUCCESS");
-                                    //on recupere les données du tag
-                                    structDonneesTag.typeTrajet = strucTrameRx.data[0];
-                                    structDonneesTag.direction = strucTrameRx.data[1];
-                                    structDonneesTag.distance = strucTrameRx.data[2];
-                                    structDonneesTag.position = strucTrameRx.data[4];
-                                    if(infosDebug == true){
-                                        debugPC.printf("\r\nTypeTrajet :\t%02x", strucTrameRx.data[0]);
-                                        debugPC.printf("\r\nDirection :\t%02x", strucTrameRx.data[1]);
-                                        debugPC.printf("\r\nDistance :\t%02x", strucTrameRx.data[2]);
-                                        debugPC.printf("\r\nPosition :\t%02x", strucTrameRx.data[4]);
-                                    }
-                                }
-                                else {
-                                    if(infosDebug == true)
-                                        debugPC.printf("\tFAIL");
-                                }
-                            }
+                        else {
+                            if(infosDebug == true)
+                                debugPC.printf("\tFAIL");
                         }
-                        stateTAG = SEEK;
-                        break;
-                }
-                break;
-        }
-        flashingLED();
+                    }
+                    stateTAG = SEEK;
+                    break;
+            }
+            break;
     }
 }
 
@@ -253,6 +209,17 @@
     lengthData += 1;    // +1 pour ajout taille commande
     csum = calcCSUM(command, lengthData, dataTx);
     
+    //Affiche debug __________________________________________
+    debugPC.printf("\n\r\tTx : ");
+    debugPC.printf("FF ");
+    debugPC.printf("00 ");
+    debugPC.printf("%02x ", lengthData );                          
+    debugPC.printf("%02x ", command);   
+    for(cpt = 0; cpt<lengthData-1; cpt++)
+        debugPC.printf("%02x ", *(dataTx+cpt));  
+    debugPC.printf("%02x ", csum);  
+    //Affiche debug __________________________________________
+    
     comRFID.putc(0xFF);                         //HEADER
     comRFID.putc(0x00);                         //RESERVED
     comRFID.putc(lengthData );                  //LENGTH
@@ -260,19 +227,7 @@
     for(cpt = 0; cpt<lengthData-1; cpt++){      //DATA
         comRFID.putc(*(dataTx+cpt));         
     }
-    comRFID.putc(csum);                         //CSUM
-    
-    //Affiche debug __________________________________________
-    if(infosDebug == true){
-        debugPC.printf("\n\r\tTx :");
-        debugPC.printf("FF ");
-        debugPC.printf("00 ");
-        debugPC.printf("%02x ", lengthData );                          
-        debugPC.printf("%02x ", command);   
-        for(cpt = 0; cpt<lengthData-1; cpt++)
-            debugPC.printf("%02x ", *(dataTx+cpt));  
-        debugPC.printf("%02x ", csum);    
-    }
+    comRFID.putc(csum);                         //CSUM  
 }
 
 unsigned int RxFrame(unsigned char *dataRx){
@@ -318,14 +273,91 @@
         csum += *(valData + cpt);
     
     return csum;
-}    
+}     
 
-void flashingLED() {
-    myled = 1;
-    wait(0.2);
-    myled = 0;
-    wait(0.2);
-}  
+void RxFrameInterrupt() {
+    static unsigned char cptDataRxFrame = 0;    //Compteur du nombres octets recu sur la liaison
+    static unsigned char stateRxFrame = 1;      //Variable etat permetant de valider chaque octet d'une trame recue
+    unsigned char byteRx;
+    
+    byteRx = comRFID.getc();                    //Variable qui stocke chaque octet recu
+    //debugPC.printf("\n\rINTERRUPT");
+    
+    switch (stateRxFrame) {
+        case 0 :
+            //debugPC.printf("\n\rSTATE 0 : Attente frameRxComplete = false");
+            if(frameRxComplete == false)
+                stateRxFrame = 1;
+            else
+                break;
+        
+        case 1 :
+            //debugPC.printf("\n\rSTATE 1 : Attente header");
+            if (byteRx == HEADER){              //Attente et vérification de la réception du HEADER
+                strucTrameRx.header = byteRx;   //Reception HEADER
+                stateRxFrame = 2;   
+            } 
+            break;
+        
+        case 2 :
+            //debugPC.printf("\n\rSTATE 2 : Attente reserved");
+            if (byteRx == RESERVED){
+                strucTrameRx.reserved = byteRx; //Reception RESERVED
+                stateRxFrame = 3;               //Réception et vérification du RESERVED
+            }
+            break;
+        
+        case 3 :
+            strucTrameRx.length = byteRx;       //Reception LENGTH
+            //debugPC.printf("\n\rSTATE 3 : Reception length : %02x", strucTrameRx.length);
+            stateRxFrame = 4;
+            break;
+        
+        case 4 :
+            strucTrameRx.command = byteRx;      //Reception COMMAND
+            //debugPC.printf("\n\rSTATE 4 : Reception command : %02x", strucTrameRx.command);
+            stateRxFrame = 5;
+            break;
+        
+        case 5 :
+            if(cptDataRxFrame < strucTrameRx.length - 1){           //On teste si il y a des données à recuperer, on retire 1 pour la COMMAND
+                strucTrameRx.data[cptDataRxFrame] = byteRx;         //Reception DATA
+                //debugPC.printf("\n\rSTATE 5 : Reception data : %02x", strucTrameRx.data[cptDataRxFrame]);
+                cptDataRxFrame++;
+                break;
+            }
+            else{
+                cptDataRxFrame = 0;             //RAZ du compteur pour le prochain passage
+                stateRxFrame = 6;
+                //debugPC.printf("\n\rSTATE 5 : Reception data OK");
+            }
+            // Pas de break, c'est normal car il faut récuperer le csum dans l'etat 6
+            
+        case 6 :
+            //debugPC.printf("\n\rSTATE 6 : Attente csum");
+            strucTrameRx.csum = byteRx;         //Reception checksum
+            
+            unsigned char csumCalc = calcCSUM(strucTrameRx.command, strucTrameRx.length, (unsigned char*) strucTrameRx.data);     //Verification csum
+            //debugPC.printf("\n\rSTATE 6 : csum = %02x et csumCalc = %02x", strucTrameRx.csum, csumCalc);
+            if(csumCalc == strucTrameRx.csum){
+                //debugPC.printf("\n\rSTATE 6 : csum OK");
+                frameRxComplete = true;
+                
+                debugPC.printf("\n\r\tRx : ");
+                debugPC.printf("%02x ", strucTrameRx.header);
+                debugPC.printf("%02x ", strucTrameRx.reserved);
+                debugPC.printf("%02x ", strucTrameRx.length);
+                debugPC.printf("%02x ", strucTrameRx.command);
+                for(unsigned int cpt = 0; cpt < strucTrameRx.length-1; cpt++)
+                    debugPC.printf("%02x ", strucTrameRx.data[cpt]);
+                debugPC.printf("%02x ", strucTrameRx.csum);
+                
+            }
+            //debugPC.printf("\n\rSTATE 6 : OUT");
+            stateRxFrame = 1;
+            break;
+    }
+}
 
 /*
 unsigned int RxFrame(unsigned char *dataRx){
--- a/main.hpp	Thu Dec 11 14:31:04 2014 +0000
+++ b/main.hpp	Thu Dec 18 11:28:13 2014 +0000
@@ -0,0 +1,81 @@
+#ifndef MAIN_HPP
+#define MAIN_HPP
+
+/*****************************************************
+------------------------ MAIN ------------------------
+*****************************************************/
+//Prototypes des fonctions
+void flashingLED();
+
+#define READ_MODE   0x01
+#define WRITE_MODE  0x00
+
+/*****************************************************
+------------------------ MAIN ------------------------
+*****************************************************/
+
+/*****************************************************
+------------------------ RFID ------------------------
+*****************************************************/
+#define HEADER      0xFF
+#define RESERVED    0x00
+
+#define ANTENNA_SWITCH_OFF  0x00
+#define ANTENNA_SWITCH_ON   0x01
+
+
+
+//COMMAND
+#define RESET           0x80
+#define FIRMWARE        0x81
+#define SEEK_FOR_TAG    0x82
+#define SELECT_TAG      0x83
+#define AUTHENTICATE    0x85
+#define READ_BLOCK      0x86
+#define WRITE_BLOCK     0x89
+#define ANTENNA_POWER   0x90
+#define SET_BAUD_RATE   0x94
+
+//STATE
+#define SET_RESET           0x00
+#define SET_ANTENNA_POWER   0x01
+#define READ_TAG            0x02
+
+#define SEEK                0x80
+#define AUTHENTI            0x81
+#define READ                0x82
+#define WRITE               0x83
+
+//Structures
+struct DataTrame{
+    char header;
+    char reserved;
+    char length;
+    char command;
+    char data[25]; 
+    char csum;
+};
+
+struct InfosTag{
+    char tagType;
+    char serialNumber[7];
+};
+
+struct DonneesTag{
+    char typeTrajet;
+    char direction;
+    char distance;
+    char position;
+};
+
+//Prototypes des fonctions
+void RFID_Module();
+void TxFrame(unsigned char command, unsigned char lengthData, unsigned char *data);
+unsigned int RxFrame(unsigned char *dataRx);
+void RxFrameInterrupt();
+unsigned char calcCSUM(unsigned char lengthData, unsigned char command, unsigned char *valData);
+
+/*****************************************************
+------------------------ RFID ------------------------
+*****************************************************/
+#endif
\ No newline at end of file