aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Embedded_SW/Embedded/Drivers
diff options
context:
space:
mode:
authorShlomo Hecht <shlomo@twine-s.com>2020-04-26 15:38:07 +0300
committerShlomo Hecht <shlomo@twine-s.com>2020-04-26 15:38:07 +0300
commit76845dc21fd587cfefd886e2539b3202d00564f6 (patch)
tree38553f5e21eb410f30386be055cba39830045d5a /Software/Embedded_SW/Embedded/Drivers
parent257919304a46076138cd31d688323f80f3081f7f (diff)
downloadTango-76845dc21fd587cfefd886e2539b3202d00564f6.tar.gz
Tango-76845dc21fd587cfefd886e2539b3202d00564f6.zip
move dispenser EEPROM handling to stubs. add whs eeprom handling draft
Diffstat (limited to 'Software/Embedded_SW/Embedded/Drivers')
-rw-r--r--Software/Embedded_SW/Embedded/Drivers/I2C_Communication/Dispenser_Card/EEPROM/Dispenser_EEPROM.c20
-rw-r--r--Software/Embedded_SW/Embedded/Drivers/I2C_Communication/WHS_Card/EEPROM/WHS_EEPROM.c181
-rw-r--r--Software/Embedded_SW/Embedded/Drivers/I2C_Communication/WHS_Card/EEPROM/WHS_EEPROM.h23
3 files changed, 212 insertions, 12 deletions
diff --git a/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/Dispenser_Card/EEPROM/Dispenser_EEPROM.c b/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/Dispenser_Card/EEPROM/Dispenser_EEPROM.c
index d374ca533..4b9f457e0 100644
--- a/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/Dispenser_Card/EEPROM/Dispenser_EEPROM.c
+++ b/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/Dispenser_Card/EEPROM/Dispenser_EEPROM.c
@@ -21,9 +21,9 @@
#include <drivers/FPGA/FPGA_Comm.h>
#include "drivers/FPGA/FPGA_GPIO/FPGA_GPIO.h"
-#include "PMR/Diagnostics/DispenserEEprom.pb-c.h"
-#include "PMR/Diagnostics/DispenserEEpromRequest.pb-c.h"
-#include "PMR/Diagnostics/DispenserEEpromResponse.pb-c.h"
+#include "PMR/stubs/StubDispenserEEprom.pb-c.h"
+#include "PMR/stubs/StubDispenserEEpromRequest.pb-c.h"
+#include "PMR/stubs/StubDispenserEEpromResponse.pb-c.h"
@@ -239,7 +239,7 @@ uint8_t Check_Dispenser_Type(uint8_t Dispenser_ID)
return Dispenser_struct[Dispenser_ID].Status;
}
-uint32_t Get_EEPROM_DATA_From_Dispenser(int Dispenser_ID,DispenserEEprom *dispensereeprom)
+uint32_t Get_EEPROM_DATA_From_Dispenser(int Dispenser_ID,DispenserEEpromData *dispensereeprom)
{
uint32_t status = OK;
status |= I2C_EEprom_Set_for_Read_Ch(Dispenser_ID, 0xA0);
@@ -320,7 +320,7 @@ uint32_t Get_EEPROM_DATA_From_Dispenser(int Dispenser_ID,DispenserEEprom *dispen
}
return status;
}
-uint32_t Prepare_EEPROM_DATA_For_Burning(int Dispenser_ID,DispenserEEprom *dispensereeprom)
+uint32_t Prepare_EEPROM_DATA_For_Burning(int Dispenser_ID,DispenserEEpromData *dispensereeprom)
{
uint32_t status = OK;
Dispenser_struct[Dispenser_ID].Write_Disp_EEPROM.bytes.Header = dispensereeprom->header;
@@ -371,8 +371,8 @@ uint32_t DispenserEEpromRequestFunc(MessageContainer* requestContainer)
MessageContainer responseContainer;
uint32_t status = OK;
- DispenserEEprom *DispenserEEpromInstance;
- Report("DispenserEEpromRequestFunc",__FILE__,__LINE__,request->dispenserid,RpWarning,(int)request->burnrequest,0);
+ DispenserEEpromData *DispenserEEpromInstance;
+ Report("StubDispenserEEpromRequestFunc",__FILE__,__LINE__,request->dispenserid,RpWarning,(int)request->burnrequest,0);
if (request->burnrequest == true)
{
@@ -380,10 +380,10 @@ uint32_t DispenserEEpromRequestFunc(MessageContainer* requestContainer)
}
else
{
- DispenserEEpromInstance = my_malloc(sizeof(DispenserEEprom));
+ DispenserEEpromInstance = my_malloc(sizeof(DispenserEEpromData));
if (DispenserEEpromInstance)
{
- dispenser_eeprom__init(DispenserEEpromInstance);
+ dispenser_eeprom_data__init(DispenserEEpromInstance);
status = Get_EEPROM_DATA_From_Dispenser(request->dispenserid,DispenserEEpromInstance);
}
else
@@ -398,7 +398,7 @@ uint32_t DispenserEEpromRequestFunc(MessageContainer* requestContainer)
}
Cresponse.has_dispenserid = true;
Cresponse.dispenserid = request->dispenserid;
- responseContainer = createContainer(MESSAGE_TYPE__DispenserEEpromResponse, requestContainer->token, true, &Cresponse, &dispenser_eeprom_response__pack, &dispenser_eeprom_response__get_packed_size);
+ responseContainer = createContainer(MESSAGE_TYPE__StubDispenserEEpromResponse, requestContainer->token, true, &Cresponse, &dispenser_eeprom_response__pack, &dispenser_eeprom_response__get_packed_size);
responseContainer.continuous = false;
if (status != OK)
{
diff --git a/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/WHS_Card/EEPROM/WHS_EEPROM.c b/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/WHS_Card/EEPROM/WHS_EEPROM.c
index 0832280c2..485a224f6 100644
--- a/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/WHS_Card/EEPROM/WHS_EEPROM.c
+++ b/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/WHS_Card/EEPROM/WHS_EEPROM.c
@@ -12,6 +12,10 @@
#include "Drivers/I2C_Communication/WHS_Card/WHS_data.h"
#include "driverlib/i2c.h"
+#include "PMR/stubs/StubWhsEEprom.pb-c.h"
+#include "PMR/stubs/StubWhsEEpromRequest.pb-c.h"
+#include "PMR/stubs/StubWhsEEpromResponse.pb-c.h"
+
//EEPROM M24M01-DFMN6TP
//uint32_t I2C_WHS_EEPROM_SLAVE_ADD = 0xA0;
@@ -188,3 +192,180 @@ uint32_t Test_WHS_EEPROM()
return status;
}
*/
+
+uint32_t Get_EEPROM_DATA_From_WHS(WhsEEpromData *Whseeprom)
+{
+ uint32_t status = OK;
+/* status |= I2C_EEprom_Set_for_Read_Ch(Whs_ID, 0xA0);
+ status |= I2C_EEprom_Read_Ch(Whs_ID, 0xA0);
+
+ if (status == OK)
+ {
+ Whseeprom->has_header = true;
+ Whseeprom->header = Whs_struct.Read_Disp_EEPROM.bytes.Header;
+ Whseeprom->has_tablelength = true;
+ Whseeprom->tablelength = Whs_struct.Read_Disp_EEPROM.bytes.Table_Length;
+ Whseeprom->has_tableversion = true;
+ Whseeprom->tableversion = Whs_struct.Read_Disp_EEPROM.bytes.Table_version;
+ Whseeprom->Whsp_n = my_malloc(sizeof(Whs_struct.Read_Disp_EEPROM.bytes.Whs_Part_Number));
+ if (Whseeprom->Whsp_n)
+ memcpy(Whseeprom->Whsp_n,Whs_struct.Read_Disp_EEPROM.bytes.Whs_Part_Number,sizeof(Whs_struct.Read_Disp_EEPROM.bytes.Whs_Part_Number));
+ Whseeprom->pcbs_n = my_malloc(sizeof(Whs_struct.Read_Disp_EEPROM.bytes.PCB_SN));
+ if (Whseeprom->pcbs_n)
+ memcpy(Whseeprom->pcbs_n,Whs_struct.Read_Disp_EEPROM.bytes.PCB_SN,sizeof(Whs_struct.Read_Disp_EEPROM.bytes.PCB_SN));
+ Whseeprom->pcbpartnumber = my_malloc(sizeof(Whs_struct.Read_Disp_EEPROM.bytes.PCB_Part_Number));
+ if (Whseeprom->pcbpartnumber)
+ memcpy(Whseeprom->pcbpartnumber,Whs_struct.Read_Disp_EEPROM.bytes.PCB_Part_Number,sizeof(Whs_struct.Read_Disp_EEPROM.bytes.PCB_Part_Number));
+ Whseeprom->Whss_n = my_malloc(sizeof(Whs_struct.Read_Disp_EEPROM.bytes.Whs_SN));
+ if (Whseeprom->Whss_n)
+ memcpy(Whseeprom->Whss_n,Whs_struct.Read_Disp_EEPROM.bytes.Whs_SN,sizeof(Whs_struct.Read_Disp_EEPROM.bytes.Whs_SN));
+ Whseeprom->has_minimalpressure = true;
+ Whseeprom->minimalpressure = Whs_struct.Read_Disp_EEPROM.bytes.Maximal_Pressure;
+ Whseeprom->has_maximalpressure = true;
+ Whseeprom->maximalpressure = Whs_struct.Read_Disp_EEPROM.bytes.Maximal_Pressure;
+ Whseeprom->has_minimalmv = true;
+ Whseeprom->minimalmv = Whs_struct.Read_Disp_EEPROM.bytes.Minimal_MV;
+ Whseeprom->has_maximalmv = true;
+ Whseeprom->maximalmv = Whs_struct.Read_Disp_EEPROM.bytes.Maximal_MV;
+ Whseeprom->has_totalcycles = true;
+ Whseeprom->totalcycles = Whs_struct.Read_Disp_EEPROM.bytes.Total_Cycles;
+ Whseeprom->has_bubblesize = true;
+ Whseeprom->bubblesize = Whs_struct.Read_Disp_EEPROM.bytes.Bubble_Size;
+ Whseeprom->has_avg_nl_stepvalue_1_4 = true;
+ Whseeprom->avg_nl_stepvalue_1_4 = Whs_struct.Read_Disp_EEPROM.bytes.AVG_Nl_Step_Value_1_4;
+ Whseeprom->has_avg_nl_stepvalue_2_4 = true;
+ Whseeprom->avg_nl_stepvalue_2_4 = Whs_struct.Read_Disp_EEPROM.bytes.AVG_Nl_Step_Value_2_4;
+ Whseeprom->has_avg_nl_stepvalue_3_4 = true;
+ Whseeprom->avg_nl_stepvalue_3_4 = Whs_struct.Read_Disp_EEPROM.bytes.AVG_Nl_Step_Value_3_4;
+ Whseeprom->has_avg_nl_stepvalue_4_4 = true;
+ Whseeprom->avg_nl_stepvalue_4_4 = Whs_struct.Read_Disp_EEPROM.bytes.AVG_Nl_Step_Value_4_4;
+ Whseeprom->has_sw_reserve = true;
+ Whseeprom->sw_reserve = Whs_struct.Read_Disp_EEPROM.bytes.SW_Reserve;
+ Whseeprom->has_spare1_pressure = true;
+ Whseeprom->spare1_pressure = Whs_struct.Read_Disp_EEPROM.bytes.Spare1_pressure;
+ Whseeprom->has_spare2_pressure = true;
+ Whseeprom->spare2_pressure = Whs_struct.Read_Disp_EEPROM.bytes.Spare2_pressure;
+ Whseeprom->has_motorpulsespercycle = true;
+ Whseeprom->motorpulsespercycle = Whs_struct.Read_Disp_EEPROM.bytes.Motor_PPC;
+ Whseeprom->has_color = true;
+ Whseeprom->color = Whs_struct.Read_Disp_EEPROM.bytes.color;
+ Whseeprom->has_pressureslope = true;
+ Whseeprom->pressureslope = Whs_struct.Read_Disp_EEPROM.bytes.Pressure_Slope;
+ Whseeprom->productiondate = my_malloc(sizeof(Whs_struct.Read_Disp_EEPROM.bytes.Production_Test_Date)+1);
+ if (Whseeprom->productiondate)
+ memcpy(Whseeprom->productiondate,Whs_struct.Read_Disp_EEPROM.bytes.Production_Test_Date,sizeof(Whs_struct.Read_Disp_EEPROM.bytes.Production_Test_Date));
+ Whseeprom->has_atslocation = true;
+ Whseeprom->atslocation = Whs_struct.Read_Disp_EEPROM.bytes.ATS_Location;
+ Whseeprom->has_spare1 = true;
+ Whseeprom->spare1 = Whs_struct.Read_Disp_EEPROM.bytes.Spare1;
+ Whseeprom->has_spare2 = true;
+ Whseeprom->spare2 = Whs_struct.Read_Disp_EEPROM.bytes.Spare2;
+ Whseeprom->has_atschannel = true;
+ Whseeprom->atschannel = Whs_struct.Read_Disp_EEPROM.bytes.ATS_Channel;
+ Whseeprom->has_unitempty = true;
+ Whseeprom->unitempty = Whs_struct.Read_Disp_EEPROM.bytes.Unit_Empty;
+ Whseeprom->has_dryrunpass_fail = true;
+ Whseeprom->dryrunpass_fail = Whs_struct.Read_Disp_EEPROM.bytes.Dry_Run_Status;
+ Whseeprom->has_flowpass_fail = true;
+ Whseeprom->flowpass_fail = Whs_struct.Read_Disp_EEPROM.bytes.Flow_Status;
+ Whseeprom->has_checksum = true;
+ Whseeprom->checksum = Whs_struct.Read_Disp_EEPROM.bytes.CheckSum;
+
+ }
+ */
+ return status;
+}
+uint32_t Prepare_WHS_DATA_For_Burning(WhsEEpromData *Whseeprom)
+{
+ uint32_t status = OK;
+ /*
+ Whs_struct.Write_Disp_EEPROM.bytes.Header = Whseeprom->header;
+ Whs_struct.Write_Disp_EEPROM.bytes.Table_Length = Whseeprom->tablelength;
+ Whs_struct.Write_Disp_EEPROM.bytes.Table_version = Whseeprom->tableversion;
+ Whs_struct.Write_Disp_EEPROM.bytes.Maximal_Pressure = Whseeprom->minimalpressure;
+ Whs_struct.Write_Disp_EEPROM.bytes.Maximal_Pressure = Whseeprom->maximalpressure;
+ Whs_struct.Write_Disp_EEPROM.bytes.Minimal_MV = Whseeprom->minimalmv;
+ Whs_struct.Write_Disp_EEPROM.bytes.Maximal_MV = Whseeprom->maximalmv;
+ Whs_struct.Write_Disp_EEPROM.bytes.Total_Cycles = Whseeprom->totalcycles;
+ Whs_struct.Write_Disp_EEPROM.bytes.Bubble_Size = Whseeprom->bubblesize;
+ Whs_struct.Write_Disp_EEPROM.bytes.AVG_Nl_Step_Value_1_4 = Whseeprom->avg_nl_stepvalue_1_4;
+ Whs_struct.Write_Disp_EEPROM.bytes.AVG_Nl_Step_Value_2_4 = Whseeprom->avg_nl_stepvalue_2_4;
+ Whs_struct.Write_Disp_EEPROM.bytes.AVG_Nl_Step_Value_3_4 = Whseeprom->avg_nl_stepvalue_3_4;
+ Whs_struct.Write_Disp_EEPROM.bytes.AVG_Nl_Step_Value_4_4 = Whseeprom->avg_nl_stepvalue_4_4;
+ Whs_struct.Write_Disp_EEPROM.bytes.SW_Reserve = Whseeprom->sw_reserve;
+ Whs_struct.Write_Disp_EEPROM.bytes.Spare1_pressure = Whseeprom->spare1_pressure;
+ Whs_struct.Write_Disp_EEPROM.bytes.Spare2_pressure = Whseeprom->spare2_pressure;
+ Whs_struct.Write_Disp_EEPROM.bytes.Motor_PPC = Whseeprom->motorpulsespercycle;
+ Whs_struct.Write_Disp_EEPROM.bytes.color = Whseeprom->color;
+ Whs_struct.Write_Disp_EEPROM.bytes.Pressure_Slope = Whseeprom->pressureslope;
+ Whs_struct.Write_Disp_EEPROM.bytes.ATS_Location = Whseeprom->atslocation;
+ Whs_struct.Write_Disp_EEPROM.bytes.Spare1 = Whseeprom->spare1;
+ Whs_struct.Write_Disp_EEPROM.bytes.Spare2 = Whseeprom->spare2;
+ Whs_struct.Write_Disp_EEPROM.bytes.ATS_Channel = Whseeprom->atschannel;
+ Whs_struct.Write_Disp_EEPROM.bytes.Unit_Empty = Whseeprom->unitempty;
+ Whs_struct.Write_Disp_EEPROM.bytes.Dry_Run_Status = Whseeprom->dryrunpass_fail;
+ Whs_struct.Write_Disp_EEPROM.bytes.Flow_Status = Whseeprom->flowpass_fail;
+ Whs_struct.Write_Disp_EEPROM.bytes.CheckSum = Whseeprom->checksum;
+ if (Whseeprom->Whsp_n)
+ strncpy(Whs_struct.Write_Disp_EEPROM.bytes.Whs_Part_Number,Whseeprom->Whsp_n,sizeof(Whs_struct.Write_Disp_EEPROM.bytes.Whs_Part_Number));
+ if (Whseeprom->pcbs_n)
+ strncpy(Whs_struct.Write_Disp_EEPROM.bytes.PCB_SN,Whseeprom->pcbs_n,sizeof(Whs_struct.Write_Disp_EEPROM.bytes.PCB_SN));
+ if (Whseeprom->pcbpartnumber)
+ strncpy(Whs_struct.Write_Disp_EEPROM.bytes.PCB_Part_Number,Whseeprom->pcbpartnumber,sizeof(Whs_struct.Write_Disp_EEPROM.bytes.PCB_Part_Number));
+ if (Whseeprom->Whss_n)
+ strncpy(Whs_struct.Write_Disp_EEPROM.bytes.Whs_SN,Whseeprom->Whss_n,sizeof(Whs_struct.Write_Disp_EEPROM.bytes.Whs_SN));
+ if (Whseeprom->productiondate)
+ strncpy(Whs_struct.Write_Disp_EEPROM.bytes.Production_Test_Date,Whseeprom->productiondate,sizeof(Whs_struct.Write_Disp_EEPROM.bytes.Production_Test_Date));
+ status = I2C_EEprom_Write_Ch(Whs_ID, 0xA0);
+ SysCtlDelay(5000000);//Must delay for at least 5 milli. !!! (See data sheet )
+ */
+ return status;
+}
+uint32_t WhsEEpromRequestFunc(MessageContainer* requestContainer)
+{
+ WhsEEpromRequest *request = whs_eeprom_request__unpack(NULL, requestContainer->data.len, requestContainer->data.data);
+ WhsEEpromResponse Cresponse = WHS_EEPROM_RESPONSE__INIT;
+ MessageContainer responseContainer;
+
+ uint32_t status = OK;
+ WhsEEpromData *WhsEEpromInstance;
+ Report("StubWhsEEpromRequestFunc",__FILE__,__LINE__,1,RpWarning,(int)request->burnrequest,0);
+
+ if (request->burnrequest == true)
+ {
+ status = Prepare_WHS_DATA_For_Burning(request->whseeprom);
+ }
+ else
+ {
+ WhsEEpromInstance = my_malloc(sizeof(WhsEEpromData));
+ if (WhsEEpromInstance)
+ {
+ whs_eeprom_data__init(WhsEEpromInstance);
+ status = Get_EEPROM_DATA_From_WHS(WhsEEpromInstance);
+ }
+ else
+ {
+ status = FAILED;
+ LOG_ERROR(1,"my_malloc failed");
+ }
+ }
+ if ((request->burnrequest == false) && (status == OK))
+ {
+ Cresponse.whseeprom = WhsEEpromInstance;
+ }
+ responseContainer = createContainer(MESSAGE_TYPE__StubWHSEEpromResponse, requestContainer->token, true, &Cresponse, &whs_eeprom_response__pack, &whs_eeprom_response__get_packed_size);
+ responseContainer.continuous = false;
+ if (status != OK)
+ {
+ responseContainer.error = ERROR_CODE__INVALID_PARAMETER;
+ responseContainer.has_error = true;
+ }
+ uint8_t* container_buffer = my_malloc(message_container__get_packed_size(&responseContainer));
+ size_t container_size = message_container__pack(&responseContainer, container_buffer);
+ my_free(responseContainer.data.data);
+ if (WhsEEpromInstance)
+ my_free(WhsEEpromInstance);
+ SendChars((char*)container_buffer, container_size);
+ return OK;
+
+}
diff --git a/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/WHS_Card/EEPROM/WHS_EEPROM.h b/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/WHS_Card/EEPROM/WHS_EEPROM.h
index 05a8ed95a..74ab0762b 100644
--- a/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/WHS_Card/EEPROM/WHS_EEPROM.h
+++ b/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/WHS_Card/EEPROM/WHS_EEPROM.h
@@ -10,13 +10,30 @@
typedef struct
{
-
uint8_t PCB_SN[20];
uint8_t Module_SN[20];
double Orifice_Pressure_V0[3]; // (measured orifice sensor voltage without flow) value for each orifice sensor
double Orifice_Waste_Level_V0; // (measured orifice sensor voltage without flow) value for each orifice sensor
double flow_calc_coefficient_C; // C (flow calculation coefficient) value (=0.239)
-
+ uint32_t Header;
+ uint32_t Table_Length;
+ uint32_t Table_version;
+ uint8_t WHS_Part_Number[20];//String
+ // uint8_t PCB_SN[20];//String
+ uint8_t PCB_Part_Number[20];//String
+ uint8_t WHS_SN[20];//String
+ double Orifice1Flow;
+ double Orifice1Slope;
+ double Orifice2Flow;
+ double Orifice2Slope;
+ double Orifice3Flow;
+ double Orifice3Slope;
+ double OrificeValveFlow;
+ double OrificeValveSlope;
+ uint8_t VOCInstallationDate[8];
+ uint8_t FilterInstallationDate[8];
+ uint8_t ProductionDate[8];
+ uint32_t CheckSum;
}WHS_EEPROM_BYTES;
typedef union
@@ -63,4 +80,6 @@ uint32_t Check_WHS_Type_Via_EEPROM();
bool WHS_I2C_EEprom_Write_Byte(uint32_t address, uint8_t data);
bool WHS_I2C_EEprom_Read_Byte (uint32_t address, uint8_t* p_data);
+uint32_t DispenserEEpromRequestFunc(MessageContainer* requestContainer);
+
#endif /* DRIVERS_I2C_COMMUNICATION_WHS_CARD_EEPROM_WHS_EEPROM_H_ */