FormazioneSitael / Mbed 2 deprecated I2C_PASSED

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
jjantoine
Date:
Fri Dec 21 15:38:58 2018 +0000
Commit message:
I2C

Changed in this revision

CRC/CRC32BIT_LOOKUP_Ext.h Show annotated file Show diff for this revision Revisions of this file
CRC/CRC32BIT_LOOKUP_Int.h Show annotated file Show diff for this revision Revisions of this file
CRC/CRC32BIT_LOOKUP_Md0.c Show annotated file Show diff for this revision Revisions of this file
CRC/ERROR_STD_Def.h Show annotated file Show diff for this revision Revisions of this file
CRC/TYPE_Def.h Show annotated file Show diff for this revision Revisions of this file
I2C.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/CRC/CRC32BIT_LOOKUP_Ext.h	Fri Dec 21 15:38:58 2018 +0000
@@ -0,0 +1,135 @@
+/* =======================================================================================
+ * (c)
+ * (c)                                  MEL SYSTEM S.r.l.
+ * (c)
+ * (c)                       Libreria VB32_Lib (Vital Board 32 Bit)
+ * (c)
+ * (c) La libreria VB32_Lib implementa le tutte le funzionalità necessarie per  l'utilizzo
+ * (c) dei due processori AT91SAM9 della scheda VB32. La libreria permette di gestire
+ * (c) tutte  le  periferiche  interne  (DBGU, USART, SPI, ecc..) e  tutte le  periferiche
+ * (c) esterne (HILSCHER COM-C DPM, ecc..) del processore AT91SAM9.
+ * (c)
+ * (c) ===================================================================================
+ * (c)
+ * (c)                           Copyright (C) MEL SYSTEM S.r.l.
+ * (c)
+ * (c)                             Tutti i diritti riservati.
+ * (c)
+ * (c) Questo programma e' tutelato dalle leggi sul copyright,  dalle  leggi  sui  diritti
+ * (c) d'autore e  dai  trattati  internazionali.  La  riproduzione  o  distribuzione  non
+ * (c) autorizzata di questo programma, o di parte di esso, sara' perseguibile  civilmente
+ * (c) e penalmente.
+ * (c)
+ * =======================================================================================
+ */
+
+/* =======================================================================================
+ * Informazioni del modulo
+ * =======================================================================================
+ * \brf CRC32BIT_LOOKUP
+ *
+ * \mod Il modulo CRC32BIT_LOOKUP permette di calcolare crc a 32 bit di vettori di BYTE
+ *      o di WORD utilizzando una tabella di lookup
+ *
+ * \aut Michele Giannese
+ * =======================================================================================
+ */
+
+/* =======================================================================================
+ * Elenco delle modifiche (data - autore - descrizione)
+ * =======================================================================================
+ *
+ * Ultima:
+ *
+ * 23/04/2013 - M. Giannese - creazione del modulo
+ * =======================================================================================
+ */
+
+#ifndef _CRC32BIT_LOOKUP_EXT_H
+#define _CRC32BIT_LOOKUP_EXT_H
+
+/* =======================================================================================
+ * File inclusi
+ * =======================================================================================
+ */
+#include "TYPE_Def.h"
+
+
+/* =======================================================================================
+ * Macro
+ * =======================================================================================
+ */
+
+/* =======================================================================================
+ * Definizioni
+ * =======================================================================================
+ */
+
+/* \str Struttura contenente la look-up table per il calcolo ottimizzato del CRC a 32 bit */
+typedef struct
+{
+   /* \var polynomial Crc 32 bit
+    * \val 0x00000000..0xFFFFFFFF (1) [-]
+    * \ini 0
+    */
+    UINT32_T UINT32_Poly;
+    
+   /* \var Initial value Crc 32 bit
+    * \val 0x00000000..0xFFFFFFFF (1) [-]
+    * \ini 0
+    */
+    UINT32_T UINT32_Init;
+    
+   /* \var Input reflection Crc 32 bit
+    * \val 0x00000000..0xFFFFFFFF (1) [-]
+    * \ini 0
+    */
+    BOOL_T  BOOL_RefIn;
+   /* \var Output reflection Crc 32 bit
+    * \val 0x00000000..0xFFFFFFFF (1) [-]
+    * \ini 0
+    */
+    BOOL_T  BOOL_RefOut;
+   /* \var XOR value Crc 32 bit
+    * \val 0x00000000..0xFFFFFFFF (1) [-]
+    * \ini 0
+    */
+    UINT32_T UINT32_XorOut;
+
+    /* \var Look-up Table Crc 32 bit
+    * \val 0x00000000..0xFFFFFFFF (1) [-]
+    * \ini 0
+    */
+    DWORD_T _vDWORD_CRC32LookUpTable[256];
+} CRC32BIT_LOOKUP_TS;
+
+/* =======================================================================================
+ * Prototipi delle funzioni
+ * =======================================================================================
+ */
+
+#if defined(__cplusplus)
+extern "C"
+{
+#endif /* __cplusplus */
+
+/* Restituisce il CRC PROPER a 32 bit calcolato su un vettore di byte */
+UINT32_T CRC32BIT_LOOKUP_Compute(const BYTE_T vBYTE_Data[],
+                                 const UINT32_T UINT32_DataSize,
+                                 const CRC32BIT_LOOKUP_TS *pCRCLUTable);
+
+/* Valorizza la look-up table in funzione del valore crcSettings */
+ERROR_T CRC32BIT_LOOKUP_Init(CRC32BIT_LOOKUP_TS *pCRCLUTable);
+
+/* Aggiorna e restituisce il CRC PROPER a 32 bit calcolato su un vettore di byte */
+UINT32_T CRC32BIT_LOOKUP_Update(const UINT32_T UINT32_PartialCrc,
+                                const BYTE_T vBYTE_Data[],
+                                const UINT32_T UINT32_DataSize,
+                                const BOOL_T BOOL_FirstData,
+                                const CRC32BIT_LOOKUP_TS *pCRCLUTable);
+
+#if defined(__cplusplus)
+}
+#endif /* __cplusplus */
+
+#endif /* _CRC32BIT_LOOKUP_EXT_H */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/CRC/CRC32BIT_LOOKUP_Int.h	Fri Dec 21 15:38:58 2018 +0000
@@ -0,0 +1,88 @@
+/* =======================================================================================
+ * (c)
+ * (c)                                  MEL SYSTEM S.r.l.
+ * (c)
+ * (c)                       Libreria VB32_Lib (Vital Board 32 Bit)
+ * (c)
+ * (c) La libreria VB32_Lib implementa le tutte le funzionalità necessarie per  l'utilizzo
+ * (c) dei due processori AT91SAM9 della scheda VB32. La libreria permette di gestire
+ * (c) tutte  le  periferiche  interne  (DBGU, USART, SPI, ecc..) e  tutte le  periferiche
+ * (c) esterne (HILSCHER COM-C DPM, ecc..) del processore AT91SAM9.
+ * (c)
+ * (c) ===================================================================================
+ * (c)
+ * (c)                           Copyright (C) MEL SYSTEM S.r.l.
+ * (c)
+ * (c)                             Tutti i diritti riservati.
+ * (c)
+ * (c) Questo programma e' tutelato dalle leggi sul copyright,  dalle  leggi  sui  diritti
+ * (c) d'autore e  dai  trattati  internazionali.  La  riproduzione  o  distribuzione  non
+ * (c) autorizzata di questo programma, o di parte di esso, sara' perseguibile  civilmente
+ * (c) e penalmente.
+ * (c)
+ * =======================================================================================
+ */
+
+/* =======================================================================================
+ * Elenco delle modifiche (data - autore - descrizione)
+ * =======================================================================================
+ *
+ * Ultima:
+ *
+ * 23/04/2013 - M. Giannese - creazione del modulo
+ * =======================================================================================
+ */
+
+#ifndef _CRC32_LOOKUP_INT_H
+#define _CRC32_LOOKUP_INT_H
+
+/* =======================================================================================
+ * File inclusi
+ * =======================================================================================
+ */
+
+#include "CRC32BIT_LOOKUP_Ext.h"
+#include "ERROR_STD_Def.h"
+//#include "WORD_Ext.h" 
+
+/* =======================================================================================
+ * Definizioni
+ * =======================================================================================
+ */
+
+/* \def Numero di bit in un byte */
+#define CRC32BIT_LOOKUP_NUMBITS_IN_BYTE               8
+/* \def Numero di bit in un byte */
+#define CRC32BIT_LOOKUP_NUMELEMENTS_IN_BYTE           256
+/* \def Numero di bit in una double word */
+#define CRC32BIT_LOOKUP_NUMBITS_UINT32                32
+/* \def Differenza di dimensione tra intero a 32 bit e byte */
+#define CRC32BIT_LOOKUP_AUGMENTATION                 (CRC32BIT_LOOKUP_NUMBITS_UINT32 - CRC32BIT_LOOKUP_NUMBITS_IN_BYTE)
+/* \def Maschera del bit meno significativo di una double word */
+#define CRC32BIT_LOOKUP_UINT32LSB_MASK               (UINT32_T)1
+ /* \def Maschera del bit meno significativo di un byte */
+#define CRC32BIT_LOOKUP_BYTELSB_MASK                 (BYTE_T)0x01
+/* \def Maschera del bit più significativo di una double word */
+#define CRC32BIT_LOOKUP_UINT32MSB_MASK               (UINT32_T)0x80000000
+/* \def dimensione del blocco per il calcolo veloce del CRC */
+#define CRC32BIT_LOOKUP_BLOCK_SIZE                   8
+
+#define TOPBIT                                       ((UINT32_T)(1<<(CRC32BIT_LOOKUP_NUMBITS_UINT32-1)))
+
+/* =======================================================================================
+ * Macro
+ * =======================================================================================
+ */
+
+/* =======================================================================================
+ * Prototipi delle funzioni
+ * =======================================================================================
+ */
+
+/* Riflette i bit di un byte */
+BYTE_T CRC32BIT_LOOKUP_ReflectByte(BYTE_T BYTE_Value);
+
+/* Riflette i bit di una double word */
+UINT32_T CRC32BIT_LOOKUP_ReflectUINT32(UINT32_T UINT32_Value);
+
+#endif /* _CRC32_LOOKUP_INT_H */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/CRC/CRC32BIT_LOOKUP_Md0.c	Fri Dec 21 15:38:58 2018 +0000
@@ -0,0 +1,389 @@
+/* =======================================================================================
+* (c)
+* (c)                                  MEL SYSTEM S.r.l.
+* (c)
+* (c)                       Libreria VB32_Lib (Vital Board 32 Bit)
+* (c)
+* (c) La libreria VB32_Lib implementa le tutte le funzionalit� necessarie per  l'utilizzo
+* (c) dei due processori AT91SAM9 della scheda VB32. La libreria permette di gestire
+* (c) tutte  le  periferiche  interne  (DBGU, USART, SPI, ecc..) e  tutte le  periferiche
+* (c) esterne (HILSCHER COM-C DPM, ecc..) del processore AT91SAM9.
+* (c)
+* (c) ===================================================================================
+* (c)
+* (c)                           Copyright (C) MEL SYSTEM S.r.l.
+* (c)
+* (c)                             Tutti i diritti riservati.
+* (c)
+* (c) Questo programma e' tutelato dalle leggi sul copyright,  dalle  leggi  sui  diritti
+* (c) d'autore e  dai  trattati  internazionali.  La  riproduzione  o  distribuzione  non
+* (c) autorizzata di questo programma, o di parte di esso, sara' perseguibile  civilmente
+* (c) e penalmente.
+* (c)
+* =======================================================================================
+*/
+
+/* =======================================================================================
+ * Elenco delle modifiche (data - autore - descrizione)
+ * =======================================================================================
+ *
+ * Ultima:
+ *
+ * 23/04/2013 - M. Giannese - creazione del modulo
+ * =======================================================================================
+ */
+
+/* =======================================================================================
+* File inclusi
+* =======================================================================================
+*/
+#include "CRC32BIT_LOOKUP_Int.h"
+
+/* =======================================================================================
+* Funzioni
+* =======================================================================================
+*/
+
+/* =======================================================================================
+* \fun Inizializza la struttura _CrcLUTable con i valori di CRC calcolati in funzione
+*      dei valori di crcSettings
+*
+
+* \par [in] crcSettings: struttura delle impostazioni per il calcolo del CRC
+* \val -
+*
+* \par [out] _CrcLUTable : la struttura che contiene la look up table
+* \val -
+*
+
+* =======================================================================================
+*/
+
+ERROR_T CRC32BIT_LOOKUP_Init(CRC32BIT_LOOKUP_TS *pCRCLUTable)
+{
+ERROR_T ERROR_Value = E_NULL;
+UINT32_T UINT32_elementInBytes = 0;
+UINT32_T UINT32_bitInBytes = 0;
+UINT32_T UINT32_value = 0;
+
+    /* Viene calcolata la look-up table */
+    if (pCRCLUTable->UINT32_Poly != 0)
+    {
+        for (UINT32_elementInBytes = 0; UINT32_elementInBytes < CRC32BIT_LOOKUP_NUMELEMENTS_IN_BYTE; ++UINT32_elementInBytes)
+        {
+            UINT32_value = UINT32_elementInBytes << 24;
+
+            for (UINT32_bitInBytes = CRC32BIT_LOOKUP_NUMBITS_IN_BYTE; UINT32_bitInBytes > 0; --UINT32_bitInBytes)
+            {
+                if (UINT32_value & TOPBIT)
+                {
+                    UINT32_value = (UINT32_value << 1) ^ pCRCLUTable->UINT32_Poly;
+                }
+                else
+                {
+                    UINT32_value = (UINT32_value << 1);
+                }
+            }
+
+            pCRCLUTable->_vDWORD_CRC32LookUpTable[UINT32_elementInBytes] = UINT32_value;
+        }
+
+        ERROR_Value = E_OK;
+    }
+    else
+    {
+        ERROR_Value = E_STD_INVALID_PARAM;
+    }
+    return ERROR_Value;
+}
+
+/* =======================================================================================
+* \fun Restituisce il CRC PROPER a 32 bit calcolato su un vettore di byte
+*
+* \par [in] vBYTE_Data: Puntatore al primo byte del vettore di cui calcolare il CRC
+* \val 0x00..0xFF (1) [-]
+*
+* \par [in] UINT32_DataSize: Numero di byte del vettore:
+* \val -
+*
+* \par [in] pCRCLUTable: look-up table
+* \val - [-]
+*
+* \ret il crc calcolato
+* =======================================================================================
+*/
+UINT32_T CRC32BIT_LOOKUP_Compute(const BYTE_T vBYTE_Data[],
+                                 const UINT32_T UINT32_DataSize,
+                                 const CRC32BIT_LOOKUP_TS *pCRCLUTable)
+{
+UINT32_T UINT32_Crc = 0;
+
+   /* si esegue il calcolo del CRC32 proper */
+   UINT32_Crc = CRC32BIT_LOOKUP_Update(0, vBYTE_Data, UINT32_DataSize, TRUE, pCRCLUTable);
+
+   return UINT32_Crc;
+}
+
+/* =======================================================================================
+* \fun Aggiorna e restituisce il CRC PROPER a 32 bit calcolato su un vettore di byte 
+*
+* \par [in] pSettings: Puntatore alla struttura delle impostazioni per il calcolo del CRC
+* \val -
+*
+* \par [in] UINT32_PartialCrc : Il crc da cui partire
+* \val -
+*
+* \par [in] vBYTE_Data: Puntatore al primo byte del vettore di cui calcolare il CRC
+* \val -
+*
+* \par [in] UINT32_DataSize: Numero di byte del vettore:
+* \val -
+*
+* \par [in] BOOL_FirstData: Indica che � il primo pacchetto di dati per cui si deve 
+*           utilizzare il valore di inizializzazione del CRC
+* \val -
+*
+* \par [in] BOOL_LastData: Indica che � l'ultimo pacchetto di dati per cui si deve
+*           effetture la riflessione in uscita o l'XOR finale
+* \val -
+*
+* \par [in] pCRCLUTable: look-up table
+* \val -
+*
+* \ret il crc calcolato
+* =======================================================================================
+*/
+
+UINT32_T CRC32BIT_LOOKUP_Update(const UINT32_T UINT32_PartialCrc,
+                                const BYTE_T vBYTE_Data[], 
+                                const UINT32_T UINT32_DataSize,
+                                const BOOL_T BOOL_FirstData,
+                                const CRC32BIT_LOOKUP_TS *pCRCLUTable)
+{
+UINT32_T UINT32_Crc = 0;
+UINT32_T UINT32_Idx = 0;
+UINT32_T UINT32_TableIdx = 0;
+BYTE_T   BYTE_Value = 0;
+
+   /* se si tratta del primo pacchetto dati il valore iniziale del CRC � 0xFFFFFFFF, altrimenti
+   � quello parziale ricevuto in input */
+   if (BOOL_FirstData == TRUE)
+   {
+      UINT32_Crc = pCRCLUTable->UINT32_Init;
+   }
+   else
+   {
+      UINT32_Crc = UINT32_PartialCrc;
+   }/* Fine IF */
+
+   UINT32_Idx = 0;
+
+
+   /* per migliorare le performance si riducono il numero di confronti nel while
+      effettuando i calcoli su blocchi di 8 byte */
+   while ((UINT32_DataSize - UINT32_Idx) >= CRC32BIT_LOOKUP_BLOCK_SIZE)
+   {
+       /* verifica se nei parametri di inizializzazione � stata attivata la riflessione dei byte */
+       if (pCRCLUTable->BOOL_RefIn == TRUE)
+       {
+            /* step 1 */
+            BYTE_Value = CRC32BIT_LOOKUP_ReflectByte(vBYTE_Data[UINT32_Idx]);
+            UINT32_TableIdx = (UINT32_T)(BYTE_Value ^ (UINT32_Crc >> CRC32BIT_LOOKUP_AUGMENTATION));
+            UINT32_Crc =  pCRCLUTable->_vDWORD_CRC32LookUpTable[UINT32_TableIdx] ^ (UINT32_Crc << CRC32BIT_LOOKUP_NUMBITS_IN_BYTE);
+            UINT32_Idx = UINT32_Idx + 1;
+
+            /* step 2 */
+            BYTE_Value = CRC32BIT_LOOKUP_ReflectByte(vBYTE_Data[UINT32_Idx]);
+            UINT32_TableIdx = (UINT32_T)(BYTE_Value ^ (UINT32_Crc >> CRC32BIT_LOOKUP_AUGMENTATION));
+            UINT32_Crc =  pCRCLUTable->_vDWORD_CRC32LookUpTable[UINT32_TableIdx] ^ (UINT32_Crc << CRC32BIT_LOOKUP_NUMBITS_IN_BYTE);
+            UINT32_Idx = UINT32_Idx + 1;
+
+            /* step 3 */
+            BYTE_Value = CRC32BIT_LOOKUP_ReflectByte(vBYTE_Data[UINT32_Idx]);
+            UINT32_TableIdx = (UINT32_T)(BYTE_Value ^ (UINT32_Crc >> CRC32BIT_LOOKUP_AUGMENTATION));
+            UINT32_Crc =  pCRCLUTable->_vDWORD_CRC32LookUpTable[UINT32_TableIdx] ^ (UINT32_Crc << CRC32BIT_LOOKUP_NUMBITS_IN_BYTE);
+            UINT32_Idx = UINT32_Idx + 1;
+
+            /* step 4 */
+            BYTE_Value = CRC32BIT_LOOKUP_ReflectByte(vBYTE_Data[UINT32_Idx]);
+            UINT32_TableIdx = (UINT32_T)(BYTE_Value ^ (UINT32_Crc >> CRC32BIT_LOOKUP_AUGMENTATION));
+            UINT32_Crc =  pCRCLUTable->_vDWORD_CRC32LookUpTable[UINT32_TableIdx] ^ (UINT32_Crc << CRC32BIT_LOOKUP_NUMBITS_IN_BYTE);
+            UINT32_Idx = UINT32_Idx + 1;
+
+            /* step 5 */
+            BYTE_Value = CRC32BIT_LOOKUP_ReflectByte(vBYTE_Data[UINT32_Idx]);
+            UINT32_TableIdx = (UINT32_T)(BYTE_Value ^ (UINT32_Crc >> CRC32BIT_LOOKUP_AUGMENTATION));
+            UINT32_Crc =  pCRCLUTable->_vDWORD_CRC32LookUpTable[UINT32_TableIdx] ^ (UINT32_Crc << CRC32BIT_LOOKUP_NUMBITS_IN_BYTE);
+            UINT32_Idx = UINT32_Idx + 1;
+
+            /* step 6 */
+            BYTE_Value = CRC32BIT_LOOKUP_ReflectByte(vBYTE_Data[UINT32_Idx]);
+            UINT32_TableIdx = (UINT32_T)(BYTE_Value ^ (UINT32_Crc >> CRC32BIT_LOOKUP_AUGMENTATION));
+            UINT32_Crc =  pCRCLUTable->_vDWORD_CRC32LookUpTable[UINT32_TableIdx] ^ (UINT32_Crc << CRC32BIT_LOOKUP_NUMBITS_IN_BYTE);
+            UINT32_Idx = UINT32_Idx + 1;
+
+            /* step 7 */
+            BYTE_Value = CRC32BIT_LOOKUP_ReflectByte(vBYTE_Data[UINT32_Idx]);
+            UINT32_TableIdx = (UINT32_T)(BYTE_Value ^ (UINT32_Crc >> CRC32BIT_LOOKUP_AUGMENTATION));
+            UINT32_Crc =  pCRCLUTable->_vDWORD_CRC32LookUpTable[UINT32_TableIdx] ^ (UINT32_Crc << CRC32BIT_LOOKUP_NUMBITS_IN_BYTE);
+            UINT32_Idx = UINT32_Idx + 1;
+
+            /* step 8 */
+            BYTE_Value = CRC32BIT_LOOKUP_ReflectByte(vBYTE_Data[UINT32_Idx]);
+            UINT32_TableIdx = (UINT32_T)(BYTE_Value ^ (UINT32_Crc >> CRC32BIT_LOOKUP_AUGMENTATION));
+            UINT32_Crc =  pCRCLUTable->_vDWORD_CRC32LookUpTable[UINT32_TableIdx] ^ (UINT32_Crc << CRC32BIT_LOOKUP_NUMBITS_IN_BYTE);
+            UINT32_Idx = UINT32_Idx + 1;
+       }
+       else
+       {
+           /* step 1 */
+          UINT32_TableIdx = (UINT32_T)(vBYTE_Data[UINT32_Idx] ^ (UINT32_Crc >> CRC32BIT_LOOKUP_AUGMENTATION));
+          UINT32_Crc =  pCRCLUTable->_vDWORD_CRC32LookUpTable[UINT32_TableIdx] ^ (UINT32_Crc << CRC32BIT_LOOKUP_NUMBITS_IN_BYTE);
+          UINT32_Idx = UINT32_Idx + 1;
+
+          /* step 2 */
+          UINT32_TableIdx = (UINT32_T)(vBYTE_Data[UINT32_Idx] ^ (UINT32_Crc >> CRC32BIT_LOOKUP_AUGMENTATION));
+          UINT32_Crc =  pCRCLUTable->_vDWORD_CRC32LookUpTable[UINT32_TableIdx] ^ (UINT32_Crc << CRC32BIT_LOOKUP_NUMBITS_IN_BYTE);
+          UINT32_Idx = UINT32_Idx + 1;
+
+          /* step 3 */
+          UINT32_TableIdx = (UINT32_T)(vBYTE_Data[UINT32_Idx] ^ (UINT32_Crc >> CRC32BIT_LOOKUP_AUGMENTATION));
+          UINT32_Crc =  pCRCLUTable->_vDWORD_CRC32LookUpTable[UINT32_TableIdx] ^ (UINT32_Crc << CRC32BIT_LOOKUP_NUMBITS_IN_BYTE);
+          UINT32_Idx = UINT32_Idx + 1;
+
+          /* step 4 */
+          UINT32_TableIdx = (UINT32_T)(vBYTE_Data[UINT32_Idx] ^ (UINT32_Crc >> CRC32BIT_LOOKUP_AUGMENTATION));
+          UINT32_Crc =  pCRCLUTable->_vDWORD_CRC32LookUpTable[UINT32_TableIdx] ^ (UINT32_Crc << CRC32BIT_LOOKUP_NUMBITS_IN_BYTE);
+          UINT32_Idx = UINT32_Idx + 1;
+
+          /* step 5 */
+          UINT32_TableIdx = (UINT32_T)(vBYTE_Data[UINT32_Idx] ^ (UINT32_Crc >> CRC32BIT_LOOKUP_AUGMENTATION));
+          UINT32_Crc =  pCRCLUTable->_vDWORD_CRC32LookUpTable[UINT32_TableIdx] ^ (UINT32_Crc << CRC32BIT_LOOKUP_NUMBITS_IN_BYTE);
+          UINT32_Idx = UINT32_Idx + 1;
+
+          /* step 6 */
+          UINT32_TableIdx = (UINT32_T)(vBYTE_Data[UINT32_Idx] ^ (UINT32_Crc >> CRC32BIT_LOOKUP_AUGMENTATION));
+          UINT32_Crc =  pCRCLUTable->_vDWORD_CRC32LookUpTable[UINT32_TableIdx] ^ (UINT32_Crc << CRC32BIT_LOOKUP_NUMBITS_IN_BYTE);
+          UINT32_Idx = UINT32_Idx + 1;
+
+          /* step 7 */
+          UINT32_TableIdx = (UINT32_T)(vBYTE_Data[UINT32_Idx] ^ (UINT32_Crc >> CRC32BIT_LOOKUP_AUGMENTATION));
+          UINT32_Crc =  pCRCLUTable->_vDWORD_CRC32LookUpTable[UINT32_TableIdx] ^ (UINT32_Crc << CRC32BIT_LOOKUP_NUMBITS_IN_BYTE);
+          UINT32_Idx = UINT32_Idx + 1;
+
+          /* step 8 */
+          UINT32_TableIdx = (UINT32_T)(vBYTE_Data[UINT32_Idx] ^ (UINT32_Crc >> CRC32BIT_LOOKUP_AUGMENTATION));
+          UINT32_Crc =  pCRCLUTable->_vDWORD_CRC32LookUpTable[UINT32_TableIdx] ^ (UINT32_Crc << CRC32BIT_LOOKUP_NUMBITS_IN_BYTE);
+          UINT32_Idx = UINT32_Idx + 1;
+       }/* Fine IF */
+   }/* Fine WHILE */
+
+   /* si continua con i byte rimanenti */
+   while (UINT32_Idx < UINT32_DataSize)
+   {
+       /* verifica se nei parametri di inizializzazione � stata attivata la riflessione dei byte */
+       if (pCRCLUTable->BOOL_RefIn == TRUE)
+       {
+           BYTE_Value = CRC32BIT_LOOKUP_ReflectByte(vBYTE_Data[UINT32_Idx]);
+           UINT32_TableIdx = (UINT32_T)(BYTE_Value ^ (UINT32_Crc >> CRC32BIT_LOOKUP_AUGMENTATION));
+           UINT32_Crc =  pCRCLUTable->_vDWORD_CRC32LookUpTable[UINT32_TableIdx] ^ (UINT32_Crc << CRC32BIT_LOOKUP_NUMBITS_IN_BYTE);
+           UINT32_Idx = UINT32_Idx + 1;
+       }
+       else
+       {
+           UINT32_TableIdx = (UINT32_T)(vBYTE_Data[UINT32_Idx] ^ (UINT32_Crc >> CRC32BIT_LOOKUP_AUGMENTATION));
+           UINT32_Crc = pCRCLUTable->_vDWORD_CRC32LookUpTable[UINT32_TableIdx] ^ (UINT32_Crc << CRC32BIT_LOOKUP_NUMBITS_IN_BYTE);
+           UINT32_Idx = UINT32_Idx + 1;
+       }
+   }/* Fine WHILW */
+
+   /* verifica se nei parametri di inizializzazione � attivata la riflessione in uscita */
+   if (pCRCLUTable->BOOL_RefOut == TRUE)
+   {
+        UINT32_Crc = CRC32BIT_LOOKUP_ReflectUINT32(UINT32_Crc);
+   }/* Fine IF */
+
+   UINT32_Crc = UINT32_Crc ^ pCRCLUTable->UINT32_XorOut;
+
+   return UINT32_Crc;
+}
+
+/* =======================================================================================
+* \fun Riflette i bit di un byte
+*
+* \par [in] BYTE_Value : Byte da riflettere
+* \val -
+*
+* \ret il byte riflesso
+* =======================================================================================
+*/
+BYTE_T CRC32BIT_LOOKUP_ReflectByte(BYTE_T BYTE_Value)
+{
+BYTE_T   BYTE_ReflectedValue = 0;
+BYTE_T   BYTE_Temp           = 0;
+UINT16_T UINT16_NumOfShifts  = 0;
+BYTE_T   BYTE_Mask           = 0;
+UINT16_T UINT16_Idx          = 0;
+
+   BYTE_ReflectedValue = 0;
+
+   /* cicla su tutti i bit del byte per effettuarne la riflessione */
+   UINT16_Idx = 0;
+   while (UINT16_Idx < CRC32BIT_LOOKUP_NUMBITS_IN_BYTE)
+   {
+      BYTE_Temp = (BYTE_T) (BYTE_Value >> UINT16_Idx);
+
+      if (BYTE_Temp & CRC32BIT_LOOKUP_BYTELSB_MASK)
+      {
+         UINT16_NumOfShifts = CRC32BIT_LOOKUP_NUMBITS_IN_BYTE - UINT16_Idx - 1;
+
+         BYTE_Mask = (BYTE_T) (CRC32BIT_LOOKUP_BYTELSB_MASK << UINT16_NumOfShifts);
+
+         BYTE_ReflectedValue = (BYTE_T) (BYTE_ReflectedValue ^ BYTE_Mask);
+      }/* Fine IF */
+
+      UINT16_Idx = UINT16_Idx + 1;
+   }/* Fine WHILE */
+
+   return BYTE_ReflectedValue;
+}
+
+/* =======================================================================================
+* \fun Riflette i bit di una double word
+*
+* \par [in] UINT32_Value : Double Word da riflettere
+* \val -
+*
+* \ret la double word riflessa
+* =======================================================================================
+*/
+UINT32_T CRC32BIT_LOOKUP_ReflectUINT32(UINT32_T UINT32_Value)
+{
+UINT32_T  UINT32_ReflectedValue = 0;
+UINT32_T  UINT32_Temp       = 0;
+UINT32_T  UINT32_Mask       = 0;
+UINT16_T UINT16_Idx         = 0;
+UINT16_T UINT16_NumOfShifts = 0;
+
+   UINT32_ReflectedValue = 0;
+
+   /* cicla su tutti i bit della DWORD per effettuarne la riflessione */
+   UINT16_Idx = 0;
+   while (UINT16_Idx < CRC32BIT_LOOKUP_NUMBITS_UINT32)
+   {
+      UINT32_Temp = (UINT32_Value >> UINT16_Idx);
+
+      if (UINT32_Temp & CRC32BIT_LOOKUP_UINT32LSB_MASK)
+      {
+         UINT16_NumOfShifts = CRC32BIT_LOOKUP_NUMBITS_UINT32 - UINT16_Idx - 1;
+
+         UINT32_Mask = (UINT32_T) (CRC32BIT_LOOKUP_UINT32LSB_MASK << UINT16_NumOfShifts);
+
+         UINT32_ReflectedValue = (UINT32_ReflectedValue ^ UINT32_Mask);
+      }/* Fine IF */
+
+      UINT16_Idx = UINT16_Idx + 1;
+   }/* Fine WHILE */
+
+   return UINT32_ReflectedValue;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/CRC/ERROR_STD_Def.h	Fri Dec 21 15:38:58 2018 +0000
@@ -0,0 +1,114 @@
+/* =======================================================================================
+ * (c)
+ * (c)                                  Sitael S.p.A.
+ * (c)
+ * (c)                             Componente ERROR_STD
+ * (c)
+ * (c)
+ * (c) ===================================================================================
+ * (c)
+ * (c)                            Copyright (C) Sitael S.p.A.
+ * (c)
+ * (c)                             Tutti i diritti riservati.
+ * (c)
+ * (c) Questo programma e' tutelato dalle leggi sul copyright,  dalle  leggi  sui  diritti
+ * (c) d'autore e  dai  trattati  internazionali.  La  riproduzione  o  distribuzione  non
+ * (c) autorizzata di questo programma, o di parte di esso, sara' perseguibile  civilmente
+ * (c) e penalmente.
+ * (c)
+ * =======================================================================================
+ */
+/* =======================================================================================
+ * Informazioni del modulo
+ * =======================================================================================
+ */
+ /*! \file   ERROR_STD_Def.h
+ *           Questo file definisce i codici di errore della libreria
+ *
+ *  \details Questo file definisce i codici di errore della libreria 
+ *          
+ *
+ *  \author  Orlando Petrone
+ */
+
+/* =======================================================================================
+ * Elenco delle modifiche (data - autore - descrizione)
+ * =======================================================================================
+ * Ultima:
+ *
+ * 03/11/2015 - O. Petrone - creazione del modulo
+ * =======================================================================================
+ */
+#ifndef _ERROR_STD_DEF_H
+#define _ERROR_STD_DEF_H
+
+/* =======================================================================================
+ * File inclusi
+ * =======================================================================================
+ */
+ #include "TYPE_Def.h" /* Contiene la definizione di ERROR_T */
+
+/* =======================================================================================
+ * Definizioni
+ * =======================================================================================
+ */
+
+/*! 
+ *       Codice identificativo della libreria
+ */
+#define STD_LIB_CODE                 (0x82)
+
+#define E_STD_INVALID_PARAM                  (ERROR_T) 0x01 /*!< Parametro non valido */
+#define E_STD_INVALID_STATE                  (ERROR_T) 0x02 /*!< Stato non ammesso */
+#define E_STD_NULL_POINTER                   (ERROR_T) 0x03 /*!< Puntatore nullo */
+#define E_STD_CHECKSUM                       (ERROR_T) 0x04 /*!< Checksum non valida */
+#define E_STD_SEQ_NUMBER                     (ERROR_T) 0x05 /*!< Errore di sequence counter */
+#define E_STD_MESSAGE_INVALID_SIZE           (ERROR_T) 0x06 /*!< Dimensione messaggio non valida */
+#define E_STD_DATA_MAX_SIZE                  (ERROR_T) 0x08 /*!< Errore sulla massima dimensione */
+#define E_STD_FRAME_INVALID_SIZE             (ERROR_T) 0x09 /*!< Dimensione non valida */
+#define E_STD_DECODING_FRAME                 (ERROR_T) 0x0A /*!< Errore decodifica frame */
+
+
+/*! \def MODULE_STD_ID_TE
+ *       Moduli e componenti appartenenti all'applicazione INTLOCK.
+ */
+typedef enum
+{
+   MODULE_STD_ID_IODEB           = 0x01 /*!< Modulo IODEB */
+   ,MODULE_STD_ID_NVCP           = 0x02 /*!< Modulo NVCP  */
+   ,MODULE_STD_ID_NVCPDL         = 0x03 /*!< Modulo NVCPDL  */
+   ,MODULE_STD_ID_INVALID        = 0xFF /*!< Identificativo modulo valido */ 
+
+
+} MODULE_STD_ID_TE;
+
+
+/* =======================================================================================
+ * Macro
+ * =======================================================================================
+ */
+ 
+ /*! \def ERROR_FormatAPP(ENUM_ModuleID, ERROR_Value)
+ *       Crea una parola da 32 bit con le informazioni sul modulo che ha generato l'errore 
+ *       ed il tipo d'errore.
+ * Nella formattazione degli errori si usa il seguente formato
+ * Il formato degli errori  (32 bit) e'
+ *      
+ * |   (1° byte)  |  (2° byte)|   (3° byte)  |  (4° byte)    |     
+ * |  Byte piu'   |           |              | Byte meno     |
+ * | significativo|           |              | significativo |
+ * ----------------------------------------------------------   
+ * | Application/ |  Modulo   |   Codice  Errore Rilevato    |
+ * |   Library    |           |   Modulo     |   Errore      |
+ * |              |           |   [0x0000......0xFFFF]       |
+ *
+ *  Per identificare la libreria di provenienza si aggiorna il
+ *  2° byte piu' significativo
+ */
+#define ERROR_FormatSTD(ENUM_ModuleID, ERROR_Value)   \
+   (((ERROR_T)((STD_LIB_CODE << 24) | (ENUM_ModuleID) << 16)) | (ERROR_Value))
+
+
+
+
+#endif /* _ERROR_STD_DEF_H */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/CRC/TYPE_Def.h	Fri Dec 21 15:38:58 2018 +0000
@@ -0,0 +1,305 @@
+/* =======================================================================================
+ * (c)
+ * (c)                                   Sitael S.p.A
+ * (c)
+ * (c)                                 Libreria STD_Lib 
+ * (c)
+ * (c)                           Copyright (C) Sitael S.p.A.
+ * (c)
+ * (c)                             Tutti i diritti riservati.
+ * (c)
+ * (c) Questo programma e' tutelato dalle leggi sul copyright,  dalle  leggi  sui  diritti
+ * (c) d'autore e  dai  trattati  internazionali.  La  riproduzione  o  distribuzione  non
+ * (c) autorizzata di questo programma, o di parte di esso, sara' perseguibile  civilmente
+ * (c) e penalmente.
+ * (c)
+ * =======================================================================================
+ */
+
+/* =======================================================================================
+ * Informazioni del modulo
+ * =======================================================================================
+ * \brf  Tipi e definizioni della libreria STD_Lib
+ *
+ * \mod  Tipi e definizioni della libreria STD_Lib
+ * \aut  Luigi Ingravallo
+ * =======================================================================================
+ */
+
+/* =======================================================================================
+ * Elenco delle modifiche (data - autore - descrizione)
+ * =======================================================================================
+ *
+ * Ultima:
+ *
+ * 24/05/2017 - Luigi Ingravallo - Creazione del modulo
+ * =======================================================================================
+ */
+
+#ifndef _TYPE_DEF_H
+#define _TYPE_DEF_H
+
+/* =======================================================================================
+ * File inclusi
+ * =======================================================================================
+ */
+#ifdef _UNICODE
+#include <wchar.h>
+#endif
+/* =======================================================================================
+ * Definizioni
+ * =======================================================================================
+ */
+
+
+#ifndef _64BIT_PLATFORM
+//#error Definire la piattaforma
+#endif
+
+
+/* TIPI SEMPLICI */
+
+#ifndef _CHAR_T
+   /* \typ Carattere            (Intero     segnato a  8 bit) */
+#ifdef _UNICODE
+   typedef wchar_t                  CHAR_T; 
+#else
+   typedef char                     CHAR_T; 
+#endif
+#define _CHAR_T   
+#endif
+
+#ifndef _SMALL_T
+   /* \typ Dato generico        (Intero     segnato a  8 bit) */ 
+   typedef signed char          SMALL_T; 
+#define _SMALL_T   
+#endif
+
+#ifndef _INT8_T
+   /* \typ Contatore            (Intero     segnato a  8 bit) */ 
+   typedef signed char           INT8_T; 
+#define _INT8_T   
+#endif
+
+#ifndef _BYTE_T
+   /* \typ Dato generico        (Intero non segnato a  8 bit) */
+   typedef unsigned char         BYTE_T; 
+#define _BYTE_T   
+#endif
+
+#ifndef _UINT8_T
+   /* \typ Contatore\dimensione (Intero non segnato a  8 bit) */
+   typedef unsigned char        UINT8_T; 
+#define _UINT8_T   
+#endif
+
+#ifndef _BOOL_T
+   /* \typ Booleano             (Intero non segnato a 32 bit) */ 
+   typedef int                   BOOL_T; 
+#define _BOOL_T   
+#endif
+
+#ifndef _SHORT_T
+   /* \typ Dato generico        (Intero     segnato a 16 bit) */ 
+   typedef signed short         SHORT_T; 
+#define _SHORT_T   
+#endif
+
+#ifndef _INT16_T
+   /* \typ Contatore            (Intero     segnato a 16 bit) */
+   typedef signed short         INT16_T; 
+#define _INT16_T   
+#endif
+
+#ifndef _WORD_T
+   /* \typ Dato generico        (Intero non segnato a 16 bit) */
+   typedef unsigned short        WORD_T; 
+#define _WORD_T   
+#endif
+
+#ifndef _UINT16_T
+   /* \typ Contatore\dimensione (Intero non segnato a 16 bit) */
+   typedef unsigned short      UINT16_T; 
+#define _UINT16_T   
+#endif
+
+#ifndef _LONG_T
+   /* \typ Dato generico        (Intero     segnato a 32 bit) */ 
+   typedef signed long           LONG_T; 
+#define _LONG_T   
+#endif
+
+#ifdef _16BIT_PLATFORM
+#ifndef _INT32_T
+   /* \typ Contatore            (Intero     segnato a 32 bit) */
+   typedef signed long          INT32_T; 
+#define _INT32_T   
+#endif
+
+#ifndef _DWORD_T
+   /* \typ Dato generico        (Intero non segnato a 32 bit) */
+   typedef unsigned long        DWORD_T; 
+#define _DWORD_T   
+#endif
+
+#ifndef _UINT32_T
+   /* \typ Contatore\dimensione (Intero non segnato a 32 bit) */  
+   typedef unsigned long       UINT32_T; 
+#define _UINT32_T   
+#endif
+#else
+   #ifndef _INT32_T
+   /* \typ Contatore            (Intero     segnato a 32 bit) */
+   typedef signed int          INT32_T; 
+#define _INT32_T   
+#endif
+
+#ifndef _DWORD_T
+   /* \typ Dato generico        (Intero non segnato a 32 bit) */
+   typedef unsigned int        DWORD_T; 
+#define _DWORD_T   
+#endif
+
+#ifndef _QWORD_T
+   /* \typ Dato generico        (Intero non segnato a 64 bit) */
+   typedef unsigned long long         QWORD_T; 
+#define _QWORD_T   
+#endif
+
+#ifndef _UINT32_T
+   /* \typ Contatore\dimensione (Intero non segnato a 32 bit) */  
+   typedef unsigned int       UINT32_T; 
+#define _UINT32_T   
+#endif
+#endif
+
+
+//#ifndef _MSC_VER
+
+#ifndef _INT64_T
+   /* \typ Contatore            (Intero     segnato a 64 bit) */  
+   typedef signed long long     INT64_T; 
+#define _INT64_T   
+#endif
+
+#ifndef _UINT64_T
+   /* \typ Contatore\dimensione (Intero non segnato a 64 bit) */ 
+   typedef unsigned long long  UINT64_T; 
+#define _UINT64_T   
+#endif
+
+//#endif
+
+   #ifndef _TIME_T
+      /* \typ Tempo                (Intero non segnato a 32 bit) */ 
+      typedef unsigned long         TIME_T; 
+      #define _TIME_T
+   #endif
+
+
+#ifndef _ADDR_T
+   /* \typ Indirizzo di memoria (Intero non segnato a 32 bit) */
+   typedef unsigned long         ADDR_T;
+#define _ADDR_T
+#endif
+
+#ifndef _ERROR_T
+   /* \typ Codice di errore     (Intero non segnato a 32 bit) */
+   typedef unsigned long       ERROR_T; 
+#define _ERROR_T
+#endif
+
+#ifndef _HANDLE_T
+   /* \typ Handle               (Intero non segnato a 16 bit) */
+   typedef unsigned short      HANDLE_T; 
+#define _HANDLE_T
+#endif
+
+#ifndef _BARRIER_T
+   /* \typ Tag di inzio e fine di una barriera                */
+   typedef unsigned char      BARRIER_T; 
+#define _BARRIER_T
+#endif
+
+#ifndef _FLOAT_T
+   /* \typ Dato generico        (Virgola mobile a 32 bit)     */
+   typedef float                FLOAT_T; 
+#define _FLOAT_T
+#endif
+
+#ifndef _DOUBLE_T
+   /* \typ Dato generico        (Virgola mobile a 64 bit)     */
+   typedef double              DOUBLE_T; 
+#define _DOUBLE_T
+#endif
+
+
+/* COSTANTI PER IL TIPO BOOL_T */
+#ifndef TRUE
+   /* \def Valore "vero"  del tipo booleano BOOL_T */
+   #define TRUE            (1) 
+#endif
+#ifndef FALSE
+   /* \def Valore "falso" del tipo booleano BOOL_T */
+   #define FALSE           (0) 
+#endif
+
+/* COSTANTI PER IL TIPO HANDLE_T */
+
+#ifndef NULL_HANDLE
+  /* \def Valore che indica un handle non valido */
+  #define NULL_HANDLE (HANDLE_T)-1 
+#endif
+
+/* COSTANTI PER IL TIPO BARRIER_T */
+
+/* \def Tag di inizio barriera */
+#define BARRIER_BEGIN ((BARRIER_T) 0x0F) 
+/* \def Tag di fine barriera   */ 
+#define BARRIER_END   ((BARRIER_T) 0xF0) 
+
+/* COSTANTI PER I PUNTATORI */
+#ifndef NULL
+   /* \def Puntatore nullo */
+   #define NULL (0) 
+#endif
+
+/* COSTANTI PER GLI ERRORI */
+#ifndef E_NULL
+   /* \err Valore iniziale delle variabili di tipo ERROR_T   */
+   #define E_NULL                                    (ERROR_T)   -1 
+#endif
+#ifndef E_OK
+   /* \err Operazione completata con successo              */
+   #define E_OK                                      (ERROR_T) 0x00 
+#endif
+
+
+
+/* =======================================================================================
+ * Macro                                                      
+ * =======================================================================================
+ */
+
+/* =======================================================================================
+ * \mac Esegue la funzione ERROR_Function solo se precedentemente non si sono
+ *      verificati degli errori
+ * 
+ * \par [in] ERROR_Value : Codice di errore di tipo ERROR_T
+ * \val -
+ *
+ * \par [in] ERROR_Function : Funzione che restituisce il tipo ERROR_T
+ * \val -
+ *
+ * \ret -
+ * =======================================================================================
+ */
+#define ERROR_Check(ERROR_Value, ERROR_Function) \
+   if ((ERROR_Value) == E_OK)                    \
+   {                                             \
+      (ERROR_Value) = (ERROR_Function);          \
+   }
+
+
+
+#endif /* _TYPE_DEF_H */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/I2C.cpp	Fri Dec 21 15:38:58 2018 +0000
@@ -0,0 +1,262 @@
+#include "mbed.h"
+#include "TYPE_Def.h"
+#include "CRC32BIT_LOOKUP_Ext.h"
+
+
+#define add (0x22)
+#define idstr (0x14)
+#define idspr (0x16)
+
+
+I2C i2c1(I2C_SDA, I2C_SCL);
+Serial pc(USBTX, USBRX); // tx, rx
+DigitalOut myled(LED2);
+DigitalOut pin(D12);
+
+UINT32_T crc;
+ERROR_T ERROR_Value;
+CRC32BIT_LOOKUP_TS _Crc32Table_TGP_DUT;
+BYTE_T vettore[13];
+char crcchar[4];
+
+int i,j,n;
+
+char UINT32_PacketSize [4];
+char ENUM_Packet_ID;
+char UINT16_PacketCounter [2];
+char UINT32_Timestamp [4];
+char UINT16_PortNumber [2];
+char UINT32_BaudRate [4];
+char UINT32_CRC [4];
+
+int hz;
+int ackr;
+int ackw;
+
+char packetsize[4] = {0x00 ,0x00 , 0x00 , 0x11};
+
+void crc_cal();
+void TGP_CMD();
+void TGP_START_READ_ACK();
+void TGP_STOP_READ_ACK();
+void TGP_START_WRITE_ACK();
+void TGP_STOP_WRITE_ACK();
+
+char data;
+char dataout;
+
+int main()
+{
+    pin = 0;
+    
+    ENUM_Packet_ID = 0;
+    data = 0;
+    dataout = 0;
+    
+    
+    ackr = 1;
+    ackw = 1;
+    
+    pc.attach(&TGP_CMD,Serial::RxIrq);
+    
+    j=0;
+    n=0;
+    
+    
+    
+}
+
+void crc_cal()
+{   
+    
+    //def vettore
+    j=0;
+    for(i=0; i<4; i++){
+            vettore[j] = packetsize[i];
+            j++;
+    }
+    
+    vettore[j] = ENUM_Packet_ID+1;
+    j++;
+    
+    for(i=0; i<2; i++){
+            vettore[j] = UINT16_PacketCounter[i];
+            j++;
+        }
+        
+    for(i=0; i<4; i++){
+            vettore[j] = UINT32_Timestamp[i];
+            j++;
+        }
+        
+    for(i=0;i<2;i++)
+    {
+        vettore[j] = UINT16_PortNumber[i];   
+        j++;
+    }    
+    
+    
+    _Crc32Table_TGP_DUT.UINT32_Poly = 0xE7994FEB;
+   _Crc32Table_TGP_DUT.UINT32_Init =  0xFFFFFFFF;
+   _Crc32Table_TGP_DUT.BOOL_RefIn = FALSE;
+   _Crc32Table_TGP_DUT.BOOL_RefOut =  FALSE;
+   _Crc32Table_TGP_DUT.UINT32_XorOut = 0x00000000;
+
+   /* Inizializzazione della tabella */
+   ERROR_Value = CRC32BIT_LOOKUP_Init(&_Crc32Table_TGP_DUT);
+   
+   crc = CRC32BIT_LOOKUP_Compute(vettore,13,&_Crc32Table_TGP_DUT);
+   
+   crcchar[0] = (crc >> 24) & 0xFF;
+    crcchar[1] = (crc >> 16) & 0xFF;
+    crcchar[2] = (crc >> 8) & 0xFF;
+    crcchar[3] = crc & 0xFF;
+   
+}
+
+void TGP_CMD()
+{
+    myled = 0;
+    
+    for(i=0; i<4; i++)
+    {
+            UINT32_PacketSize[i] = pc.getc();
+    }
+    
+    ENUM_Packet_ID = pc.getc();
+    
+    if(ENUM_Packet_ID == idstr)
+    {
+        for(i=0; i<2; i++){
+            UINT16_PacketCounter[i]=pc.getc();
+        }
+        
+        for(i=0; i<4; i++){
+            UINT32_Timestamp[i]=pc.getc();
+        }
+        
+        for(i=0; i<2; i++){
+            UINT16_PortNumber[i]=pc.getc();
+        }
+        
+        for(i=0; i<4; i++){
+            UINT32_BaudRate[i]=pc.getc();
+        }
+        
+        for(i=0; i<4; i++){
+            UINT32_CRC[i]=pc.getc();
+        }
+        
+        myled = 1;
+        
+        TGP_START_READ_ACK();
+        
+    } 
+    else if(ENUM_Packet_ID == idspr)
+    {
+        for(i=0; i<2; i++){
+            UINT16_PacketCounter[i]=pc.getc();
+        }
+        
+        for(i=0; i<4; i++){
+            UINT32_Timestamp[i]=pc.getc();
+        }
+        
+        for(i=0; i<2; i++){
+            UINT16_PortNumber[i]=pc.getc();
+        }
+        
+        for(i=0; i<4; i++){
+            UINT32_CRC[i]=pc.getc();
+        }
+        
+        myled = 1;
+        
+        TGP_STOP_READ_ACK();
+        
+    }
+    
+    else 
+    {
+        while(1)
+        {
+            myled = 1;
+            wait(0.1);
+            myled = 0;
+            wait(0.1);   
+        }
+    }
+    
+    
+}
+
+
+void TGP_START_READ_ACK()
+{
+    for(i=0; i<4; i++)
+    {
+        pc.printf("%c",packetsize[i]); 
+    }
+    
+    pc.printf("%c",ENUM_Packet_ID+1);
+    
+    for(i=0; i<2; i++)
+    {
+        pc.printf("%c",UINT16_PacketCounter[i]);
+    }
+        
+    for(i=0; i<4; i++)
+    {
+        pc.printf("%c",UINT32_Timestamp[i]);
+    }
+    
+    for(i=0; i<2; i++)
+    {
+        pc.putc(UINT16_PortNumber[i]);
+    }
+    
+    crc_cal();
+    
+    for(i=0; i<4; i++)
+    {
+        pc.putc(crcchar[i]);
+    }
+    
+    myled = 0;
+    pin = 1;
+}
+
+void TGP_STOP_READ_ACK()
+{
+    for(i=0; i<4; i++)
+    {
+        pc.printf("%c",packetsize[i]); 
+    }
+    
+    pc.printf("%c",ENUM_Packet_ID+1);
+    
+    for(i=0; i<2; i++)
+    {
+        pc.printf("%c",UINT16_PacketCounter[i]);
+    }
+        
+    for(i=0; i<4; i++)
+    {
+        pc.printf("%c",UINT32_Timestamp[i]);
+    }
+    
+    for(i=0; i<2; i++)
+    {
+        pc.putc(UINT16_PortNumber[i]);
+    }
+    
+    crc_cal();
+    
+    for(i=0; i<4; i++)
+    {
+        pc.putc(crcchar[i]);
+    }
+    
+    myled = 0;
+    pin = 0;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Fri Dec 21 15:38:58 2018 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/mbed_official/code/mbed/builds/3a7713b1edbc
\ No newline at end of file