diff options
| author | Avi Levkovich <avi@twine-s.com> | 2020-07-27 15:26:02 +0300 |
|---|---|---|
| committer | Avi Levkovich <avi@twine-s.com> | 2020-07-27 15:26:02 +0300 |
| commit | f51a7d656e9ec9795a1ca80ad643b9d3c5c23638 (patch) | |
| tree | 5d7a2dd970e2a20721f3008ec82cb05f29823b2a /Software/Embedded_SW/Embedded | |
| parent | 004d88fd5af64ab5329d7eb3bca3069d737aca0a (diff) | |
| download | Tango-f51a7d656e9ec9795a1ca80ad643b9d3c5c23638.tar.gz Tango-f51a7d656e9ec9795a1ca80ad643b9d3c5c23638.zip | |
Add the function Init_IFS : Hw+SW reset + initialization of the RFID reader.
Diffstat (limited to 'Software/Embedded_SW/Embedded')
19 files changed, 322 insertions, 111 deletions
diff --git a/Software/Embedded_SW/Embedded/.cproject b/Software/Embedded_SW/Embedded/.cproject index 4bebf3c83..b0b5c14ed 100644 --- a/Software/Embedded_SW/Embedded/.cproject +++ b/Software/Embedded_SW/Embedded/.cproject @@ -170,7 +170,7 @@ </toolChain> </folderInfo> <sourceEntries> - <entry excluding="Drivers/I2C_Communication/I2C_FIFO.c|Drivers/I2C_Communication/test_fifo_dma.c|Drivers/Uart_Comm/WHS_Controller_Comm/Modbus|Drivers/Uart_Comm/WHS_Controller_Comm/Modbus/tcp|Drivers/I2C_Communication/RFID_NFC/NFC_I2C|Drivers/I2C_Communication/RFID_NFC/PN7150|Drivers/I2C_Communication/Head_Card/ADC/Head_ADC_old.c|src|EmbParam.cfg" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name=""/> + <entry excluding="Drivers/I2C_Communication/RFID_NFC/Test_RFID.c|Drivers/I2C_Communication/I2C_FIFO.c|Drivers/I2C_Communication/test_fifo_dma.c|Drivers/Uart_Comm/WHS_Controller_Comm/Modbus|Drivers/Uart_Comm/WHS_Controller_Comm/Modbus/tcp|Drivers/I2C_Communication/RFID_NFC/NFC_I2C|Drivers/I2C_Communication/RFID_NFC/PN7150|Drivers/I2C_Communication/Head_Card/ADC/Head_ADC_old.c|src|EmbParam.cfg" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name=""/> </sourceEntries> </configuration> </storageModule> diff --git a/Software/Embedded_SW/Embedded/DataDef.h b/Software/Embedded_SW/Embedded/DataDef.h index 0e38c6e2e..7499e4374 100644 --- a/Software/Embedded_SW/Embedded/DataDef.h +++ b/Software/Embedded_SW/Embedded/DataDef.h @@ -37,7 +37,7 @@ extern bool Special_Dispensers; #define I2C_2_Data_Transfer_Rate_400kbps #define I2C_3_Data_Transfer_Rate_400kbps// Head card + WHS card -#define I2C_4_Data_Transfer_Rate_400kbps +#define I2C_4_Data_Transfer_Rate_400kbps// RFID + Dispensers #define MAX_ERR_SAMPLES 5 //Number of Samples before sending error #define ERROR_TEMPERATURE_MEASUREMENT 0xFFFF diff --git a/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/RFID_NFC/I2C_IFS_Mux.c b/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/RFID_NFC/I2C_IFS_Mux.c index 601e2e18a..57c9cb70f 100644 --- a/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/RFID_NFC/I2C_IFS_Mux.c +++ b/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/RFID_NFC/I2C_IFS_Mux.c @@ -16,7 +16,7 @@ #include <Drivers/I2C_Communication/I2C.h> #include "drivers/FPGA/FPGA_Comm.h" #include <Drivers/I2C_Communication/RFID_NFC/PN7150/PN7150.h> -#include <Drivers/I2C_Communication/RFID_NFC/NFC_I2C/Test_NFC.h> +//#include <Drivers/I2C_Communication/RFID_NFC/NFC_I2C/Test_NFC.h> #include "I2C_IFS_Mux.h" #include "NFC_MainBaord.h" #include "Modules/Control/Control.h" @@ -26,57 +26,76 @@ PANEL_BUTTON_OR_CRAT_ID Active_RFID_Reader = UNKNOWN; F1_GPO_REG2 Reset_NFC; -uint32_t I2C_NFC_Config(uint32_t channel) -{ - uint32_t Status = OK; - - Status = I2C_Write(I2C_ID_IFS_MUX, I2C_MUX_Slave_Add, channel, 1); - - return Status; -} - -uint32_t Block_Main_All_I2C_RFID_Channels() -{ - uint32_t Status= OK; - - uint8_t Channel = 0x00;//Block all - - Status = I2C_NFC_Config(Channel); - - return Status; -} +//uint32_t I2C_NFC_Config(uint8_t channel)//config main mux +//{ +// uint32_t Status = OK; +// +// Status = I2C_Write(I2C_ID_IFS_MUX, I2C_MUX_Slave_Add, channel, 1); +// +// return Status; +//} +// +//uint32_t Block_Main_All_I2C_RFID_Channels() +//{ +// uint32_t Status= OK; +// +// uint8_t Channel = 0x00;//Block all +// +// Status = I2C_NFC_Config(Channel); +// +// return Status; +//} +// +//uint32_t Select_Main_I2C_RFID_Channel(PANEL_BUTTON_OR_CRAT_ID Cart_ID) +//{ +// uint32_t status= OK; +// uint8_t Channel = 0x00; +// +// //if(Active_RFID_Reader != Cart_ID) +// //{ +// //Block_Main_All_I2C_RFID_Channels(); +// +// Channel = 0x01 << (Cart_ID - 1); +// +// status = I2C_NFC_Config(Channel); +// +// Active_RFID_Reader = Cart_ID; +// //} +// return status; +//} uint32_t Select_Main_I2C_RFID_Channel(PANEL_BUTTON_OR_CRAT_ID Cart_ID) { uint32_t status= OK; - uint32_t Channel; + uint8_t Write_Buf[1]; - if(Active_RFID_Reader != Cart_ID) - { - Block_Main_All_I2C_RFID_Channels(); + //if(Active_RFID_Reader != Cart_ID) + //{ - Channel = 0x01 << (Cart_ID - 1); + Write_Buf[0] = 0x01 << (Cart_ID - 1);// 1 << 0/1/2 - status = I2C_NFC_Config(Channel); + status = I2C_Write(I2C_ID_IFS_MUX, I2C_MUX_Slave_Add, Write_Buf, 1); Active_RFID_Reader = Cart_ID; - } - return status; -} - -uint32_t I2C_RFID_Set_for_Read_Ch() -{ - uint32_t status= OK; - - uint8_t Write_Buf[2] = {0,0}; - - status |= Select_Main_I2C_RFID_Channel(Active_RFID_Reader); - - status |= I2C_Write(I2C_ID_IFS_MUX, I2C_NFC_Slave_Add, Write_Buf, sizeof(Write_Buf)); + //delayUs(10); + //} return status; } +//uint32_t I2C_RFID_Set_for_Read_Ch() +//{ +// uint32_t status= OK; +// +// uint8_t Write_Buf[2] = {0,0}; +// +// status |= Select_Main_I2C_RFID_Channel(Active_RFID_Reader); +// +// status |= I2C_Write(I2C_ID_IFS_MUX, I2C_NFC_Slave_Add, Write_Buf, sizeof(Write_Buf)); +// +// return status; +//} +/* uint32_t Reset_and_Check_IFS_Availability(PANEL_BUTTON_OR_CRAT_ID Cart_ID) { uint32_t status = OK; @@ -124,7 +143,8 @@ uint32_t Reset_and_Check_IFS_Availability(PANEL_BUTTON_OR_CRAT_ID Cart_ID) return status; } - +*/ +/* uint32_t Check_IFS_Availability() { uint32_t status = OK; @@ -136,5 +156,8 @@ uint32_t Check_IFS_Availability() status |= Reset_and_Check_IFS_Availability(Cart_i); delayms(1); } + + Active_RFID_Reader = CART_2; // temporary !!!!! return status; } +*/ diff --git a/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/RFID_NFC/I2C_IFS_Mux.h b/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/RFID_NFC/I2C_IFS_Mux.h index bf15e0c3c..a82f63163 100644 --- a/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/RFID_NFC/I2C_IFS_Mux.h +++ b/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/RFID_NFC/I2C_IFS_Mux.h @@ -21,7 +21,8 @@ uint32_t Check_IFS_Availability(); typedef enum { IFS_AVAILABILITY_UNKNOWN, - IFS_RECOGNIZED, + IFS_RECOGNIZED_INIT_FAILED, + IFS_RECOGNIZED_INIT_PASSED, IFS_NOT_RECOGNIZED, }IFS_AVAILABILITY; diff --git a/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/RFID_NFC/NFC.c b/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/RFID_NFC/NFC.c index f6e1bf712..f029d24d5 100644 --- a/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/RFID_NFC/NFC.c +++ b/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/RFID_NFC/NFC.c @@ -13,14 +13,16 @@ #include "delay.h" #include "drivers/I2C_Communication/I2C.h" #include "drivers/I2C_Communication/RFID_NFC/NFC_I2C/NFC_I2C.h" + #include "drivers/I2C_Communication/RFID_NFC/logi-tag/LT_RFID.h" +#include <Drivers/I2C_Communication/RFID_NFC/NFC_MainBaord.h> NxpNci_RfIntf_t tagInfo; -void Init_RFID_Reader()//1 +bool Init_RFID_Reader(RFID_READER_ID Reader_ID)//0-2 { static bool firstTime = true; - uint8_t readerID = 0; + RFID_RETURN_CODE RFIDRetCode; if(firstTime) { @@ -28,10 +30,17 @@ void Init_RFID_Reader()//1 firstTime = false; } - //for(readerID = 0; readerID < 3; readerID++) - //{ - RFID_Connect(readerID); - //} + RFIDRetCode = RFID_Connect(Reader_ID);//0-2 - > Active_RFID_Reader = Cart_ID;//1-3 - verify using scope/ fluke + + if(RFIDRetCode == SUCCESS) + { + return OK; + } + else + { + return ERROR; + } + } uint8_t RFID_Pint_Errors(uint8_t readerID, RFID_RETURN_CODE Err_Code) @@ -106,37 +115,45 @@ uint8_t Connect_to_RFID_Reder(uint8_t readerID)//2 RFID_StartDiscovery(readerID); - if(RFID_WaitForDiscoveryNotification(readerID, &tagInfo) == SUCCESS) + while(1)//only for testing - stub call the function { - RFIDRetValue = getUID( readerID, &tagInfo, uid ); - RFID_Status = RFIDRetValue; - Status |= RFID_Pint_Errors(readerID, RFIDRetValue); -/* - //password authentication - PwdRetVal = checkPwd( newPwd, newPACK ); - if(PwdRetVal == 1) + if(RFID_WaitForDiscoveryNotification(readerID, &tagInfo) == SUCCESS) { - //OK - } - else if(PwdRetVal == -1) - { - LOG_ERROR (readerID, "RFID - checkPwd: wrong Pwd");//wrong value - Status |= ERROR; + RFIDRetValue = getUID( readerID, &tagInfo, uid ); + RFID_Status = RFIDRetValue; + Status |= RFID_Pint_Errors(readerID, RFIDRetValue); + /* + //password authentication + PwdRetVal = checkPwd( newPwd, newPACK ); + + if(PwdRetVal == 1) + { + //OK + } + else if(PwdRetVal == -1) + { + LOG_ERROR (readerID, "RFID - checkPwd: wrong Pwd");//wrong value + Status |= ERROR; + } + else if(PwdRetVal == -2) + { + LOG_ERROR (readerID, "RFID - checkPwd: wrong pack value");//wrong pack value + Status |= ERROR; + } + + counter = GetCounter (readerID, &tagInfo); + isTagValid = IsTagValid(readerID, &tagInfo); + */ + break; } - else if(PwdRetVal == -2) + else { - LOG_ERROR (readerID, "RFID - checkPwd: wrong pack value");//wrong pack value - Status |= ERROR; - } + nop++; - counter = GetCounter (readerID, &tagInfo); - isTagValid = IsTagValid(readerID, &tagInfo); - */ - } - else - { - nop++; + } + //Task_sleep (1000); + delayms(1000); } RFID_StopDiscovery(readerID); diff --git a/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/RFID_NFC/NFC.h b/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/RFID_NFC/NFC.h index 6783cb156..35f8c6383 100644 --- a/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/RFID_NFC/NFC.h +++ b/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/RFID_NFC/NFC.h @@ -8,7 +8,7 @@ #ifndef DRIVERS_I2C_COMMUNICATION_RFID_NFC_NFC_H_ #define DRIVERS_I2C_COMMUNICATION_RFID_NFC_NFC_H_ -void Init_RFID_Reader(); +bool Init_RFID_Reader(RFID_READER_ID Reader_ID); bool Connect_to_RFID_Reder(uint8_t readerID); extern uint8_t uid[7]; diff --git a/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/RFID_NFC/NFC_MainBaord.c b/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/RFID_NFC/NFC_MainBaord.c index 1da08d559..bc8ef08e0 100644 --- a/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/RFID_NFC/NFC_MainBaord.c +++ b/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/RFID_NFC/NFC_MainBaord.c @@ -10,15 +10,27 @@ #include <stdbool.h> #include <string.h> //memset #include <DataDef.h> +#include "include.h" #include "driverlib/sysctl.h" #include <Drivers/I2C_Communication/I2C.h> #include "drivers/FPGA/FPGA_Comm.h" #include "delay.h" #include <Drivers/I2C_Communication/RFID_NFC/PN7150/PN7150.h> -#include <Drivers/I2C_Communication/RFID_NFC/NFC_I2C/Test_NFC.h> +#include <Drivers/I2C_Communication/RFID_NFC/Test_RFID.h> +#include "drivers/I2C_Communication/RFID_NFC/logi-tag/LT_RFID.h" +#include "Drivers/I2C_Communication/RFID_NFC/NFC_MainBaord.h" +#include "Drivers/I2C_Communication/RFID_NFC/NFC.h" +#include "driverlib/i2c.h" +#include <Drivers/I2C_Communication/RFID_NFC/logi-tag/LT_NFC.h> +//#include <Drivers/I2C_Communication/RFID_NFC/logi-tag/LT_NFC.h> +//#include <Drivers/I2C_Communication/RFID_NFC/logi-tag/LT_NFC_Settings.h> +//#include <Drivers/I2C_Communication/RFID_NFC/I2C_IFS_Mux.h> #include "I2C_IFS_Mux.h" #include "NFC_MainBaord.h" + +IFS_AVAILABILITY IFS_Init_Status[3] = {IFS_AVAILABILITY_UNKNOWN,IFS_AVAILABILITY_UNKNOWN,IFS_AVAILABILITY_UNKNOWN}; + /* PANEL_BUTTON_OR_CRAT_ID Active_RFID_Reader = UNKNOWN; @@ -92,22 +104,22 @@ void NFC_HardwareReset() switch(Active_RFID_Reader) { case CART_1: - Reset_NFC.bits.F1_RFID_CART1_RST = 0; + Reset_NFC.bits.F1_RFID_CART1_RST = NFC_HARDWARE_RESET; F1_GPO_02_bus = Reset_NFC.ushort; delayms(10); - Reset_NFC.bits.F1_RFID_CART1_RST = NFC_HARDWARE_RESET; + Reset_NFC.bits.F1_RFID_CART1_RST = 0; break; case CART_2: - Reset_NFC.bits.F1_RFID_CART2_RST = 0; + Reset_NFC.bits.F1_RFID_CART2_RST = NFC_HARDWARE_RESET; F1_GPO_02_bus = Reset_NFC.ushort; delayms(10); - Reset_NFC.bits.F1_RFID_CART2_RST = NFC_HARDWARE_RESET; + Reset_NFC.bits.F1_RFID_CART2_RST = 0; break; case CART_3: - Reset_NFC.bits.F1_RFID_CART3_RST = 0; + Reset_NFC.bits.F1_RFID_CART3_RST = NFC_HARDWARE_RESET; F1_GPO_02_bus = Reset_NFC.ushort; delayms(10); - Reset_NFC.bits.F1_RFID_CART3_RST = NFC_HARDWARE_RESET; + Reset_NFC.bits.F1_RFID_CART3_RST = 0; break; default: break; @@ -167,4 +179,62 @@ void NFC_Disconnect() } #endif + +void Init_IFS()//must be done after FPGA_Init +{ + RFID_READER_ID Cart_i; + bool Status = OK; + + for(Cart_i = READER_1; Cart_i <= READER_3; Cart_i++) + { + Status = Init_RFID_Reader(Cart_i); + if(Status == OK) // Cstage = 14 + { + IFS_Init_Status[Cart_i] = IFS_RECOGNIZED_INIT_PASSED; + ReportWithPackageFilter(IDSFilter,"------------ IFS RFID reader Initialization Passed -----------------", __FILE__,__LINE__, Cart_i, RpMessage, 0, 0); + Active_RFID_Reader = (PANEL_BUTTON_OR_CRAT_ID)(Cart_i +1); + } + else if(Cstage == 0)//failed in the first step - NFC_Config + { + IFS_Init_Status[Cart_i] = IFS_NOT_RECOGNIZED; + ReportWithPackageFilter(IDSFilter,"------------ IFS RFID reader Not recognized-----------------", __FILE__,__LINE__, Cart_i, RpMessage, 0, 0); + } + else //(Cstage > 0) - Passed HW + SW reset, failed in initialization + { + IFS_Init_Status[Cart_i] = IFS_RECOGNIZED_INIT_FAILED; + ReportWithPackageFilter(IDSFilter,"------------ IFS RFID reader Initialization failed-----------------", __FILE__,__LINE__, Cart_i, RpMessage, 0, 0); + } + } +} + +/* +extern uint8_t rBuf[258];//#define MAX_NCI_FRAME_SIZE 258 +extern uint16_t readLen; + +bool NFC_Transceive(uint8_t *tBuff, uint16_t tLen)//Avi - test without interrupt +{ + uint32_t status = OK; + //uint32_t IFS_i2c_status = I2C_MASTER_ERR_NONE; + + status |= Select_Main_I2C_RFID_Channel(Active_RFID_Reader); + delayUs(5); + status |= I2C_Write(I2C_ID_IFS_MUX, I2C_NFC_Slave_Add, tBuff, tLen); + delayms(3);// + status |= I2C_Read(I2C_ID_IFS_MUX, I2C_NFC_Slave_Add + 1, rBuf, 3); + if(status == OK) + { + if(rBuf[2] != 0){ + if(I2C_Read(I2C_ID_IFS_MUX, I2C_NFC_Slave_Add + 1, &rBuf[3], rBuf[2]) == OK) + readLen = rBuf[2] + 3; + else + return false; + } + else readLen = 3;//???? + } + else + return false; + + return true; +} +*/ //---------------------------------------------------------------------------------------------- diff --git a/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/RFID_NFC/NFC_MainBaord.h b/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/RFID_NFC/NFC_MainBaord.h index 652d38694..1440dba1f 100644 --- a/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/RFID_NFC/NFC_MainBaord.h +++ b/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/RFID_NFC/NFC_MainBaord.h @@ -15,13 +15,26 @@ uint32_t Block_Main_All_I2C_RFID_Channels(); uint32_t Select_Main_I2C_RFID_Channel(PANEL_BUTTON_OR_CRAT_ID Cart_ID); */ + +typedef enum +{ + //logitag ID + READER_1 = 0, + READER_2 = 1, + READER_3 = 2, +}RFID_READER_ID; + #ifndef EVALUATION_BOARD bool SetReader(uint32_t readerID); void NFC_HardwareReset(); bool NFC_WaitForIRQ(uint16_t timeout); void NFC_Disconnect(); +bool NFC_Transceive(uint8_t *tBuff, uint16_t tLen); +void Init_IFS(); #endif +extern uint8_t IFS_Init_Status[3]; + #endif /* DRIVERS_I2C_COMMUNICATION_RFID_NFC_NFC_MAINBAORD_H_ */ diff --git a/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/RFID_NFC/Test_RFID.c b/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/RFID_NFC/Test_RFID.c new file mode 100644 index 000000000..2c5c32319 --- /dev/null +++ b/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/RFID_NFC/Test_RFID.c @@ -0,0 +1,25 @@ +/* + * Test_RFID.c + * + * Created on: Jul 22, 2020 + * Author: avi + */ +#include <DataDef.h> +#include <Drivers/I2C_Communication/RFID_NFC/logi-tag/LT_RFID.h> +#include "Test_RFID.h" +/* +bool Test_Basic_RFID_func(RFID_READER_ID Reader_ID)//0-2 +{ + RFID_RETURN_CODE RFIDRetCode; + + RFIDRetCode = RFID_Connect(Reader_ID);//0-2 - > Active_RFID_Reader = Cart_ID;//1-3 - verify using scope/ fluke + if(RFIDRetCode == SUCCESS) + { + return OK; + } + else + { + return ERROR; + } +} +*/ diff --git a/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/RFID_NFC/Test_RFID.h b/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/RFID_NFC/Test_RFID.h new file mode 100644 index 000000000..a26d54b70 --- /dev/null +++ b/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/RFID_NFC/Test_RFID.h @@ -0,0 +1,21 @@ +/* + * Test_RFID.h + * + * Created on: Jul 22, 2020 + * Author: avi + */ + +#ifndef DRIVERS_I2C_COMMUNICATION_RFID_NFC_TEST_RFID_H_ +#define DRIVERS_I2C_COMMUNICATION_RFID_NFC_TEST_RFID_H_ + +//typedef enum +//{ +// //logitag ID +// READER_1 = 0, +// READER_2 = 1, +// READER_3 = 2, +//}RFID_READER_ID; + + + +#endif /* DRIVERS_I2C_COMMUNICATION_RFID_NFC_TEST_RFID_H_ */ diff --git a/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/RFID_NFC/logi-tag/LT_NFC.c b/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/RFID_NFC/logi-tag/LT_NFC.c index 4be3c9757..9b1343321 100644 --- a/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/RFID_NFC/logi-tag/LT_NFC.c +++ b/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/RFID_NFC/logi-tag/LT_NFC.c @@ -2,7 +2,7 @@ #include <Drivers/I2C_Communication/I2C.h> #include <Drivers/I2C_Communication/RFID_NFC/logi-tag/LT_NFC.h> #include <Drivers/I2C_Communication/RFID_NFC/logi-tag/LT_NFC_Settings.h> - +#include <Drivers/I2C_Communication/RFID_NFC/I2C_IFS_Mux.h> #include "../NFC_MainBaord.h" uint8_t rBuf[MAX_NCI_FRAME_SIZE]; @@ -48,15 +48,20 @@ bool NFC_Receive(uint16_t timeout){ if(rBuf[2] != 0){ if(I2C_ReadBuff(I2C_Base, NXPNCI_I2C_ADDR, &rBuf[3], rBuf[2]) == OK) readLen = rBuf[2] + 3; - else return false; + else + return false; } else readLen = 3; } - else return false; + else + return false; return true; } + bool NFC_Transceive(uint8_t *tBuff, uint16_t tLen){ + Select_Main_I2C_RFID_Channel( Active_RFID_Reader); + delayUs(5); readLen = 0; I2C_ReadBuff(I2C_Base, NXPNCI_I2C_ADDR, rBuf, 3); // I2C problem solution (AVI - change from 1 t0 3, didn't read as expected with 1) delayms(10); // I2C problem solution @@ -103,10 +108,10 @@ bool NFC_CoreInit(uint32_t *fwVersion){ } bool NFC_Connect(uint32_t *fwVersion){ - NFC_HardwareReset(); - if(!NFC_CoreReset()) + NFC_HardwareReset();//FPGA hardware reset to the Active_RFID_Reader (Cart_ID) 1-3 + if(!NFC_CoreReset())//reset the reader (0x20, 0x00, 0x01, 0x01) (the same as done in Reset_and_Check_IFS_Availability) return false; - if(!NFC_CoreInit(fwVersion)) + if(!NFC_CoreInit(fwVersion))//Init the reader and verify it is PN7150 return false; return true; } @@ -117,38 +122,54 @@ void NFC_Disconnect(){ } #endif +unsigned char Cstage = 0; + bool NFC_ConfigSettings(){ + Cstage = 1; if(!NFC_Config(NxpNci_CORE_CONF, sizeof(NxpNci_CORE_CONF))) return false; + Cstage = 2; if(!NFC_Transceive(NxpNci_CORE_STANDBY, sizeof(NxpNci_CORE_STANDBY))) return false; + Cstage = 3; if ((readLen < 4) || (rBuf[0] != 0x4F) || (rBuf[1] != 0x00) || (rBuf[3] != 0x00)) return false; + Cstage = 4; const uint8_t NCIReadTS[] = {0x20, 0x03, 0x03, 0x01, 0xA0, 0x14}; if(!NFC_Transceive(NCIReadTS, sizeof(NCIReadTS))) // Read timestamp stored in NFC Controller return false; + Cstage = 5; if ((readLen < 9) || (rBuf[0] != 0x40) || (rBuf[1] != 0x03) || (rBuf[3] != 0x00)) return false; + Cstage = 6; uint8_t currentTS[32] = __TIMESTAMP__; if(memcmp(&rBuf[8], currentTS, sizeof(currentTS)) != 0){ // Compare stored timestamp with current build timestamp + Cstage = 7; if(!NFC_Config(NxpNci_CORE_CONF_EXTN, sizeof(NxpNci_CORE_CONF_EXTN))) return false; + Cstage = 8; if(!NFC_Config(NxpNci_CLK_CONF, sizeof(NxpNci_CLK_CONF))) return false; + Cstage = 9; if(!NFC_Config(NxpNci_TVDD_CONF_2ndGen, sizeof(NxpNci_TVDD_CONF_2ndGen))) return false; + Cstage = 10; if(!NFC_Config(NxpNci_RF_CONF_2ndGen, sizeof(NxpNci_RF_CONF_2ndGen))) return false; + Cstage = 11; uint8_t NCIWriteTS[7+32] = {0x20, 0x02, 0x24, 0x01, 0xA0, 0x14, 0x20}; memcpy(&NCIWriteTS[7], currentTS, sizeof(currentTS)); if(!NFC_Config(NCIWriteTS, sizeof(NCIWriteTS))) // Save current build timestamp return false; + Cstage = 12; } if(!NFC_CoreReset()) return false; + Cstage = 13; uint32_t tmp; if(!NFC_CoreInit(&tmp)) return false; + Cstage = 14; return true; } diff --git a/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/RFID_NFC/logi-tag/LT_NFC.h b/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/RFID_NFC/logi-tag/LT_NFC.h index 07070bb7e..2c15f704b 100644 --- a/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/RFID_NFC/logi-tag/LT_NFC.h +++ b/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/RFID_NFC/logi-tag/LT_NFC.h @@ -19,4 +19,6 @@ bool NFC_StopDiscovery(); uint8_t NFC_WaitForDiscoveryNotification(NxpNci_RfIntf_t *tagInfo); bool NFC_ReaderTagCmd(uint8_t *command, uint8_t commandSize, uint8_t *answer, uint8_t *answerSize); +extern unsigned char Cstage; + #endif diff --git a/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/RFID_NFC/logi-tag/LT_RFID.c b/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/RFID_NFC/logi-tag/LT_RFID.c index 021e8d9a4..30a6d6f16 100644 --- a/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/RFID_NFC/logi-tag/LT_RFID.c +++ b/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/RFID_NFC/logi-tag/LT_RFID.c @@ -70,13 +70,15 @@ bool SetReader(uint32_t readerID){ #endif RFID_RETURN_CODE RFID_Connect(uint32_t readerID){ - if(!SetReader(readerID)) + Cstage = 0; + if(!SetReader(readerID))//main select mux return ERR_UNDEFINED_READER; - if(!NFC_Connect(&readerFwVersion[readerID])) + if(!NFC_Connect(&readerFwVersion[readerID]))//HW + SW reset the reader return ERR_CONNECTION; - if(!NFC_ConfigSettings()) + Cstage = 1;//Passed HW + SW reset + if(!NFC_ConfigSettings())//Config the reader.... return ERR_CONFIG_SETTINGS; - if(!NFC_ConfigMode()) + if(!NFC_ConfigMode())//Config the reader.... return ERR_CONFIG_MODE; readerInitialized[readerID] = true; return SUCCESS; diff --git a/Software/Embedded_SW/Embedded/Main.c b/Software/Embedded_SW/Embedded/Main.c index 88ba521a4..45059e9c4 100644 --- a/Software/Embedded_SW/Embedded/Main.c +++ b/Software/Embedded_SW/Embedded/Main.c @@ -88,6 +88,12 @@ #include <Drivers/I2C_Communication/I2C_Task.h> #include <Drivers/I2C_Communication/WHS_Card/EEPROM/WHS_EEPROM.h> #include <Drivers/I2C_Communication/RFID_NFC/I2C_IFS_Mux.h> + +#include <Drivers/I2C_Communication/RFID_NFC/NFC_MainBaord.h> +#include <Drivers/I2C_Communication/RFID_NFC/logi-tag/LT_RFID.h> +#include <Drivers/I2C_Communication/RFID_NFC/NFC.h> + +#include <Drivers/I2C_Communication/RFID_NFC/NFC_MainBaord.h> //***************************************************************************** // // The system tick rate expressed both as ticks per second and a millisecond @@ -283,14 +289,14 @@ int main(void) Trigger_Head_io_Init();//Head_IO_Init();//moved to set 24 to pressure sensor in arc earlier } - Check_IFS_Availability(); - #ifndef EVALUATION_BOARD STATUS_RED_LED_ON; STATUS_GREEN_LED_ON; FPGA_Init(); #endif + Init_IFS();//must be done after FPGA_Init + MAP_FPULazyStackingEnable(); SysCtlUSBPLLEnable(); diff --git a/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_Cartridge.c b/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_Cartridge.c index 7e75f31f9..938b3bbd7 100644 --- a/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_Cartridge.c +++ b/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_Cartridge.c @@ -11,6 +11,7 @@ #include "driverlib/gpio.h" #include "Drivers/I2C_Communication/RFID_NFC/logi-tag/LT_RFID.h" +#include <Drivers/I2C_Communication/RFID_NFC/NFC_MainBaord.h> #include "Drivers/I2C_Communication/RFID_NFC/NFC.h" #include <Utilities/RfidTagHandling.h> #include <Drivers/I2C_Communication/RFID_NFC/RFIDTagInfo.h> @@ -27,12 +28,20 @@ void Stub_CartridgeReadRequest(MessageContainer* requestContainer) Cartridge CartridgeRead = CARTRIDGE__INIT; CartridgeTagContent TagRead = CARTRIDGE_TAG_CONTENT__INIT; NFC_Tag NFC_TagRead; - Init_RFID_Reader(); - uint8_t readerID = request->cartridgeid; - Connect_to_RFID_Reder(readerID);//2 StubCartridgeReadResponse response = STUB_CARTRIDGE_READ_RESPONSE__INIT; + uint8_t readerID = request->cartridgeid >> 8; + + if(request->cartridgeid == 0x0100) + { + Init_RFID_Reader(readerID);//0-2 + } + else if(request->cartridgeid == 0x0101) + { + Connect_to_RFID_Reder(readerID);//0-2 - conect the card and get tag id + } + response.cartridge = &CartridgeRead; CartridgeRead.has_index = false; CartridgeRead.has_slot = true; diff --git a/Software/Embedded_SW/Embedded/Modules/Waste/Waste_maint.c b/Software/Embedded_SW/Embedded/Modules/Waste/Waste_maint.c index 7d358cfc2..c13b77bab 100644 --- a/Software/Embedded_SW/Embedded/Modules/Waste/Waste_maint.c +++ b/Software/Embedded_SW/Embedded/Modules/Waste/Waste_maint.c @@ -8,6 +8,7 @@ #include "Modules/Waste/Waste_ex.h" #include <Drivers/I2C_Communication/RFID_NFC/RFIDTagInfo.h> #include "Drivers/I2C_Communication/RFID_NFC/logi-tag/LT_RFID.h" +#include <Drivers/I2C_Communication/RFID_NFC/NFC_MainBaord.h> #include "Drivers/I2C_Communication/RFID_NFC/NFC.h" //#include <Utilities/RfidTagHandling.h> diff --git a/Software/Embedded_SW/Embedded/src/makefile.libs b/Software/Embedded_SW/Embedded/src/makefile.libs index ae6999352..f262762ef 100644 --- a/Software/Embedded_SW/Embedded/src/makefile.libs +++ b/Software/Embedded_SW/Embedded/src/makefile.libs @@ -1,6 +1,6 @@ # # This file was generated based on the configuration script: -# C:\tango\Software\Embedded_SW\Embedded\Embedded.cfg +# C:\Tango\Software\Embedded_SW\Embedded\Embedded.cfg # # This makefile may be included in other makefiles that need to build # the libraries containing the compiled source files generated as @@ -14,7 +14,7 @@ # # The absolute path to the generated source directory (at the time the # sources were generated) is: -# C:\tango\Software\Embedded_SW\Embedded\src +# C:\Tango\Software\Embedded_SW\Embedded\src # GEN_SRC_DIR ?= ../src diff --git a/Software/Embedded_SW/Embedded/src/sysbios/makefile b/Software/Embedded_SW/Embedded/src/sysbios/makefile index a8280a913..0f63ec463 100644 --- a/Software/Embedded_SW/Embedded/src/sysbios/makefile +++ b/Software/Embedded_SW/Embedded/src/sysbios/makefile @@ -1,29 +1,29 @@ -XOPTS = -I"C:/ti/xdctools_3_32_00_06_core/packages/" -Dxdc_target_types__=C:/ti/tirtos_tivac_2_16_00_08/products/bios_6_45_01_29/packages/ti/targets/arm/elf/std.h -Dxdc_target_name__=M4F +XOPTS = -I"C:/TI/xdctools_3_32_00_06_core/packages/" -Dxdc_target_types__=C:/TI/tirtos_tivac_2_16_00_08/products/bios_6_45_01_29/packages/ti/targets/arm/elf/std.h -Dxdc_target_name__=M4F -vpath % C:/ti/tirtos_tivac_2_16_00_08/products/bios_6_45_01_29/packages/ti/sysbios/ -vpath %.c C:/ti/xdctools_3_32_00_06_core/packages/ +vpath % C:/TI/tirtos_tivac_2_16_00_08/products/bios_6_45_01_29/packages/ti/sysbios/ +vpath %.c C:/TI/xdctools_3_32_00_06_core/packages/ CCOPTS = --endian=little -mv7M4 --abi=eabi --float_support=fpv4spd16 -q -ms --program_level_compile -g -Dxdc_FILE=__FILE__ -Dti_sysbios_knl_Task_minimizeLatency__D=FALSE -Dti_sysbios_knl_Clock_stopCheckNext__D=FALSE -Dti_sysbios_family_arm_m3_Hwi_enableException__D=TRUE -Dti_sysbios_family_arm_m3_Hwi_disablePriority__D=32U -Dti_sysbios_family_arm_m3_Hwi_numSparseInterrupts__D=0U -Dti_sysbios_hal_Core_numCores__D=1 -XDC_ROOT = C:/ti/xdctools_3_32_00_06_core/packages/ +XDC_ROOT = C:/TI/xdctools_3_32_00_06_core/packages/ -BIOS_ROOT = C:/ti/tirtos_tivac_2_16_00_08/products/bios_6_45_01_29/packages/ti/sysbios/ +BIOS_ROOT = C:/TI/tirtos_tivac_2_16_00_08/products/bios_6_45_01_29/packages/ti/sysbios/ BIOS_DEFS = -Dti_sysbios_BIOS_swiEnabled__D=TRUE -Dti_sysbios_BIOS_taskEnabled__D=TRUE -Dti_sysbios_BIOS_clockEnabled__D=TRUE -Dti_sysbios_BIOS_runtimeCreatesEnabled__D=TRUE -Dti_sysbios_hal_Hwi_DISABLE_ALL_HOOKS -Dti_sysbios_knl_Swi_DISABLE_ALL_HOOKS -Dti_sysbios_BIOS_smpEnabled__D=FALSE -Dti_sysbios_Build_useHwiMacros -Dti_sysbios_knl_Swi_numPriorities__D=16 -Dti_sysbios_knl_Task_deleteTerminatedTasks__D=FALSE -Dti_sysbios_knl_Task_numPriorities__D=16 -Dti_sysbios_knl_Task_checkStackFlag__D=TRUE -Dti_sysbios_knl_Task_initStackFlag__D=TRUE -Dti_sysbios_knl_Task_DISABLE_ALL_HOOKS -Dti_sysbios_knl_Clock_TICK_SOURCE=ti_sysbios_knl_Clock_TickSource_TIMER -Dti_sysbios_knl_Clock_TICK_MODE=ti_sysbios_knl_Clock_TickMode_PERIODIC -Dti_sysbios_hal_Core_delegate_getId=ti_sysbios_hal_CoreNull_getId__E -Dti_sysbios_hal_Core_delegate_interruptCore=ti_sysbios_hal_CoreNull_interruptCore__E -Dti_sysbios_hal_Core_delegate_lock=ti_sysbios_hal_CoreNull_lock__E -Dti_sysbios_hal_Core_delegate_unlock=ti_sysbios_hal_CoreNull_unlock__E -Dti_sysbios_hal_Core_numCores__D=1 -Dti_sysbios_hal_CoreNull_numCores__D=1 -Dti_sysbios_utils_Load_taskEnabled__D=TRUE -Dti_sysbios_utils_Load_swiEnabled__D=FALSE -Dti_sysbios_utils_Load_hwiEnabled__D=FALSE -Dti_sysbios_family_arm_m3_Hwi_dispatcherSwiSupport__D=TRUE -Dti_sysbios_family_arm_m3_Hwi_dispatcherTaskSupport__D=TRUE -Dti_sysbios_family_arm_m3_Hwi_dispatcherAutoNestingSupport__D=TRUE -Dti_sysbios_family_arm_m3_Hwi_dispatcherIrpTrackingSupport__D=TRUE -Dti_sysbios_knl_Semaphore_supportsEvents__D=FALSE -Dti_sysbios_knl_Semaphore_supportsPriority__D=TRUE -BIOS_INC = -I"C:/ti/tirtos_tivac_2_16_00_08/products/bios_6_45_01_29/packages/" +BIOS_INC = -I"C:/TI/tirtos_tivac_2_16_00_08/products/bios_6_45_01_29/packages/" -TARGET_INC = -I"C:/ti/tirtos_tivac_2_16_00_08/products/bios_6_45_01_29/packages/" +TARGET_INC = -I"C:/TI/tirtos_tivac_2_16_00_08/products/bios_6_45_01_29/packages/" INCS = $(BIOS_INC) $(TARGET_INC) -CC = C:/ti/ccsv7/tools/compiler/ti-cgt-arm_16.9.2.LTS/bin/armcl -c $(CCOPTS) -I C:/ti/ccsv7/tools/compiler/ti-cgt-arm_16.9.2.LTS/include -ASM = C:/ti/ccsv7/tools/compiler/ti-cgt-arm_16.9.2.LTS/bin/armcl -c $(CCOPTS) -I C:/ti/ccsv7/tools/compiler/ti-cgt-arm_16.9.2.LTS/include -AR = C:/ti/ccsv7/tools/compiler/ti-cgt-arm_16.9.2.LTS/bin/armar rq +CC = C:/TI/ccsv7/tools/compiler/ti-cgt-arm_16.9.4.LTS/bin/armcl -c $(CCOPTS) -I C:/TI/ccsv7/tools/compiler/ti-cgt-arm_16.9.4.LTS/include +ASM = C:/TI/ccsv7/tools/compiler/ti-cgt-arm_16.9.4.LTS/bin/armcl -c $(CCOPTS) -I C:/TI/ccsv7/tools/compiler/ti-cgt-arm_16.9.4.LTS/include +AR = C:/TI/ccsv7/tools/compiler/ti-cgt-arm_16.9.4.LTS/bin/armar rq -DEL = C:/ti/xdctools_3_32_00_06_core/packages/../bin/rm -f -CP = C:/ti/xdctools_3_32_00_06_core/packages/../bin/cp -f +DEL = C:/TI/xdctools_3_32_00_06_core/packages/../bin/rm -f +CP = C:/TI/xdctools_3_32_00_06_core/packages/../bin/cp -f define RM $(if $(wildcard $1),$(DEL) $1,:) diff --git a/Software/Embedded_SW/Embedded/src/sysbios/sysbios.aem4f b/Software/Embedded_SW/Embedded/src/sysbios/sysbios.aem4f Binary files differindex 50096cc7a..b658da29a 100644 --- a/Software/Embedded_SW/Embedded/src/sysbios/sysbios.aem4f +++ b/Software/Embedded_SW/Embedded/src/sysbios/sysbios.aem4f |
