aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Embedded_SW/Embedded
diff options
context:
space:
mode:
authorRoy Ben Shabat <Roy.mail.net@gmail.com>2020-07-19 11:29:11 +0300
committerRoy Ben Shabat <Roy.mail.net@gmail.com>2020-07-19 11:29:11 +0300
commitfacf3fea6ebc728cdd09d6d2a22bd32bfe8de6b9 (patch)
treead18e27d769ca53a483b012193fc1197b9704b59 /Software/Embedded_SW/Embedded
parentc90b4e2e753a0a86ebb2af4dc827cda206b148b6 (diff)
parenta23042015bb78f0603440f5746edbc509877faa9 (diff)
downloadTango-facf3fea6ebc728cdd09d6d2a22bd32bfe8de6b9.tar.gz
Tango-facf3fea6ebc728cdd09d6d2a22bd32bfe8de6b9.zip
Merge branch 'master' of https://twinetfs.visualstudio.com/Tango/_git/Tango
Diffstat (limited to 'Software/Embedded_SW/Embedded')
-rw-r--r--Software/Embedded_SW/Embedded/.cproject4
-rw-r--r--Software/Embedded_SW/Embedded/DataDef.h2
-rw-r--r--Software/Embedded_SW/Embedded/Drivers/I2C_Communication/DAC/Blower.c4
-rw-r--r--Software/Embedded_SW/Embedded/Drivers/I2C_Communication/Head_Card/I2C_Head_Mux.c6
-rw-r--r--Software/Embedded_SW/Embedded/Drivers/I2C_Communication/Head_Card/IO_Ports/Head_IO.c162
-rw-r--r--Software/Embedded_SW/Embedded/Drivers/I2C_Communication/Head_Card/IO_Ports/Head_IO.h1
-rw-r--r--Software/Embedded_SW/Embedded/Drivers/I2C_Communication/I2C.c9
-rw-r--r--Software/Embedded_SW/Embedded/Drivers/I2C_Communication/I2C.h8
-rw-r--r--Software/Embedded_SW/Embedded/Drivers/I2C_Communication/I2C_Comm.c93
-rw-r--r--Software/Embedded_SW/Embedded/Drivers/I2C_Communication/I2C_Task.c16
-rw-r--r--Software/Embedded_SW/Embedded/Drivers/I2C_Communication/I2C_Task.h2
-rw-r--r--Software/Embedded_SW/Embedded/Drivers/I2C_Communication/WHS_Card/D_MAX11614_ADC/MAX11614_Driver.c2
-rw-r--r--Software/Embedded_SW/Embedded/Drivers/I2C_Communication/WHS_Card/D_MAX11614_ADC/WHS_MAX11614_A2D.c42
-rw-r--r--Software/Embedded_SW/Embedded/Drivers/I2C_Communication/WHS_Card/D_Max5805_ADC_Blower/WHS_Blower.c7
-rw-r--r--Software/Embedded_SW/Embedded/Drivers/I2C_Communication/WHS_Card/D_TCA9546_ADC_MUX/TCA9546_Driver.c4
-rw-r--r--Software/Embedded_SW/Embedded/Drivers/I2C_Communication/WHS_Card/EEPROM/WHS_EEPROM.c2
-rw-r--r--Software/Embedded_SW/Embedded/Drivers/I2C_Communication/WHS_Card/I2C_WHS_Mux.c6
-rw-r--r--Software/Embedded_SW/Embedded/Drivers/I2C_Communication/WHS_Card/IO_Extender_Ports_TCA9555/TCA9555_Driver.c10
-rw-r--r--Software/Embedded_SW/Embedded/Drivers/I2C_Communication/test_fifo_dma.c763
-rw-r--r--Software/Embedded_SW/Embedded/Main.c30
-rw-r--r--Software/Embedded_SW/Embedded/Modules/AlarmHandling/AlarmHandling.c7
-rw-r--r--Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.c18
-rw-r--r--Software/Embedded_SW/Embedded/Modules/Control/control.h1
-rw-r--r--Software/Embedded_SW/Embedded/Modules/Diagnostics/Diagnostics.c9
-rw-r--r--Software/Embedded_SW/Embedded/Modules/General/Safety.c18
-rw-r--r--Software/Embedded_SW/Embedded/Modules/General/buttons.h1
-rw-r--r--Software/Embedded_SW/Embedded/Modules/General/process.c2
-rw-r--r--Software/Embedded_SW/Embedded/Modules/IDS/IDS_Cleaning.c9
-rw-r--r--Software/Embedded_SW/Embedded/Modules/IDS/IDS_dispenser.c5
-rw-r--r--Software/Embedded_SW/Embedded/Modules/IDS/IDS_print.c23
-rw-r--r--Software/Embedded_SW/Embedded/Modules/IFS/ifs.c487
-rw-r--r--Software/Embedded_SW/Embedded/Modules/IFS/ifs.h58
-rw-r--r--Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Progress.c19
-rw-r--r--Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c165
-rw-r--r--Software/Embedded_SW/Embedded/Modules/Waste/Waste_ex.h4
-rw-r--r--Software/Embedded_SW/Embedded/Modules/Waste/Waste_init.c3
-rw-r--r--Software/Embedded_SW/Embedded/Modules/Waste/Waste_maint.c153
-rw-r--r--Software/Embedded_SW/Embedded/Modules/Waste/Waste_maint.h0
-rw-r--r--Software/Embedded_SW/Embedded/Modules/Waste/Waste_print.c0
-rw-r--r--Software/Embedded_SW/Embedded/Software Release Notes.txt24
-rw-r--r--Software/Embedded_SW/Embedded/StateMachines/Initialization/PowerOffSequence.c4
-rw-r--r--Software/Embedded_SW/Embedded/src/makefile.libs4
-rw-r--r--Software/Embedded_SW/Embedded/src/sysbios/makefile24
-rw-r--r--Software/Embedded_SW/Embedded/src/sysbios/sysbios.aem4fbin1998810 -> 1998354 bytes
44 files changed, 1620 insertions, 591 deletions
diff --git a/Software/Embedded_SW/Embedded/.cproject b/Software/Embedded_SW/Embedded/.cproject
index 388976f56..4bebf3c83 100644
--- a/Software/Embedded_SW/Embedded/.cproject
+++ b/Software/Embedded_SW/Embedded/.cproject
@@ -170,7 +170,7 @@
</toolChain>
</folderInfo>
<sourceEntries>
- <entry excluding="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/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>
@@ -441,7 +441,7 @@
</toolChain>
</folderInfo>
<sourceEntries>
- <entry excluding="EmbParam.cfg|Drivers/Uart_Comm/Uart.c|JigCommands.c|PWM.c|USBCDCD.c|Message.c|Pin_config.c|src|Configuration.c|SlowMotors.c|Timer.c|Communication.c|FastMotors.c|ADCUtils.c|Drivers/L6470|Pin.c|ADCLogger.c|Flashstore.c|Profile.c" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name=""/>
+ <entry excluding="Drivers/I2C_Communication/Head_Card/ADC/Head_ADC_old.c|Drivers/Uart_Comm/WHS_Controller_Comm/Modbus|Drivers/I2C_Communication/RFID_NFC/PN7150|Drivers/I2C_Communication/RFID_NFC/NFC_I2C|EmbParam.cfg|JigCommands.c|PWM.c|USBCDCD.c|Message.c|Pin_config.c|src|Configuration.c|SlowMotors.c|Timer.c|Communication.c|FastMotors.c|ADCUtils.c|Drivers/L6470|Pin.c|ADCLogger.c|Flashstore.c|Profile.c" 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 4b6bdc129..0e38c6e2e 100644
--- a/Software/Embedded_SW/Embedded/DataDef.h
+++ b/Software/Embedded_SW/Embedded/DataDef.h
@@ -68,6 +68,8 @@ enum
#define ENABLE 1
#define DISABLE 0
+#define DONTCARE 0
+
//Valves Directions:
#define MidTank_Dispenser 0
#define Dispenser_Mixer 1
diff --git a/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/DAC/Blower.c b/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/DAC/Blower.c
index 16641d1de..57b57a41d 100644
--- a/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/DAC/Blower.c
+++ b/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/DAC/Blower.c
@@ -182,7 +182,7 @@ uint32_t Control_Voltage_To_Blower(uint32_t mV)
else //new WHS
{
Trigger_SetWHSBlowerVoltage(mV);
- Report("------------ Set Blower Voltage:-----------------", __FILE__,__LINE__, mV, RpMessage, (int)headairflow, 0);
+ //Report("------------ Set Blower Voltage:-----------------", __FILE__,__LINE__, mV, RpMessage, (int)headairflow, 0);
}
voltage = mV;
DiaglosticChangeBlowerData();
@@ -200,7 +200,7 @@ uint32_t Turn_the_Blower_Off()
}
else //new WHS
{
- Trigger_SetWHSBlowerVoltage(0);
+ //Trigger_SetWHSBlowerVoltage(0);
}
blowerStatus = false;
diff --git a/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/Head_Card/I2C_Head_Mux.c b/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/Head_Card/I2C_Head_Mux.c
index 80411394b..f8a425e36 100644
--- a/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/Head_Card/I2C_Head_Mux.c
+++ b/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/Head_Card/I2C_Head_Mux.c
@@ -40,7 +40,7 @@ uint32_t Select_Main_Head_Mux_Channel_test()
{
uint32_t status= OK;
- uint8_t Write_Buf[1];
+ uint8_t Write_Buf[1] = {0};
Write_Buf[0] = 0x01 << 0;//Channel 0
@@ -53,7 +53,9 @@ uint32_t Block_Main_Head_Mux_Channel()
{
uint32_t status= OK;
- uint8_t Write_Buf[1];
+ uint8_t Write_Buf[1] = {0};
+
+ Main_Mux_Flag = UNKNOWN;
Write_Buf[0] = 0x00;//Block all
diff --git a/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/Head_Card/IO_Ports/Head_IO.c b/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/Head_Card/IO_Ports/Head_IO.c
index d7b7fc98f..24690c25f 100644
--- a/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/Head_Card/IO_Ports/Head_IO.c
+++ b/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/Head_Card/IO_Ports/Head_IO.c
@@ -31,7 +31,7 @@ uint32_t TCA9555Config(uint8_t TCA9555_ADDRESS)//Set GPIO
uint32_t status= OK;
uint8_t Config_Reg_PORT_0;
uint8_t Config_Reg_PORT_1;
- uint8_t Write_Buf[2];
+ uint8_t Write_Buf[3];
TCA9555_union config_bits;
if(TCA9555_ADDRESS == 0x40)
@@ -87,12 +87,8 @@ uint32_t TCA9555Config(uint8_t TCA9555_ADDRESS)//Set GPIO
Write_Buf[0] = TCA9555_CONFIG_PORT_0;
Write_Buf[1] = Config_Reg_PORT_0;
-
- status |= I2C_Write(I2C_ID_HEAD_CARD, TCA9555_ADDRESS, Write_Buf, 2);
-
- Write_Buf[0] = TCA9555_CONFIG_PORT_1;
- Write_Buf[1] = Config_Reg_PORT_1;
- status |= I2C_Write(I2C_ID_HEAD_CARD, TCA9555_ADDRESS, Write_Buf, 2);
+ Write_Buf[2] = Config_Reg_PORT_1;
+ status |= I2C_Write(I2C_ID_HEAD_CARD, TCA9555_ADDRESS, Write_Buf, 3);
return OK;
@@ -148,19 +144,28 @@ uint32_t Head_IO_Init()
uint32_t Head_Write_IO_Reg(uint8_t TCA9555_ADDRESS, uint8_t Byte) //LOW/HIGH/LOW_AND_HIGH
{
uint32_t status= OK;
- uint8_t Write_Buf[2];
+ uint8_t Write_Buf[3];
if(TCA9555_ADDRESS == 0x40)
{
- if((Byte == LOW) || (Byte == LOW_AND_HIGH))
+ if(Byte == LOW_AND_HIGH)
+ {
+ Write_Buf[0] = TCA9555_OUTPUT_PORT_0;
+ Write_Buf[1] = Head_I2C_EXP1_0x40.uchar[0];
+ Write_Buf[2] = Head_I2C_EXP1_0x40.uchar[1];
+ status |= Select_Main_Head_Mux_Channel();
+ status |= I2C_Write(I2C_ID_HEAD_CARD, TCA9555_ADDRESS, Write_Buf, 3);
+ }
+ else
+ if(Byte == LOW)
{
Write_Buf[0] = TCA9555_OUTPUT_PORT_0;
Write_Buf[1] = Head_I2C_EXP1_0x40.uchar[0];
status |= Select_Main_Head_Mux_Channel();
status |= I2C_Write(I2C_ID_HEAD_CARD, TCA9555_ADDRESS, Write_Buf, 2);
}
-
- if((Byte == HIGH) || (Byte == LOW_AND_HIGH))
+ else
+ if(Byte == HIGH)
{
Write_Buf[0] = TCA9555_OUTPUT_PORT_1;
Write_Buf[1] = Head_I2C_EXP1_0x40.uchar[1];
@@ -171,14 +176,24 @@ uint32_t Head_Write_IO_Reg(uint8_t TCA9555_ADDRESS, uint8_t Byte) //LOW/HIGH/LOW
else
if(TCA9555_ADDRESS == 0x42)
{
- if((Byte == LOW) || (Byte == LOW_AND_HIGH))
+ if(Byte == LOW_AND_HIGH)
+ {
+ Write_Buf[0] = TCA9555_OUTPUT_PORT_0;
+ Write_Buf[1] = Head_I2C_EXP2_0x42.uchar[0];
+ Write_Buf[2] = Head_I2C_EXP2_0x42.uchar[1];
+ status |= Select_Main_Head_Mux_Channel();
+ status |= I2C_Write(I2C_ID_HEAD_CARD, TCA9555_ADDRESS, Write_Buf, 3);
+ }
+ else
+ if(Byte == LOW)
{
Write_Buf[0] = TCA9555_OUTPUT_PORT_0;
Write_Buf[1] = Head_I2C_EXP2_0x42.uchar[0];
status |= Select_Main_Head_Mux_Channel();
status |= I2C_Write(I2C_ID_HEAD_CARD, TCA9555_ADDRESS, Write_Buf, 2);
}
- if((Byte == HIGH) || (Byte == LOW_AND_HIGH))
+ else
+ if(Byte == HIGH)
{
Write_Buf[0] = TCA9555_OUTPUT_PORT_1;
Write_Buf[1] = Head_I2C_EXP2_0x42.uchar[1];
@@ -189,14 +204,24 @@ uint32_t Head_Write_IO_Reg(uint8_t TCA9555_ADDRESS, uint8_t Byte) //LOW/HIGH/LOW
else
if(TCA9555_ADDRESS == 0x46)
{
- if((Byte == LOW) || (Byte == LOW_AND_HIGH))
+ if(Byte == LOW_AND_HIGH)
+ {
+ Write_Buf[0] = TCA9555_OUTPUT_PORT_0;
+ Write_Buf[1] = Head_I2C_EXP4_0x46.uchar[0];
+ Write_Buf[2] = Head_I2C_EXP4_0x46.uchar[1];
+ status |= Select_Main_Head_Mux_Channel();
+ status |= I2C_Write(I2C_ID_HEAD_CARD, TCA9555_ADDRESS, Write_Buf, 3);
+ }
+ else
+ if(Byte == LOW)
{
Write_Buf[0] = TCA9555_OUTPUT_PORT_0;
Write_Buf[1] = Head_I2C_EXP4_0x46.uchar[0];// & BIT7;
status |= Select_Main_Head_Mux_Channel();
status |= I2C_Write(I2C_ID_HEAD_CARD, TCA9555_ADDRESS, Write_Buf, 2);
}
- if((Byte == HIGH) || (Byte == LOW_AND_HIGH))
+ else
+ if(Byte == HIGH)
{
Write_Buf[0] = TCA9555_OUTPUT_PORT_1;
Write_Buf[1] = Head_I2C_EXP4_0x46.uchar[1];// & (BIT10 | BIT11) ;
@@ -218,7 +243,18 @@ uint32_t Head_Read_IO_Reg(uint8_t TCA9555_ADDRESS, uint8_t Byte) //LOW/HIGH/LOW_
if(TCA9555_ADDRESS == 0x44)
{
- if((Byte == LOW) || (Byte == LOW_AND_HIGH))
+ if(Byte == LOW_AND_HIGH)
+ {
+ Write_Buf[0] = TCA9555_INPUT_PORT_0;
+ status |= Select_Main_Head_Mux_Channel();
+ status |= I2C_Write(I2C_ID_HEAD_CARD, TCA9555_ADDRESS, Write_Buf, 1);
+ delayUs(10);//TODO - check the delay
+ status |= I2C_Read(I2C_ID_HEAD_CARD, TCA9555_ADDRESS + 1, Read_Buf, 2);
+ Head_I2C_EXP3_0x44.uchar[0] = Read_Buf[0];
+ Head_I2C_EXP3_0x44.uchar[1] = Read_Buf[1];
+ }
+ else
+ if(Byte == LOW)
{
Write_Buf[0] = TCA9555_INPUT_PORT_0;
status |= Select_Main_Head_Mux_Channel();
@@ -227,7 +263,8 @@ uint32_t Head_Read_IO_Reg(uint8_t TCA9555_ADDRESS, uint8_t Byte) //LOW/HIGH/LOW_
status |= I2C_Read(I2C_ID_HEAD_CARD, TCA9555_ADDRESS + 1, Read_Buf, 1);
Head_I2C_EXP3_0x44.uchar[0] = Read_Buf[0];
}
- if((Byte == HIGH) || (Byte == LOW_AND_HIGH))
+ else
+ if(Byte == HIGH)
{
Write_Buf[0] = TCA9555_INPUT_PORT_1;
status |= Select_Main_Head_Mux_Channel();
@@ -241,7 +278,20 @@ uint32_t Head_Read_IO_Reg(uint8_t TCA9555_ADDRESS, uint8_t Byte) //LOW/HIGH/LOW_
else
if(TCA9555_ADDRESS == 0x46)
{
- if((Byte == LOW) || (Byte == LOW_AND_HIGH))
+ if(Byte == LOW_AND_HIGH)
+ {
+ Write_Buf[0] = TCA9555_INPUT_PORT_0;
+ status |= Select_Main_Head_Mux_Channel();
+ status |= I2C_Write(I2C_ID_HEAD_CARD, TCA9555_ADDRESS, Write_Buf, 1);
+ delayUs(10);//TODO - check the delay
+ status |= I2C_Read(I2C_ID_HEAD_CARD, TCA9555_ADDRESS + 1, Read_Buf, 2);
+ Head_I2C_EXP4_0x46.uchar[0] &= BIT7;//ACT_DIR
+ Head_I2C_EXP4_0x46.uchar[0] |= Read_Buf[0];
+ Head_I2C_EXP4_0x46.uchar[1] &= (BIT2 | BIT3);//ACTIN_ON ACTOT_ON
+ Head_I2C_EXP4_0x46.uchar[1] |= Read_Buf[1];
+ }
+ else
+ if(Byte == LOW)
{
Write_Buf[0] = TCA9555_INPUT_PORT_0;
status |= Select_Main_Head_Mux_Channel();
@@ -253,7 +303,8 @@ uint32_t Head_Read_IO_Reg(uint8_t TCA9555_ADDRESS, uint8_t Byte) //LOW/HIGH/LOW_
Head_I2C_EXP4_0x46.uchar[0] |= Read_Buf[0];
}
- if((Byte == HIGH) || (Byte == LOW_AND_HIGH))
+ else
+ if(Byte == HIGH)
{
Write_Buf[0] = TCA9555_INPUT_PORT_1;
status |= Select_Main_Head_Mux_Channel();
@@ -469,7 +520,7 @@ uint32_t HeadCard_Actuators_Control(ACTUATORS Act_ID, bool Direction)
}
-uint32_t HeadCard_Actuators_Stub(ACTUATORS Act_ID, bool Enable, bool Direction)
+uint32_t HeadCard_Actuators_Stub(ACTUATORS Act_ID, bool Enable, bool Direction)//ENABLE/DISABLE, DOWN/UP/DONTCARE
{
uint32_t status = OK;
@@ -599,6 +650,77 @@ uint8_t Head_Test_IO()
return status;
}
+typedef enum {
+ ActuatorIdle,
+ ActuatorMoveDown,
+ ActuatorWait, //wait for the actuator to get to the lower position
+ ActuatorMoveUp,
+ ActuatorLocated
+}ActuatorLocatingEnum;
+ActuatorLocatingEnum ActuatorLocating = ActuatorIdle;
+uint32_t ActuatorLocatingControl = 0xFF;
+uint32_t count_time = 0, moveuptime = 0;
+#define ACTUATOR_RELOCATING_MOVEUP_TIME 160
+uint32_t MovingUpTime = ACTUATOR_RELOCATING_MOVEUP_TIME;
+bool isActuatorOnLowestLocation(void)
+{
+#warning give here indication if the actuator reached the lowest point
+ return true;
+}
+uint32_t HeadCard_Actuators_Relocate_callback(uint32_t IfIndex, uint32_t BusyFlag) // use IfIndex for Act_ID
+{
+ count_time++;
+ switch (ActuatorLocating)
+ {
+ case ActuatorIdle:
+ break;
+ case ActuatorMoveDown:
+ Trigger_Head_Actuators_Stub(ACTIN, true, false);
+ ActuatorLocating = ActuatorWait;
+ ReportWithPackageFilter(ThreadFilter,"actuators relocation",__FILE__,msec_millisecondCounter,ActuatorLocating,RpMessage,count_time,0);
+ break;
+ case ActuatorWait:
+ if (isActuatorOnLowestLocation())
+ {
+ ActuatorLocating = ActuatorMoveUp;
+ Trigger_Head_Actuators_Stub(ACTIN, true, true);
+ moveuptime = count_time;
+ ReportWithPackageFilter(ThreadFilter,"actuators relocation",__FILE__,msec_millisecondCounter,ActuatorLocating,RpMessage,count_time,0);
+ }
+ break;
+ case ActuatorMoveUp:
+ if (count_time>=(moveuptime+MovingUpTime))
+ {
+ Trigger_Head_Actuators_Stub(ACTIN, false, false);
+ ActuatorLocating = ActuatorLocated;
+ ReportWithPackageFilter(ThreadFilter,"actuators relocation",__FILE__,msec_millisecondCounter,ActuatorLocating,RpMessage,count_time,0);
+ }
+ break;
+ case ActuatorLocated:
+ if (SafeRemoveControlCallback(ActuatorLocatingControl, HeadCard_Actuators_Relocate_callback )==OK)
+ ActuatorLocatingControl = 0xFF;
+ else
+ Report("Remove control callback failed",__FILE__,__LINE__,(int)ActuatorLocatingControl,RpWarning,(int)HeadCard_Actuators_Relocate_callback,0);
+ ReportWithPackageFilter(ThreadFilter,"actuators relocation",__FILE__,msec_millisecondCounter,ActuatorLocating,RpMessage,count_time,0);
+ break;
+ default:
+ break;
+ }
+ return ActuatorLocatingControl;
+}
+uint32_t HeadCard_Actuators_Relocate(void)
+{
+ if ((ActuatorLocating == ActuatorIdle)||(ActuatorLocating == ActuatorLocated))
+ {
+ ActuatorLocating = ActuatorMoveDown;
+ count_time = 0;
+ ReportWithPackageFilter(ThreadFilter,"actuators relocation",__FILE__,msec_millisecondCounter,ActuatorLocating,RpMessage,count_time,0);
+ ActuatorLocatingControl = AddControlCallback("Actuator Location", HeadCard_Actuators_Relocate_callback, eOneMillisecond, TemplateDataReadCBFunction,0,0, 0 );
+ }
+ return ActuatorLocatingControl;
+}
+
+
diff --git a/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/Head_Card/IO_Ports/Head_IO.h b/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/Head_Card/IO_Ports/Head_IO.h
index d927fdaa0..33187d1f6 100644
--- a/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/Head_Card/IO_Ports/Head_IO.h
+++ b/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/Head_Card/IO_Ports/Head_IO.h
@@ -198,6 +198,7 @@ uint32_t HeadCard_Valve_Control(bool Direction);
uint32_t HeadCard_Actuators_Stub(ACTUATORS Act_ID, bool Enable, bool Direction);
+uint32_t HeadCard_Actuators_Relocate(void);
//------------------------------
uint8_t Head_Test_IO();
diff --git a/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/I2C.c b/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/I2C.c
index a9f037942..c83fe6e50 100644
--- a/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/I2C.c
+++ b/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/I2C.c
@@ -17,11 +17,14 @@
#include "driverlib/sysctl.h"
#include "driverlib/i2c.h"
#include "I2C.h"
+#include "inc/hw_i2c.h"
#include "i2c_fifo.h"
#define I2C_DELAY 3000
uint8_t Main_Mux_Flag = UNKNOWN;
+uint32_t I2C_BUSY_DELAY = 100;
+
void InitI2C2()
{
//
@@ -71,7 +74,7 @@ void Configuring_Master_I2C2(/*uint32_t ui32SysClock*/)
I2CMasterInitExpClk(I2C2_BASE, ui32SysClock, false);//The last parameter sets the I2C data transfer rate: false for 100kbps and true for 400kbps
#endif
- i2c_fifo_setup(I2C2_BASE);
+ //i2c_fifo_setup(I2C2_BASE);
}
//--------------------------------------------------------------
@@ -125,7 +128,7 @@ void Configuring_Master_I2C3(/*uint32_t ui32SysClock*/)
I2CMasterInitExpClk(I2C3_BASE, ui32SysClock, false);//The last parameter sets the I2C data transfer rate: false for 100kbps and true for 400kbps
#endif
- i2c_fifo_setup(I2C3_BASE);
+ //i2c_fifo_setup(I2C3_BASE);
}
@@ -179,7 +182,7 @@ void Configuring_Master_I2C4(/*uint32_t ui32SysClock*/)
I2CMasterInitExpClk(I2C4_BASE, ui32SysClock, false);//The last parameter sets the I2C data transfer rate: false for 100kbps and true for 400kbps
#endif
- i2c_fifo_setup(I2C4_BASE);
+ //i2c_fifo_setup(I2C4_BASE);
}
void Init_All_I2C()
diff --git a/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/I2C.h b/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/I2C.h
index ed4c1228f..56c386aa8 100644
--- a/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/I2C.h
+++ b/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/I2C.h
@@ -10,8 +10,8 @@
extern uint32_t Arb_Loss_Count;
-
-#define I2C_BUSY_DELAY 5000//15000
+extern uint32_t I2C_BUSY_DELAY;
+//#define I2C_BUSY_DELAY 100//15000
uint32_t I2C_control(uint32_t I2C_ID, uint32_t Slave_Add, bool RW,uint32_t Byte2Write );
void Init_All_I2C();
@@ -26,8 +26,8 @@ uint32_t I2C_WriteBuff(uint32_t I2C_BASE, unsigned char addr, unsigned char* dat
uint32_t I2C_ReadBuff(uint32_t I2C_BASE, unsigned char addr, unsigned char* data, unsigned int len);
-uint32_t I2C_Write(uint32_t I2C_ID, uint32_t Slave_Add, uint32_t *I2C_Write_buf, uint32_t No_BytesToWrite );
-uint32_t I2C_Read(uint32_t I2C_ID, uint32_t Slave_Add, uint32_t *I2C_Read_buf, uint32_t No_BytesToRead );
+uint32_t I2C_Write(uint32_t I2C_ID, uint32_t Slave_Add, uint8_t *I2C_Write_buf, uint32_t No_BytesToWrite );
+uint32_t I2C_Read(uint32_t I2C_ID, uint32_t Slave_Add, uint8_t *I2C_Read_buf, uint32_t No_BytesToRead );
uint32_t Block_Main_MUX_TCA9548A_0xE4(); ////unused I2C MUX
diff --git a/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/I2C_Comm.c b/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/I2C_Comm.c
index 7c98b53da..182e5ccf7 100644
--- a/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/I2C_Comm.c
+++ b/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/I2C_Comm.c
@@ -26,6 +26,7 @@ uint32_t LastReadI2C_BASE; unsigned char LastReadaddr; unsigned char* LastReadda
uint32_t LastWriteI2C_BASE; unsigned char LastWriteaddr; unsigned char *LastWritedata; unsigned int LastWritelen;
Task_Handle TaskId;
uint32_t Arb_Loss_Count = 0;
+
//*****************************************************************************
//! Indicates whether or not the I2C bus has timed out.
//!
@@ -37,18 +38,6 @@ uint32_t Arb_Loss_Count = 0;
//! \return Returns \b true if the I2C bus has timed out; otherwise, returns
//! \b false.
//*****************************************************************************
-bool I2CMasterTimeout(uint32_t ui32Base)
-{
- // Return the bus timeout status
- if(HWREG(ui32Base + I2C_O_MCS) & I2C_MCS_CLKTO)
- {
- return(true);
- }
- else
- {
- return(false);
- }
-}
char I2CErrMsg[181];
uint32_t I2C_WriteBuff(uint32_t I2C_BASE, unsigned char addr, unsigned char* data, unsigned int len)
@@ -65,36 +54,29 @@ uint32_t I2C_WriteBuff(uint32_t I2C_BASE, unsigned char addr, unsigned char* dat
if (len == 1)
{
I2CMasterControl(I2C_BASE, I2C_MASTER_CMD_SINGLE_SEND);
- //while ( I2CMasterBusy(I2C_BASE) && !I2CMasterTimeout( I2C_BASE) );
-//
-// return I2CMasterErr(I2C_BASE) == I2C_MASTER_ERR_NONE;
+ SysCtlDelay(I2C_BUSY_DELAY);//The CPU waits for the Command processing to begin before it goes to check if the command is processed
status |= I2CMasterErr(I2C_BASE);
- SysCtlDelay(I2C_BUSY_DELAY);
+ while(I2CMasterBusy(I2C_BASE));
}
else
{
-
-
// Start sending consecutive data
I2CMasterControl(I2C_BASE, I2C_MASTER_CMD_BURST_SEND_START);
- //while ( I2CMasterBusy(I2C_BASE) && !I2CMasterTimeout( I2C_BASE) );
- // if (I2CMasterErr(I2C_BASE) != I2C_MASTER_ERR_NONE)
- // return false;
+ SysCtlDelay(I2C_BUSY_DELAY);//The CPU waits for the Command processing to begin before it goes to check if the command is processed
status |= I2CMasterErr(I2C_BASE);
- SysCtlDelay(I2C_BUSY_DELAY);
+ while(I2CMasterBusy(I2C_BASE));
+
len--;
data++;
-
// Continue sending consecutive data
while(len > 1){
I2CMasterDataPut(I2C_BASE, *data);
I2CMasterControl(I2C_BASE, I2C_MASTER_CMD_BURST_SEND_CONT);
- //while ( I2CMasterBusy(I2C_BASE) && !I2CMasterTimeout( I2C_BASE) );
- // if (I2CMasterErr(I2C_BASE) != I2C_MASTER_ERR_NONE)
- // return false;
+ SysCtlDelay(I2C_BUSY_DELAY);//The CPU waits for the Command processing to begin before it goes to check if the command is processed
status |= I2CMasterErr(I2C_BASE);
- SysCtlDelay(I2C_BUSY_DELAY);
+ while(I2CMasterBusy(I2C_BASE));
+
len--;
data++;
}
@@ -102,11 +84,9 @@ uint32_t I2C_WriteBuff(uint32_t I2C_BASE, unsigned char addr, unsigned char* dat
// Send last piece of data
I2CMasterDataPut(I2C_BASE, *data);
I2CMasterControl(I2C_BASE, I2C_MASTER_CMD_BURST_SEND_FINISH);
- //while ( I2CMasterBusy(I2C_BASE) && !I2CMasterTimeout( I2C_BASE) );
- //
- // return I2CMasterErr(I2C_BASE) == I2C_MASTER_ERR_NONE;
+ SysCtlDelay(I2C_BUSY_DELAY);//The CPU waits for the Command processing to begin before it goes to check if the command is processed
status |= I2CMasterErr(I2C_BASE);
- SysCtlDelay(I2C_BUSY_DELAY);
+ while(I2CMasterBusy(I2C_BASE));
}
return status;
@@ -133,25 +113,25 @@ uint32_t I2C_ReadBuff(uint32_t I2C_BASE, unsigned char addr, unsigned char* data
if (len == 1)
{
I2CMasterControl(I2C_BASE, I2C_MASTER_CMD_SINGLE_RECEIVE);
- //while ( I2CMasterBusy(I2C_BASE) && !I2CMasterTimeout( I2C_BASE) );
- SysCtlDelay(I2C_BUSY_DELAY);
- *data = I2CMasterDataGet(I2C_BASE);
-
- //return I2CMasterErr(I2C_BASE) == I2C_MASTER_ERR_NONE;
-
+ //On the TM4C129 we discovered a design behavior that due to higher system clock frequency and lower I2C baud rate,
+ //the CPU when it starts a I2C Transaction or writes a new I2C Command, for the I2C to respond to it takes time.
+ //So in effect the I2CMasterBusy statement gets skipped which causes The I2C controller to lose data.
+ //see: https://e2e.ti.com/support/microcontrollers/other/f/908/t/368493?Why-is-a-delay-needed-before-writing-the-first-byte-from-I2C-Master-
+ //therefore we need delay before waiting until bus is not busy - it doesn't work as expected without it or with while(!(I2CMasterBusy(I2C0_BASE)
+ SysCtlDelay(I2C_BUSY_DELAY);//The CPU waits for the Command processing to begin before it goes to check if the command is processed
status |= I2CMasterErr(I2C_BASE);
+ while(I2CMasterBusy(I2C_BASE));
+ *data = I2CMasterDataGet(I2C_BASE);
}
else
{
// Start receiving consecutive data
I2CMasterControl(I2C_BASE, I2C_MASTER_CMD_BURST_RECEIVE_START);
- //while ( I2CMasterBusy(I2C_BASE) && !I2CMasterTimeout( I2C_BASE) );
- SysCtlDelay(I2C_BUSY_DELAY);
- *data = I2CMasterDataGet(I2C_BASE);
- // if (I2CMasterErr(I2C_BASE) != I2C_MASTER_ERR_NONE)
- // return false;
+ SysCtlDelay(I2C_BUSY_DELAY);//The CPU waits for the Command processing to begin before it goes to check if the command is processed
status |= I2CMasterErr(I2C_BASE);
+ while(I2CMasterBusy(I2C_BASE));
+ *data = I2CMasterDataGet(I2C_BASE);
len--;
data++;
@@ -160,12 +140,10 @@ uint32_t I2C_ReadBuff(uint32_t I2C_BASE, unsigned char addr, unsigned char* data
// Continue receiving consecutive data
while(len > 1){
I2CMasterControl(I2C_BASE, I2C_MASTER_CMD_BURST_RECEIVE_CONT);
- //while ( I2CMasterBusy(I2C_BASE) && !I2CMasterTimeout( I2C_BASE) );
- SysCtlDelay(I2C_BUSY_DELAY);
+ SysCtlDelay(I2C_BUSY_DELAY);//The CPU waits for the Command processing to begin before it goes to check if the command is processed
+ status |= I2CMasterErr(I2C_BASE);
+ while(I2CMasterBusy(I2C_BASE));
*data = I2CMasterDataGet(I2C_BASE);
- // if (I2CMasterErr(I2C_BASE) != I2C_MASTER_ERR_NONE)
- // return false;
- status |= I2CMasterErr(I2C_BASE);
len--;
data++;
@@ -173,20 +151,17 @@ uint32_t I2C_ReadBuff(uint32_t I2C_BASE, unsigned char addr, unsigned char* data
// Receive last piece of data
I2CMasterControl(I2C_BASE, I2C_MASTER_CMD_BURST_RECEIVE_FINISH);
- //while ( I2CMasterBusy(I2C_BASE) && !I2CMasterTimeout( I2C_BASE) );
- SysCtlDelay(I2C_BUSY_DELAY);
- *data = I2CMasterDataGet(I2C_BASE);
-
- //return I2CMasterErr(I2C_BASE) == I2C_MASTER_ERR_NONE;
+ SysCtlDelay(I2C_BUSY_DELAY);//The CPU waits for the Command processing to begin before it goes to check if the command is processed
status |= I2CMasterErr(I2C_BASE);
+ while(I2CMasterBusy(I2C_BASE));
+ *data = I2CMasterDataGet(I2C_BASE);
}
return status;
}
-uint32_t I2C_Write(uint32_t I2C_ID, uint32_t Slave_Add, uint32_t *I2C_Write_buf, uint32_t No_BytesToWrite )
+uint32_t I2C_Write(uint32_t I2C_ID, uint32_t Slave_Add, uint8_t *I2C_Write_buf, uint32_t No_BytesToWrite )
{
uint32_t status = OK;
- uint8_t* buff = (uint8_t *)I2C_Write_buf;
uint32_t I2C_BASE;
if (I2C_ID == 4)
@@ -227,7 +202,7 @@ uint32_t I2C_Write(uint32_t I2C_ID, uint32_t Slave_Add, uint32_t *I2C_Write_buf,
{
//LastWriteI2C_BASE = I2C_BASE;
LastWriteaddr = Slave_Add;
- LastWritedata = buff;
+ LastWritedata = I2C_Write_buf;
LastWritelen = No_BytesToWrite;
TaskId = Task_self();
}
@@ -266,11 +241,10 @@ uint32_t I2C_Write(uint32_t I2C_ID, uint32_t Slave_Add, uint32_t *I2C_Write_buf,
return status;
}
-uint32_t I2C_Read(uint32_t I2C_ID, uint32_t Slave_Add, uint32_t *I2C_Read_buf, uint32_t No_BytesToRead )
+uint32_t I2C_Read(uint32_t I2C_ID, uint32_t Slave_Add, uint8_t *I2C_Read_buf, uint32_t No_BytesToRead )
{
uint32_t status = OK;
- uint8_t* buff = (uint8_t *)I2C_Read_buf;
uint32_t I2C_BASE;
if (I2C_ID == 4)
@@ -298,7 +272,7 @@ uint32_t I2C_Read(uint32_t I2C_ID, uint32_t Slave_Add, uint32_t *I2C_Read_buf, u
//Byte2Write = Byte2Write & 0xFF;
status = I2C_ReadBuff(I2C_BASE, Slave_Add, I2C_Read_buf, No_BytesToRead);
- //status = I2C_ReadFifo(I2C_BASE, Slave_Add, buff, No_BytesToRead);
+
if (status)
{
if (Arb_Loss_Count++ >= 5)
@@ -313,7 +287,7 @@ uint32_t I2C_Read(uint32_t I2C_ID, uint32_t Slave_Add, uint32_t *I2C_Read_buf, u
{
//LastReadI2C_BASE = I2C_BASE;
LastReadaddr = Slave_Add;
- LastReaddata = buff;
+ LastReaddata = I2C_Read_buf;
LastReadlen = No_BytesToRead;
TaskId = Task_self();
}
@@ -334,4 +308,3 @@ uint32_t I2C_Read(uint32_t I2C_ID, uint32_t Slave_Add, uint32_t *I2C_Read_buf, u
return status;
}
-
diff --git a/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/I2C_Task.c b/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/I2C_Task.c
index 44ab8d710..c06e8f4df 100644
--- a/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/I2C_Task.c
+++ b/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/I2C_Task.c
@@ -28,12 +28,14 @@
#include <Drivers/I2C_Communication/WHS_Card/IO_Extender_Ports_TCA9555/WHS_IO.h>
#include "ADC_MUX/ADC_MUX.h"
#include "modules/ids/ids_ex.h"
+#include <Drivers/I2C_Communication/Dispenser_Card/EEPROM/Dispenser_EEPROM.h>
extern Semaphore_Handle I2C_Sem;
Task_Handle I2C_Task_Handle;
Mailbox_Handle I2C_ReadingMsgQ = NULL;
typedef enum
{
+ Head_IO_Initialization,
Midtank_Pressure_Reading,
Heater_Current_Reading,
PT100_Reading,
@@ -87,6 +89,17 @@ typedef struct I2C_ReadingMessage{
uint8_t* parameter3;
}I2C_ReadingMessageStruc;
+
+void Trigger_Head_io_Init(void)
+{
+ I2C_ReadingMessageStruc I2C_ReadingMessage;
+
+ I2C_ReadingMessage.messageId = Head_IO_Initialization;
+ if (I2C_ReadingMsgQ != NULL)
+ Mailbox_post(I2C_ReadingMsgQ , &I2C_ReadingMessage, BIOS_NO_WAIT);
+ return;
+}
+
void Trigger_Heater_Current_Read(void)
{
I2C_ReadingMessageStruc I2C_ReadingMessage;
@@ -583,6 +596,9 @@ void I2C_ReadingTask(UArg arg0, UArg arg1)
//Report("------------ I2C task - messageId -------------", __FILE__,__LINE__, (int)(I2C_ReadingMessage.messageId), RpMessage, 0, 0);
switch (I2C_ReadingMessage.messageId)
{
+ case Head_IO_Initialization:
+ Head_IO_Init();
+ break;
case Midtank_Pressure_Reading:
//Report("Read_MidTank_Pressure_Sensor",__FILE__,__LINE__,255,RpWarning,0,0);
Read_MidTank_Pressure_Sensor(I2C_ReadingMessage.parameter);
diff --git a/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/I2C_Task.h b/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/I2C_Task.h
index 20fcb0074..2a98296b4 100644
--- a/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/I2C_Task.h
+++ b/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/I2C_Task.h
@@ -9,7 +9,7 @@
#ifndef DRIVERS_I2C_COMMUNICATION_I2C_TASK_H_
#define DRIVERS_I2C_COMMUNICATION_I2C_TASK_H_
-
+void Trigger_Head_io_Init(void);
void Trigger_WHS_init_IO(void);
void Trigger_WHS_init_fan(void);
void Trigger_WHS_init_PT100(void);
diff --git a/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/WHS_Card/D_MAX11614_ADC/MAX11614_Driver.c b/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/WHS_Card/D_MAX11614_ADC/MAX11614_Driver.c
index ae37bf938..559cc0375 100644
--- a/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/WHS_Card/D_MAX11614_ADC/MAX11614_Driver.c
+++ b/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/WHS_Card/D_MAX11614_ADC/MAX11614_Driver.c
@@ -23,7 +23,7 @@ bool MAX11614_Read_allADC(uint8_t i2cbus, WHS_chip_address i2cadd, uint16_t *p_v
status |= I2C_Read(i2cbus, i2cadd + 1, p_value , 0x10);//&p_value
- delayUs(10);//TODO - check the delay
+ //delayUs(10);//TODO - check the delay
return status;
}
diff --git a/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/WHS_Card/D_MAX11614_ADC/WHS_MAX11614_A2D.c b/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/WHS_Card/D_MAX11614_ADC/WHS_MAX11614_A2D.c
index db9ee1053..bb41e1af3 100644
--- a/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/WHS_Card/D_MAX11614_ADC/WHS_MAX11614_A2D.c
+++ b/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/WHS_Card/D_MAX11614_ADC/WHS_MAX11614_A2D.c
@@ -22,6 +22,7 @@
#include "drivers/Flash_ram/MCU_E2Prom.h"
#include <Drivers/I2C_Communication/WHS_Card/EEPROM/WHS_EEPROM.h>
#include "modules/control/control.h"
+#include "modules/General/process.h"
uint16_t Orf_zero_value[DRIER_FLOW_METER+1] = {1112,0,1040};
@@ -79,7 +80,7 @@ uint32_t WHS_MAX11614_Read_allADC( )
status |= MAX11614_Read_allADC(U20_MAX11614.MAX11614_I2CBUS, U20_MAX11614.MAX11614_I2CADDR, U20_MAX11614.MAX11614_Read_Buf);
- delayUs(10);//TODO - check the delay
+ //delayUs(10);//TODO - check the delay
return status;
}
@@ -540,7 +541,7 @@ double CalculateWHSWasteTankLevelMiliLiter()
get_vlev1(&Vm_mv);//mV (VREF = 4.096V 12bit so 1bit is 1mV)
- Report("***** get waste level in mV ********", __FILE__, __LINE__, 0, RpMessage, (int)(Vm_mv), 0);
+ //Report("***** get waste level in mV ********", __FILE__, __LINE__, 0, RpMessage, (int)(Vm_mv), 0);
Vm_ml = Vm_mv * 1500/mvfor1500mL;
@@ -554,11 +555,12 @@ double CalculateWHSWasteTankLevelMiliLiter()
waste_volume_milliliter = Vm_ml -LocalV0_ml;
}
//ReportWithPackageFilter(WasteFilter,"------------ waste_volume_ml -----------------", __FILE__, __LINE__, 0, RpMessage, (int)(waste_volume_milliliter), 0);
- Report("------------ get waste level in ml -----------------", __FILE__, LocalV0_ml, Vm_ml, RpMessage, (int)(waste_volume_milliliter), 0);
+ //Report("------------ get waste level in ml -----------------", __FILE__, LocalV0_ml, Vm_ml, RpMessage, (int)(waste_volume_milliliter), 0);
return waste_volume_milliliter;
}
uint32_t WasteControlId = 0xFF;
+bool ContinouosWaste = false, regularWaste = false;
typedef enum
{
Open_Valve,
@@ -566,6 +568,7 @@ typedef enum
Read_Waste
}Waste_Tank_Procedure_Enum;
int nop = 0;
+int FirstInSequence = true;
Waste_Tank_Procedure_Enum OpenClose = Open_Valve;
bool waste_seq_cont()
{
@@ -592,7 +595,7 @@ bool waste_seq_cont()
if (WasteAverageIndex >= 8)
WasteAverageIndex = 0;
WasteCounter++;
- Report("------------ waste level procedure read -----------------", __FILE__, WasteAverageIndex, OpenClose, RpMessage, (int)(WasteAverageContent[WasteAverageIndex-1]), 0);
+ //Report("------------ waste level procedure read -----------------", __FILE__, WasteAverageIndex, OpenClose, RpMessage, (int)(WasteAverageContent[WasteAverageIndex-1]), 0);
OpenClose = Open_Valve;
break;
}
@@ -609,6 +612,17 @@ bool waste_seq_cont()
Report("------------ Avg waste level in ml -----------------", __FILE__, WasteAverageIndex, avg, RpMessage, (int)(waste_level_ml), 0);
}
+ if (FirstInSequence == false)
+ {
+ if (WasteCounter == 4)
+ {
+ for (i = 0; i<8;i++)
+ {
+ avg+=WasteAverageContent[i];
+ }
+ waste_level_ml = avg/8;
+ }
+ }
return status;
}
@@ -624,19 +638,19 @@ bool waste_seq_step2()
case Open_Valve:
Set_WHS_valve(VOC_VALVE, OPEN, 0);
Write_WHS_Valve_reg();
- Report("------------ waste level procedure open -----------------", __FILE__, WasteAverageIndex, OpenClose, RpMessage, (int)(waste_level_ml), 0);
+ //Report("------------ waste level procedure open -----------------", __FILE__, WasteAverageIndex, OpenClose, RpMessage, (int)(waste_level_ml), 0);
OpenClose = Close_Valve;
break;
case Close_Valve:
Set_WHS_valve(VOC_VALVE, CLOSE, 0);
Write_WHS_Valve_reg();
- Report("------------ waste level procedure close ----------------", __FILE__, WasteAverageIndex, OpenClose, RpMessage, (int)(waste_level_ml), 0);
+ //Report("------------ waste level procedure close ----------------", __FILE__, WasteAverageIndex, OpenClose, RpMessage, (int)(waste_level_ml), 0);
OpenClose = Read_Waste;
break;
case Read_Waste:
WasteAverageContent[WasteAverageIndex++] = CalculateWHSWasteTankLevelMiliLiter();
WasteCounter++;
- Report("------------ waste level procedure read -----------------", __FILE__, WasteAverageIndex, OpenClose, RpMessage, (int)(WasteAverageContent[WasteAverageIndex-1]), 0);
+ //Report("------------ waste level procedure read -----------------", __FILE__, WasteAverageIndex, OpenClose, RpMessage, (int)(WasteAverageContent[WasteAverageIndex-1]), 0);
OpenClose = Open_Valve;
break;
}
@@ -656,11 +670,14 @@ bool waste_seq_step2()
WasteCounter = 0;
waste_level_ml = avg/8;
+ regularWaste = false;
+ if (ContinouosWaste == true)
+ waste_seq_step1_cont();
+
Report("------------ Avg waste level in ml -----------------", __FILE__, WasteCounter, OpenClose, RpMessage, (int)(waste_level_ml), 0);
}
return status;
}
-bool ContinouosWaste = false;
#define WASTE_PROCESS_TIME 1000
bool waste_seq_step1_cont()
{
@@ -671,6 +688,9 @@ bool waste_seq_step1_cont()
ContinouosWaste = true;
+ if (regularWaste == true)
+ return status;
+
Trigger_SetWHS_VOC_Valve(OPEN);
WasteControlId = AddControlCallback(NULL, Trigger_ReadWHS_WasteContinouos, WASTE_PROCESS_TIME, TemplateDataReadCBFunction,0,0, 0 );
@@ -690,11 +710,16 @@ bool waste_seq_cont_stop(void)
//else
// Report("Remove control callback failed",__FILE__,__LINE__,(int)WasteControlId,RpWarning,(int)waste_seq_step2,0);
+
return OK;
}
bool waste_seq_step1()
{
bool status = OK;
+ if (MachineReadyForHeating == false)
+ {
+ return OK;
+ }
if (ContinouosWaste == true)
{
Report("------- periodic waste called while emptying ------------", __FILE__, __LINE__, 0, RpMessage, 0, 0);
@@ -703,6 +728,7 @@ bool waste_seq_step1()
WasteAverageIndex = 0;
WasteCounter = 0;
OpenClose = CLOSE;
+ regularWaste = true;
Report("------------ open waste level Air valve -----------------", __FILE__, __LINE__, WHS_Eeprom.bytes.Orifice_Waste_Level_V0_ml, RpMessage, 0, 0);
Trigger_SetWHS_VOC_Valve(OPEN);
diff --git a/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/WHS_Card/D_Max5805_ADC_Blower/WHS_Blower.c b/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/WHS_Card/D_Max5805_ADC_Blower/WHS_Blower.c
index 211d7cbef..32d82f8af 100644
--- a/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/WHS_Card/D_Max5805_ADC_Blower/WHS_Blower.c
+++ b/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/WHS_Card/D_Max5805_ADC_Blower/WHS_Blower.c
@@ -84,9 +84,8 @@ int32_t i2c_smbus_read_word_data(int i2cFileDescriptor, uint8_t command_regAddre
uint32_t status= OK;
uint8_t Write_Buf[1];
-
Write_Buf[0] = command_regAddress;
- status |= Block_Main_Head_Mux_Channel();
+
status |= Select_Main_WHS_Mux_Channel();
status |= I2C_Write(I2C_ID_WHS_CARD, I2CDAC_ADDRESS, Write_Buf, 1);
@@ -408,7 +407,7 @@ void WHS_Set_IFS_Clearing_Suction (int midtank)
}
#define MAX_ALLOWED_BLOWER_VOLTAGE 4300
-#define MIN_ALLOWED_BLOWER_VOLTAGE 2000
+#define MIN_ALLOWED_BLOWER_VOLTAGE 2400
bool BlowerAlarmActive = false;
void SendLimitedBlowerControl(int mV)
{
@@ -544,7 +543,7 @@ bool WHS_Set_Blower_Control_Closed_Loop(double Q_value)
}
}
}
- Report("------------ Blower Control :-----------------", __FILE__,Orf_zero_value[HEAD_FLOW_METER], (int)(current_dying_head_flow_Q*100), RpMessage, (int)(Q_value*100), 0);
+ //Report("------------ Blower Control :-----------------", __FILE__,Orf_zero_value[HEAD_FLOW_METER], (int)(current_dying_head_flow_Q*100), RpMessage, (int)(Q_value*100), 0);
return OK;
}
diff --git a/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/WHS_Card/D_TCA9546_ADC_MUX/TCA9546_Driver.c b/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/WHS_Card/D_TCA9546_ADC_MUX/TCA9546_Driver.c
index f7fe99aed..f5e14a48e 100644
--- a/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/WHS_Card/D_TCA9546_ADC_MUX/TCA9546_Driver.c
+++ b/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/WHS_Card/D_TCA9546_ADC_MUX/TCA9546_Driver.c
@@ -24,6 +24,8 @@ bool D_TCA9546_Select_Channel(uint8_t TCA9546A_I2C_bus_number, uint8_t TCA9546A_
uint8_t Write_Buf[1] = {0};
uint8_t Read_buf[1] = {0};
+ //Select_Main_WHS_Mux_Channel();
+
status |= I2C_Write(TCA9546A_I2C_bus_number, TCA9546A_I2C_addr, Write_Buf, 1); //status |= I2C_Write(I2C_ID_HEAD_CARD, TCA9555_ADDRESS, Write_Buf, 2);
delayUs(10);//TODO - check the delay
status = I2C_Read(TCA9546A_I2C_bus_number, TCA9546A_I2C_addr+1, Read_buf, 1 );
@@ -47,6 +49,8 @@ bool D_TCA9546_Read_Channel(uint32_t TCA9546A_I2C_bus_number, uint32_t TCA9546A_
bool status= OK;
uint8_t Read_buf[1];
+ //Select_Main_WHS_Mux_Channel();
+
status = I2C_Read(TCA9546A_I2C_bus_number, TCA9546A_I2C_addr, Read_buf, 1 );
if (Read_buf[1] & chnl_number )
{
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 74083e67a..0b859cc79 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
@@ -24,7 +24,7 @@
//uint32_t I2C_WHS_EEPROM_SLAVE_ADD = 0xA0;
WHS_EEPROM WHS_Eeprom;
-uint8_t WHS_Type = WHS_TYPE_UNKNOWN;
+WHS_TYPE WHS_Type = WHS_TYPE_UNKNOWN;
#define MAX_ALLOWS_PAGE_WRITE 256
#define MIN_READ_BYTE 1
diff --git a/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/WHS_Card/I2C_WHS_Mux.c b/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/WHS_Card/I2C_WHS_Mux.c
index a5d36a264..1ada4f24a 100644
--- a/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/WHS_Card/I2C_WHS_Mux.c
+++ b/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/WHS_Card/I2C_WHS_Mux.c
@@ -19,7 +19,7 @@ uint32_t Select_Main_WHS_Mux_Channel()
{
uint32_t status= OK;
- uint8_t Write_Buf[1];
+ uint8_t Write_Buf[1] = {0};
if(Main_Mux_Flag != WHS)
{
@@ -39,7 +39,9 @@ uint32_t Block_Main_WHS_Mux_Channel()
{
uint32_t status= OK;
- uint8_t Write_Buf[1];
+ uint8_t Write_Buf[1] = {0};
+
+ Main_Mux_Flag = UNKNOWN;
Write_Buf[0] = 0x00;//Block all
diff --git a/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/WHS_Card/IO_Extender_Ports_TCA9555/TCA9555_Driver.c b/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/WHS_Card/IO_Extender_Ports_TCA9555/TCA9555_Driver.c
index cf615f424..c357dbcb1 100644
--- a/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/WHS_Card/IO_Extender_Ports_TCA9555/TCA9555_Driver.c
+++ b/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/WHS_Card/IO_Extender_Ports_TCA9555/TCA9555_Driver.c
@@ -36,16 +36,12 @@ struct TCA9555_params
uint32_t D_TCA9555ConfigDirection(uint8_t TCA9555_I2C_bus_number, uint8_t TCA9555_ADDRESS, uint8_t Config_dir_PORT_0, uint8_t Config_dir_PORT_1)
{
uint32_t status= OK;
- uint8_t Write_Buf[2];
+ uint8_t Write_Buf[3];
Write_Buf[0] = TCA9555_CONFIG_PORT_0;
Write_Buf[1] = Config_dir_PORT_0;
- status |= I2C_Write(TCA9555_I2C_bus_number, TCA9555_ADDRESS, Write_Buf, 2); /*status |= I2C_Write(I2C_ID_HEAD_CARD, TCA9555_ADDRESS, Write_Buf, 2);*/
-
-
- Write_Buf[0] = TCA9555_CONFIG_PORT_1;
- Write_Buf[1] = Config_dir_PORT_1;
- status |= I2C_Write(TCA9555_I2C_bus_number, TCA9555_ADDRESS, Write_Buf, 2); /*status |= I2C_Write(I2C_ID_HEAD_CARD, TCA9555_ADDRESS, Write_Buf, 2);*/
+ Write_Buf[2] = Config_dir_PORT_1;
+ status |= I2C_Write(TCA9555_I2C_bus_number, TCA9555_ADDRESS, Write_Buf, 3);
return status;
}
diff --git a/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/test_fifo_dma.c b/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/test_fifo_dma.c
new file mode 100644
index 000000000..75028fc4a
--- /dev/null
+++ b/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/test_fifo_dma.c
@@ -0,0 +1,763 @@
+/*
+ * test_fifo_dma.c
+ *
+ * Created on: Jul 1, 2020
+ * Author: avi
+ */
+
+//*****************************************************************************
+//
+// ektm4c129_i2c_master_udma_fifo.c - I2C Master with UDMA and FIFO Data Transfer
+//
+// Copyright (c) 2013-2015 Texas Instruments Incorporated. All rights reserved.
+// Software License Agreement
+//
+// Texas Instruments (TI) is supplying this software for use solely and
+// exclusively on TI's microcontroller products. The software is owned by
+// TI and/or its suppliers, and is protected under applicable copyright
+// laws. You may not combine this software with "viral" open-source
+// software in order to form a larger program.
+//
+// THIS SOFTWARE IS PROVIDED "AS IS" AND WITH ALL FAULTS.
+// NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT
+// NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. TI SHALL NOT, UNDER ANY
+// CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
+// DAMAGES, FOR ANY REASON WHATSOEVER.
+//
+// This is part of revision 2.1.1.71 of the EK-TM4C1294XL Firmware Package.
+//
+//*****************************************************************************
+#include <stdint.h>
+#include <stdbool.h>
+#include "inc/hw_types.h"
+#include "inc/hw_i2c.h"
+#include "inc/hw_ints.h"
+#include "inc/hw_memmap.h"
+#include "inc/hw_udma.h"
+#include "driverlib/gpio.h"
+#include "driverlib/i2c.h"
+#include "driverlib/interrupt.h"
+#include "driverlib/pin_map.h"
+#include "driverlib/sysctl.h"
+#include "driverlib/uart.h"
+#include "driverlib/udma.h"
+#include "utils/random.h"
+#include "utils/uartstdio.h"
+
+//*****************************************************************************
+//
+//! \addtogroup example_list
+//! <h1>ektm4c129_i2c_master_udma_fifo (ektm4c129_i2c_master_udma_fifo)</h1>
+//!
+//! A Simple I2C Master Code for Performing Data Transfer with UDMA and
+//! I2CFIFODATA register
+//
+//*****************************************************************************
+
+//*****************************************************************************
+//
+// Define for I2C Module
+//
+//*****************************************************************************
+uint8_t SLAVE_ADDRESS_EXT;
+#define NUM_OF_I2CBYTES 255
+
+//*****************************************************************************
+//
+// Enumerated Data Types for Master State Machine
+//
+//*****************************************************************************
+enum I2C_MASTER_STATE
+{
+ I2C_OP_IDLE = 0,
+ I2C_OP_TXADDR,
+ I2C_OP_FIFO,
+ I2C_OP_TXDATA,
+ I2C_OP_RXDATA,
+ I2C_OP_STOP,
+ I2C_ERR_STATE
+};
+
+//*****************************************************************************
+//
+// Global variable for Delay Count
+//
+//*****************************************************************************
+volatile uint16_t g_ui16SlaveWordAddress;
+uint8_t g_ui8MasterTxData[NUM_OF_I2CBYTES];
+uint8_t g_ui8MasterRxData[NUM_OF_I2CBYTES];
+volatile uint8_t g_ui8MasterCurrState;
+volatile uint8_t g_ui8MasterPrevState;
+volatile bool g_bI2CDirection;
+volatile bool g_bI2CRepeatedStart;
+volatile uint8_t g_ui8MasterBytes = NUM_OF_I2CBYTES;
+volatile uint8_t g_ui8MasterBytesLength = NUM_OF_I2CBYTES;
+
+
+uint32_t ui32TxArbSize, ui32RxArbSize;
+
+//*****************************************************************************
+//
+// The control table used by the uDMA controller. This table must be aligned
+// to a 1024 byte boundary.
+//
+//*****************************************************************************
+#if defined(ewarm)
+#pragma data_alignment=1024
+uint8_t pui8ControlTable[1024];
+#elif defined(ccs)
+#pragma DATA_ALIGN(pui8ControlTable, 1024)
+uint8_t pui8ControlTable[1024];
+#else
+uint8_t pui8ControlTable[1024] __attribute__ ((aligned(1024)));
+#endif
+
+//*****************************************************************************
+//
+// Interrupt Handler for I2C Master Interface
+//
+//*****************************************************************************
+void
+I2C3IntHandler(void)
+{
+ uint32_t ui32I2CMasterInterruptStatus;
+
+ //
+ // Toggle PL4 High to Indicate Entry to ISR
+ //
+ ///GPIOPinWrite(GPIO_PORTL_BASE, GPIO_PIN_4, GPIO_PIN_4);
+
+ //
+ // Get the masked interrupt status and clear the flags
+ //
+ ui32I2CMasterInterruptStatus = I2CMasterIntStatusEx(I2C3_BASE, true);
+ I2CMasterIntClearEx(I2C3_BASE, ui32I2CMasterInterruptStatus);
+
+ //
+ // Execute the State Machine
+ //
+ switch (g_ui8MasterCurrState) {
+ case I2C_OP_IDLE:
+ //
+ // Move from IDLE to Transmit Address State
+ //
+ g_ui8MasterPrevState = g_ui8MasterCurrState;
+ g_ui8MasterCurrState = I2C_OP_TXADDR;
+
+ //
+ // Write the upper bits of the page to the Slave
+ //
+ I2CMasterSlaveAddrSet(I2C3_BASE, SLAVE_ADDRESS_EXT, false);
+ I2CMasterDataPut(I2C3_BASE, (g_ui16SlaveWordAddress >> 8));
+ I2CMasterControl(I2C3_BASE, I2C_MASTER_CMD_BURST_SEND_START);
+ break;
+
+ case I2C_OP_TXADDR:
+ //
+ // Assign the current state to the previous state
+ //
+ g_ui8MasterPrevState = g_ui8MasterCurrState;
+
+ //
+ // If Address has been NAK'ed then go to stop state
+ // else go the FIFO Priming State
+ //
+ if(ui32I2CMasterInterruptStatus & I2C_MASTER_INT_NACK)
+ {
+ g_ui8MasterCurrState = I2C_OP_STOP;
+ }
+ else
+ {
+ g_ui8MasterCurrState = I2C_OP_FIFO;
+ }
+
+ //
+ // Write the lower bits of the page to the Slave if
+ // Address has been ACK-ed
+ //
+ I2CMasterDataPut(I2C3_BASE, (g_ui16SlaveWordAddress >> 0));
+ I2CMasterControl(I2C3_BASE, I2C_MASTER_CMD_BURST_SEND_CONT);
+ break;
+
+ case I2C_OP_FIFO:
+ //
+ // If Last Data has been NAK'ed then go to stop state
+ //
+ if(ui32I2CMasterInterruptStatus & I2C_MASTER_INT_NACK)
+ {
+ g_ui8MasterCurrState = I2C_OP_STOP;
+ }
+ //
+ // Based on the direction move to the appropriate state
+ // of Transmit or Receive. Also send the BURST command
+ // for FIFO Operations.
+ //
+ else if(!g_bI2CDirection)
+ {
+ g_ui8MasterCurrState = I2C_OP_TXDATA;
+ I2CMasterControl(I2C3_BASE, I2C_MASTER_CMD_FIFO_BURST_SEND_FINISH);
+ }
+ else
+ {
+ g_ui8MasterCurrState = I2C_OP_RXDATA;
+ I2CMasterSlaveAddrSet(I2C3_BASE, SLAVE_ADDRESS_EXT, true);
+ I2CMasterControl(I2C3_BASE, I2C_MASTER_CMD_FIFO_SINGLE_RECEIVE);
+ }
+ break;
+
+ case I2C_OP_TXDATA:
+ //
+ // Move the current state to the previous state
+ // Else continue with the transmission till last byte
+ //
+ g_ui8MasterPrevState = g_ui8MasterCurrState;
+
+ //
+ // If Address or Data has been NAK'ed then go to stop state
+ // If a Stop condition is seen due to number of bytes getting
+ // done then move to STOP state
+ //
+ if(ui32I2CMasterInterruptStatus & I2C_MASTER_INT_NACK)
+ {
+ g_ui8MasterCurrState = I2C_OP_STOP;
+ }
+ else if(ui32I2CMasterInterruptStatus & I2C_MASTER_INT_STOP)
+ {
+ g_ui8MasterCurrState = I2C_OP_STOP;
+ }
+ else if(ui32I2CMasterInterruptStatus & I2C_MASTER_INT_TX_DMA_DONE)
+ {
+ g_ui8MasterCurrState = I2C_OP_STOP;
+ }
+ else
+ {
+ g_ui8MasterCurrState = I2C_ERR_STATE;
+ }
+ break;
+
+ case I2C_OP_RXDATA:
+ //
+ // Move the current state to the previous state
+ // Else continue with the transmission till last byte
+ //
+ g_ui8MasterPrevState = g_ui8MasterCurrState;
+
+ //
+ // If Address has been NAK'ed then go to stop state
+ // If a Stop condition is seen due to number of bytes getting
+ // done then move to STOP state and read the last data byte
+ //
+ if(ui32I2CMasterInterruptStatus & I2C_MASTER_INT_NACK)
+ {
+ g_ui8MasterCurrState = I2C_OP_STOP;
+ }
+ else if(ui32I2CMasterInterruptStatus & I2C_MASTER_INT_STOP)
+ {
+ g_ui8MasterCurrState = I2C_OP_STOP;
+ }
+ else if(ui32I2CMasterInterruptStatus & I2C_MASTER_INT_RX_DMA_DONE)
+ {
+ g_ui8MasterCurrState = I2C_OP_STOP;
+ }
+ break;
+
+ case I2C_OP_STOP:
+ //
+ // Move the current state to the previous state
+ // Else continue with the transmission till last byte
+ //
+ g_ui8MasterPrevState = g_ui8MasterCurrState;
+ break;
+
+ case I2C_ERR_STATE:
+ g_ui8MasterCurrState = I2C_ERR_STATE;
+ break;
+
+ default:
+ g_ui8MasterCurrState = I2C_ERR_STATE;
+ break;
+ }
+
+ //
+ // Toggle PL4 Low to Indicate Exit from ISR
+ //
+ ///GPIOPinWrite(GPIO_PORTL_BASE, GPIO_PIN_4, 0x0);
+}
+
+//*****************************************************************************
+//
+// This function sets up UDMA Channel Control Structures for TX
+//
+//*****************************************************************************
+void
+ConfigureuDMATX(uint8_t ui8Length, uint32_t ui32ArbSize)
+{
+ //
+ // Put the attributes in a known state for the uDMA channel.
+ // These should already be disabled by default.
+ //
+ uDMAChannelAttributeDisable(UDMA_CH19_I2C3TX,
+ UDMA_ATTR_USEBURST | UDMA_ATTR_ALTSELECT |
+ (UDMA_ATTR_HIGH_PRIORITY |
+ UDMA_ATTR_REQMASK));
+
+ //
+ // Configure the control parameters for the I2C2 TX channel. The channel
+ // will be used to transfer between memory buffer and I2CFIFODATA register
+ // 8 bits at a time. Therefore the data size is 8 bits, and the address
+ // increment is 8 bits for source. The destination increment is none.
+ // The arbitration size will be set based on the TX FIFO Threshold, which
+ // causes the uDMA controller to rearbitrate after N items are transferred.
+ // This keeps this channel from hogging the uDMA controller once the transfer
+ // is started and allows other channels cycles if they are higher priority.
+ //
+ uDMAChannelControlSet(UDMA_CH19_I2C3TX | UDMA_PRI_SELECT,
+ UDMA_SIZE_8 | UDMA_SRC_INC_8 | UDMA_DST_INC_NONE |
+ ui32ArbSize);
+
+ //
+ // Set up the transfer parameters for the hardware channel. This will
+ // configure the transfer buffers and the transfer size. Basic mode
+ // is used in this example
+ //
+ uDMAChannelTransferSet(UDMA_CH19_I2C3TX | UDMA_PRI_SELECT,
+ UDMA_MODE_BASIC, g_ui8MasterTxData,
+ (void *)(I2C3_BASE + I2C_O_FIFODATA),
+ ui8Length);
+
+ //
+ // The channel must be enabled. For hardware based transfers, a request
+ // must be issued by the peripheral. After this, the uDMA memory transfer begins.
+ //
+ uDMAChannelEnable(UDMA_CH19_I2C3TX);
+
+}
+
+//*****************************************************************************
+//
+// This function sets up UDMA Channel Control Structures for RX
+//
+//*****************************************************************************
+void
+ConfigureuDMARX(uint8_t ui8Length, uint32_t ui32ArbSize)
+{
+ //
+ // Put the attributes in a known state for the uDMA software channel.
+ // These should already be disabled by default.
+ //
+ uDMAChannelAttributeDisable(UDMA_CH18_I2C3RX,
+ UDMA_ATTR_USEBURST | UDMA_ATTR_ALTSELECT |
+ (UDMA_ATTR_HIGH_PRIORITY |
+ UDMA_ATTR_REQMASK));
+
+ //
+ // Configure the control parameters for the I2C2 RX channel. The channel
+ // will be used to transfer between I2CFIFODATA register and memory buffers,
+ // 8 bits at a time. Therefore the data size is 8 bits, and the address
+ // increment is 8 bits for destination. The source increment is none.
+ // The arbitration size will be set based on the RX FIFO Threshold, which
+ // causes the uDMA controller to rearbitrate after N items are transferred.
+ // This keeps this channel from hogging the uDMA controller once the transfer
+ // is started and allows other channels cycles if they are higher priority.
+ //
+ uDMAChannelControlSet(UDMA_CH18_I2C3RX | UDMA_PRI_SELECT,
+ UDMA_SIZE_8 | UDMA_SRC_INC_NONE | UDMA_DST_INC_8 |
+ ui32ArbSize);
+
+ //
+ // Set up the transfer parameters for the hardware channel. This will
+ // configure the transfer buffers and the transfer size. Basic mode
+ // is used in this example
+ //
+ uDMAChannelTransferSet(UDMA_CH18_I2C3RX | UDMA_PRI_SELECT,
+ UDMA_MODE_BASIC, (void *)(I2C3_BASE + I2C_O_FIFODATA),
+ g_ui8MasterRxData,
+ ui8Length);
+
+ //
+ // The channel must be enabled. For hardware based transfers, a request
+ // must be issued by the peripheral. After this, the uDMA memory transfer begins.
+ //
+ uDMAChannelEnable(UDMA_CH18_I2C3RX);
+
+}
+
+//*****************************************************************************
+//
+// This function sets up UART0 to be used for a console to display information
+// as the example is running.
+//
+//*****************************************************************************
+/*
+void
+InitConsole(void)
+{
+ //
+ // Enable GPIO port A which is used for UART0 pins.
+ // TODO: change this to whichever GPIO port you are using.
+ //
+ SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
+
+ //
+ // Configure the pin muxing for UART0 functions on port A0 and A1.
+ // This step is not necessary if your part does not support pin muxing.
+ // TODO: change this to select the port/pin you are using.
+ //
+ GPIOPinConfigure(GPIO_PA0_U0RX);
+ GPIOPinConfigure(GPIO_PA1_U0TX);
+
+ //
+ // Enable UART0 so that we can configure the clock.
+ //
+ SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0);
+
+ //
+ // Use the internal 16MHz oscillator as the UART clock source.
+ //
+ UARTClockSourceSet(UART0_BASE, UART_CLOCK_PIOSC);
+
+ //
+ // Select the alternate (UART) function for these pins.
+ // TODO: change this to select the port/pin you are using.
+ //
+ GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1);
+
+ //
+ // Initialize the UART for console I/O.
+ //
+ UARTStdioConfig(0, 115200, 16000000);
+}
+*/
+//*****************************************************************************
+//
+// Main Program to Configure and Use the I2C Master
+//
+//*****************************************************************************
+int
+InitI2C3_udma_fifo(void)
+{
+ uint32_t ui32SysClock;
+ uint8_t /*ui8Count, */ui8MasterBytesLength;
+ //
+
+
+ //
+ // Set up the serial console to use for displaying messages. This is
+ // just for this example program and is not needed for EPI operation.
+ //
+ ///InitConsole();
+
+ //
+ // Display the setup on the console.
+ //
+ ///UARTprintf("\033[2J\033[H");
+ ///UARTprintf("\r\nExample Code for I2C Master with");
+ ///UARTprintf("\nUDMA and FIFO Data Transfer\n\n");
+
+ //
+ // Stop the Clock, Reset and Enable UDMA Module
+ // in Master Function
+ //
+ SysCtlPeripheralDisable(SYSCTL_PERIPH_UDMA);
+ SysCtlPeripheralReset(SYSCTL_PERIPH_UDMA);
+ SysCtlPeripheralEnable(SYSCTL_PERIPH_UDMA);
+
+ //
+ // Wait for the Peripheral to be ready for programming
+ //
+ while(!SysCtlPeripheralReady(SYSCTL_PERIPH_UDMA));
+
+ //
+ // Enable the uDMA controller.
+ //
+ uDMAEnable();
+
+ //
+ // Point at the control table to use for channel control structures.
+ //
+ uDMAControlBaseSet(pui8ControlTable);
+
+ //
+ // Assign the UDMA Channel for I2C2 RX and TX DMA Request
+ //
+ uDMAChannelAssign(UDMA_CH18_I2C3RX);
+ uDMAChannelAssign(UDMA_CH19_I2C3TX);
+
+ //
+ // Enable GPIO for Configuring the I2C Interface Pins
+ //
+ SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOR);
+
+ //
+ // Wait for the Peripheral to be ready for programming
+ //
+ while(!SysCtlPeripheralReady(SYSCTL_PERIPH_GPIOR));
+
+ //
+ // Configure Pins for I2C2 Master Interface
+ //
+ GPIOPinConfigure(GPIO_PR4_I2C3SCL);
+ GPIOPinConfigure(GPIO_PR5_I2C3SDA);
+ GPIOPinTypeI2C(GPIO_PORTR_BASE, GPIO_PIN_5);
+ GPIOPinTypeI2CSCL(GPIO_PORTR_BASE, GPIO_PIN_4);
+
+ //
+ // Configure GPIO Pin PL4 for Interrupt Time Processing
+ //
+ ///GPIOPinTypeGPIOOutput(GPIO_PORTL_BASE, GPIO_PIN_4);
+ ///GPIOPinWrite(GPIO_PORTL_BASE, GPIO_PIN_4, 0x0);
+
+ //
+ // Setup System Clock for 120MHz
+ //
+ ui32SysClock = SysCtlClockFreqSet((SYSCTL_OSC_MAIN | SYSCTL_USE_PLL | SYSCTL_XTAL_25MHZ |
+ SYSCTL_CFG_VCO_480), 120000000);
+
+ //
+ // Stop the Clock, Reset and Enable I2C Module
+ // in Master Function
+ //
+ SysCtlPeripheralDisable(SYSCTL_PERIPH_I2C3);
+ SysCtlPeripheralReset(SYSCTL_PERIPH_I2C3);
+ SysCtlPeripheralEnable(SYSCTL_PERIPH_I2C3);
+
+ //
+ // Wait for the Peripheral to be ready for programming
+ //
+ while(!SysCtlPeripheralReady(SYSCTL_PERIPH_I2C3));
+
+ //
+ // Initialize and Configure the Master Module
+ //
+ I2CMasterInitExpClk(I2C3_BASE, ui32SysClock, true);
+
+ //
+ // Assign the Transmit and Receive FIFO to the Master
+ // Transmit threshold of 2 means that when there are less
+ // than or equal to 2 bytes in the TX FIFO then generate
+ // an interrupt
+ // Receive threshold of 6 means that when there are more
+ // than or qual to 6 bytes in the RX FIFO then generate
+ // an interrupt
+ //
+ I2CTxFIFOConfigSet(I2C3_BASE, I2C_FIFO_CFG_TX_MASTER_DMA | I2C_FIFO_CFG_TX_TRIG_2);
+ I2CRxFIFOConfigSet(I2C3_BASE, I2C_FIFO_CFG_RX_MASTER_DMA | I2C_FIFO_CFG_RX_TRIG_3);
+
+ //
+ // Transmit uDMA Arbitrartion size is calculated as the
+ // smaller mod 2 which can write to the TXFIFO without
+ // overrun
+ // TX TRIGGER ARB
+ // I2C_FIFO_CFG_TX_NO_TRIG UDMA_ARB_8
+ // I2C_FIFO_CFG_TX_TRIG_1 UDMA_ARB_4
+ // I2C_FIFO_CFG_TX_TRIG_2 UDMA_ARB_4
+ // I2C_FIFO_CFG_TX_TRIG_3 UDMA_ARB_4
+ // I2C_FIFO_CFG_TX_TRIG_4 UDMA_ARB_4
+ // I2C_FIFO_CFG_TX_TRIG_5 UDMA_ARB_2
+ // I2C_FIFO_CFG_TX_TRIG_6 UDMA_ARB_2
+ // I2C_FIFO_CFG_TX_TRIG_7 UDMA_ARB_1
+ //
+ ui32TxArbSize = UDMA_ARB_4;
+
+ //
+ // Receive uDMA Arbitrartion size is calculated as the
+ // Trigger Level to read back data from RXFIFO without
+ // an underrun
+ // RX TRIGGER ARB
+ // I2C_FIFO_CFG_RX_NO_TRIG INVALID
+ // I2C_FIFO_CFG_RX_TRIG_1 UDMA_ARB_1
+ // I2C_FIFO_CFG_RX_TRIG_2 UDMA_ARB_2
+ // I2C_FIFO_CFG_RX_TRIG_3 UDMA_ARB_2
+ // I2C_FIFO_CFG_RX_TRIG_4 UDMA_ARB_4
+ // I2C_FIFO_CFG_RX_TRIG_5 UDMA_ARB_4
+ // I2C_FIFO_CFG_RX_TRIG_6 UDMA_ARB_4
+ // I2C_FIFO_CFG_RX_TRIG_7 UDMA_ARB_4
+ //
+ ui32RxArbSize = UDMA_ARB_2;
+
+ //
+ // Flush any existing data in the FIFO
+ //
+ I2CTxFIFOFlush(I2C3_BASE);
+ I2CRxFIFOFlush(I2C3_BASE);
+
+ //
+ // Enable Interrupts for Arbitration Lost, Stop, NAK,
+ // Clock Low Timeout and Data.
+ //
+ I2CMasterIntEnableEx(I2C3_BASE, (I2C_MASTER_INT_ARB_LOST |
+ I2C_MASTER_INT_STOP | I2C_MASTER_INT_NACK |
+ I2C_MASTER_INT_TIMEOUT | I2C_MASTER_INT_DATA));
+
+ //
+ // Enable the Interrupt in the NVIC from I2C Master
+ //
+ IntEnable(INT_I2C3);
+
+ //
+ // Enable the Glitch Filter. Writting a value 0 will
+ // disable the glitch filter
+ // I2C_MASTER_GLITCH_FILTER_DISABLED
+ // I2C_MASTER_GLITCH_FILTER_1
+ // I2C_MASTER_GLITCH_FILTER_2 : Ideal Value when in HS Mode
+ // for 120MHz clock
+ // I2C_MASTER_GLITCH_FILTER_4
+ // I2C_MASTER_GLITCH_FILTER_8 : Ideal Value when in Std,
+ // Fast, Fast+ for 120MHz clock
+ // I2C_MASTER_GLITCH_FILTER_16
+ // I2C_MASTER_GLITCH_FILTER_32
+ //
+ I2CMasterGlitchFilterConfigSet(I2C3_BASE, I2C_MASTER_GLITCH_FILTER_8);
+
+ //
+ // Initialize and Configure the Master Module State Machine
+ //
+ g_ui8MasterCurrState = I2C_OP_IDLE;
+
+ return 0;
+
+}
+
+uint32_t I2C_Write_udmaFifo(uint32_t base, uint8_t addr, uint8_t *data, uint32_t len)
+{
+ uint8_t ui8Count;
+ //uint32_t ui32TxArbSize;
+ SLAVE_ADDRESS_EXT = addr;
+ uint8_t ui8MasterBytesLength;
+ //
+ // Check if the Bus is Busy or not
+ //
+ while(I2CMasterBusBusy(base));
+
+ //
+ // Randomly Initialize the Transmit buffer and
+ // set the receive buffer to 0xFF
+ //
+ for(ui8Count=0 ; ui8Count < len ; ui8Count++)
+ {
+ g_ui8MasterTxData[ui8Count] = data[ui8Count];
+
+ //
+ // Change the Random Value for the next
+ // iteration..
+ //
+ ///RandomAddEntropy(RandomSeed());
+
+ //
+ // Init the receive buffers with the value
+ // 0xFF
+ //
+ ////g_ui8MasterRxData[ui8Count] = 0xFF;
+ }
+
+ //
+ // When sending data to slave make sure
+ // RX DMA DONE interrupt bit is masked and
+ // TX DMA DONE interrupt bit is unmasked
+ //
+ I2CMasterIntEnableEx(base, I2C_MASTER_INT_TX_DMA_DONE);
+ I2CMasterIntDisableEx(base, I2C_MASTER_INT_RX_DMA_DONE);
+
+ //
+ // Set the I2CMBLEN register and also initialize
+ // the internal flag
+ //
+ ui8MasterBytesLength = 32;
+
+ I2CMasterBurstLengthSet(base, ui8MasterBytesLength);
+
+ //
+ // Configure the uDMA Control Channel Structure for TX
+ //
+ ConfigureuDMATX(ui8MasterBytesLength, ui32TxArbSize);
+
+ //
+ // Set Transmit Flag and set the Page Address in
+ // external slave to 0x0000
+ //
+ g_bI2CDirection = false;
+ g_ui16SlaveWordAddress = 0x0;
+ g_ui8MasterBytes = 0;
+
+ //
+ // Print Message before sending data
+ //
+ ///UARTprintf("Transmit %d bytes to external Slave...\n\n",ui8MasterBytesLength);
+
+ //
+ // Trigger the Transfer using Software Interrupt
+ //
+ g_ui8MasterCurrState = I2C_OP_IDLE;
+ IntTrigger(INT_I2C3);
+ while(g_ui8MasterCurrState != I2C_OP_STOP);
+
+ return 0;
+}
+
+uint32_t I2C_Read_udmaFifo(uint32_t base, uint8_t addr, uint8_t *data, uint32_t len)
+{
+ uint8_t ui8Count;
+ bool bError;
+ //uint32_t ui32RxArbSize;
+ uint8_t ui8MasterBytesLength;
+
+ SLAVE_ADDRESS_EXT = addr;
+ //
+ // When receiving data from slave make sure
+ // TX DMA DONE interrupt bit is masked and
+ // RX DMA DONE interrupt bit is unmasked
+ //
+ I2CMasterIntEnableEx(base, I2C_MASTER_INT_RX_DMA_DONE);
+ I2CMasterIntDisableEx(base, I2C_MASTER_INT_TX_DMA_DONE);
+
+ //
+ // Set the I2CMBLEN register and also initialize
+ // the internal flag
+ //
+ ui8MasterBytesLength = 32;
+
+ I2CMasterBurstLengthSet(base, ui8MasterBytesLength);
+
+ //
+ // Configure the uDMA Control Channel Structure for RX
+ //
+ ConfigureuDMARX(ui8MasterBytesLength,ui32RxArbSize);
+
+ //
+ // Set receive Flag and set the Page Address in
+ // external slave to 0x0000
+ //
+ g_bI2CDirection = true;
+ g_bI2CRepeatedStart = true;
+ g_ui16SlaveWordAddress = 0x0;
+ g_ui8MasterBytes = 0;
+
+ //
+ // Print Message before receiving data
+ //
+ ///UARTprintf("Receiving %d bytes from external Slave...\n\n",ui8MasterBytesLength);
+
+ //
+ // Trigger the Transfer using Software Interrupt
+ //
+ g_ui8MasterCurrState = I2C_OP_IDLE;
+ IntTrigger(INT_I2C3);
+ while(g_ui8MasterCurrState != I2C_OP_STOP);
+
+ //
+ // Perform Data Integrity Check...
+ //
+ bError = false;
+ for(ui8Count = 0 ; ui8Count < len ; ui8Count++)
+ {
+ data[ui8Count] = g_ui8MasterRxData[ui8Count];
+
+ }
+
+ return 0;
+
+}
+
+
+
diff --git a/Software/Embedded_SW/Embedded/Main.c b/Software/Embedded_SW/Embedded/Main.c
index 3be36668d..88ba521a4 100644
--- a/Software/Embedded_SW/Embedded/Main.c
+++ b/Software/Embedded_SW/Embedded/Main.c
@@ -39,6 +39,7 @@
#include <DataDef.h>
#include "Sys_PinOut_Config/MCU_MAIN_pinout.h"
+#include <Drivers/I2C_Communication/I2C.h>
/*
#include "Drivers/SPI_SDCARD/SDSPI.h"
@@ -84,7 +85,7 @@
#include "Drivers/I2C_Communication/Head_Card/IO_Ports/Head_IO.h"
#include "Drivers/I2C_Communication/Head_Card/EEPROM/Head_EEPROM.h"
#include "modules/AlarmHandling/AlarmHandling.h"
-//#include <Drivers/I2C_Communication/I2C_Task.h>
+#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>
//*****************************************************************************
@@ -265,21 +266,25 @@ int main(void)
Init_All_I2C();
Block_Main_MUX_TCA9548A_0xE4();//unused, same i2c as head and whs cards
- Check_Head_Type_Via_EEPROM();
+ I2C_BUSY_DELAY = 3000; //temporary workaround!!!
+ Check_Head_Type_Via_EEPROM();//without trigger
+ Check_WHS_Type_Via_EEPROM();//without trigger
+ I2C_BUSY_DELAY = 100; //temporary workaround!!!
+ if ((Head_Type >= HEAD_TYPE_UNKNOWN_WITH_CARD)&&(WHS_Type == WHS_TYPE_NEW))
+ {
+ PP_Machine = true;
+ }
+ if ((Head_Type > HEAD_TYPE_SYLKO_WITHOUT_CARD)||(WHS_Type == WHS_TYPE_NEW))
+ {
+ I2C_ReadingTask_Init();
+ }
if (Head_Type > HEAD_TYPE_SYLKO_WITHOUT_CARD)
{
- Head_IO_Init();//moved to set 24 to pressure sensor in arc earlier
+ Trigger_Head_io_Init();//Head_IO_Init();//moved to set 24 to pressure sensor in arc earlier
}
- //Trigger_Check_WHS_Type_Via_EEPROM();
- Check_WHS_Type_Via_EEPROM();
-
Check_IFS_Availability();
- if ((Head_Type >= HEAD_TYPE_UNKNOWN_WITH_CARD)&&(WHS_Type == WHS_TYPE_NEW))
- {
- PP_Machine = true;
- }
#ifndef EVALUATION_BOARD
STATUS_RED_LED_ON;
STATUS_GREEN_LED_ON;
@@ -290,8 +295,6 @@ int main(void)
SysCtlUSBPLLEnable();
-
-
#ifndef EVALUATION_BOARD
DeActivateAllSSR();
Control_Dryer_Fan(STOP,0);//Preventing unwanted movement at power up, since the default from FPGA is "0" (= START)
@@ -310,8 +313,7 @@ int main(void)
//ActivateHeadMagnet();
Set_Speed_Sensor_TypeII_Registers(10,5);//set default values
#endif
- if ((Head_Type > HEAD_TYPE_SYLKO_WITHOUT_CARD)||(WHS_Type == WHS_TYPE_NEW))
- I2C_ReadingTask_Init();
+
//EMAC_initEMAC();
ControlInit();
diff --git a/Software/Embedded_SW/Embedded/Modules/AlarmHandling/AlarmHandling.c b/Software/Embedded_SW/Embedded/Modules/AlarmHandling/AlarmHandling.c
index 1c2b6662d..650d9be24 100644
--- a/Software/Embedded_SW/Embedded/Modules/AlarmHandling/AlarmHandling.c
+++ b/Software/Embedded_SW/Embedded/Modules/AlarmHandling/AlarmHandling.c
@@ -893,7 +893,7 @@ JobEndReasonEnum AlarmHandlingPrepareJob(void *CurrentJob)
if (AlarmItem[Alarm_i].AlarmSource == ALARM_SOURCE_TYPE__CoversAlarm)
{
- if (AlarmState[Alarm_i].Status == true)
+ if ((AlarmState[Alarm_i].Status == true)&&(AlarmItem[Alarm_i].Severity == DEBUG_LOG_CATEGORY__Error))
{
FoundReason = JOB_TAMPER_ALARM;
ReportWithPackageFilter(AlarmFilter,"tamper alarm preventing job", __FILE__,__LINE__,AlarmItem[Alarm_i].EventType, AlarmItem[Alarm_i].Severity, AlarmItem[Alarm_i].DeviceId, 0);
@@ -977,6 +977,7 @@ JobEndReasonEnum AlarmHandlingPrepareJob(void *CurrentJob)
case EVENT_TYPE__INSUFFICIENT_AIR_FLOW:
case EVENT_TYPE__VOC_SENSOR_ALARM_TIME:
case EVENT_TYPE__VOC_SENSOR_ALARM_SLOPE:
+ //case EVENT_TYPE__POWER_UP_BIT_FAILURE:
FoundReason = JOB_UNSPECIFIED_ERROR;
AlarmId = Alarm_i;
ReportWithPackageFilter(AlarmFilter,"an alarm preventing job", __FILE__,__LINE__,AlarmItem[Alarm_i].EventType, AlarmItem[Alarm_i].Severity, AlarmItem[Alarm_i].DeviceId, 0);
@@ -1001,7 +1002,7 @@ JobEndReasonEnum AlarmHandlingPrepareJob(void *CurrentJob)
//AbortJob(AlarmReasonStr);
//PrepareReady(Module_Alarms,ModuleFail);
ReportWithPackageFilter(AlarmFilter,AlarmReasonStr, __FILE__,__LINE__,AlarmId, RpMessage, DEBUG_LOG_CATEGORY__Error, 0);
- return (JobEndReason);
+ return (FoundReason);
}
return JOB_OK;
}
@@ -1314,7 +1315,7 @@ uint32_t AlarmHandlingLoop(uint32_t tick)
}
break;
case ALARM_SOURCE_TYPE__MotorAlarm:
- if (0)//(CheckMotorAlarms)
+ if (CheckMotorAlarms)
{
if (FPGA_WD_Occurred == true)
{
diff --git a/Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.c b/Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.c
index 4ad5336d9..27fc8a707 100644
--- a/Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.c
+++ b/Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.c
@@ -594,7 +594,7 @@ uint32_t MillisecLowLoop(uint32_t tick)
//call all modules Millisec functions
//test dancers and speed encoders
//check all callback units (state machine waiting for completion of a change)
- bool Ten_msTick, Fifty_msTick, Hundred_msTick , m20msecTick,m70msecTick,m90msecTick, Onesecond_Tick,Tensecond_Tick,OneMinute_Tick,OneHourTick,Gradient_Tick;
+ bool Ten_msTick, Fifty_msTick, Hundred_msTick , m20msecTick,m70msecTick,m90msecTick, Onesecond_Tick,Tensecond_Tick,OneMinute_Tick,TenMinutes_Tick,OneHourTick,Gradient_Tick;
bool O700Millisecond_Tick,O200Millisecond_Tick,O400Millisecond_Tick,O500Millisecond_Tick,O600Millisecond_Tick;
//bool O100Millisecond_Tick,O200Millisecond_Tick,O400Millisecond_Tick,O500Millisecond_Tick,O600Millisecond_Tick,O800Millisecond_Tick,O900Millisecond_Tick;
Ten_msTick = (tick%eTenMillisecond == 0) ?true:false;
@@ -614,6 +614,7 @@ uint32_t MillisecLowLoop(uint32_t tick)
Onesecond_Tick = (tick%eOneSecond == 0) ?true:false;
Tensecond_Tick = (tick%10000 == 0) ?true:false;
OneMinute_Tick = (tick%eOneMinute == 0) ?true:false;
+ TenMinutes_Tick = (tick%eTenMinutes == 0) ?true:false;
OneHourTick = (tick%eOneHour == 0) ?true:false;
realtimetest[(tick%1000)/10]++;
//gather Motor data from FPGA
@@ -766,8 +767,12 @@ uint32_t MillisecLowLoop(uint32_t tick)
}
*/
}
+
//call waste state machine
Waste_StateMachine_OneSecond_Call();
+
+ //call IFS state machine
+ midTankStateMachine();
}
if (Tensecond_Tick)
{
@@ -797,6 +802,13 @@ uint32_t MillisecLowLoop(uint32_t tick)
ResetControlTime();
#endif
}
+ if (TenMinutes_Tick)
+ {
+ if (WHS_Type == WHS_TYPE_NEW)
+ {
+ waste_seq_step1();// include 1Sec delay <- to open !!!!
+ }
+ }
if (OneHourTick)
{
#define PUMP_LIMIT 4
@@ -807,10 +819,10 @@ uint32_t MillisecLowLoop(uint32_t tick)
PumpCounter = 0;
}
MidTankReading();
- if (WHS_Type == WHS_TYPE_NEW)
+ /*if (WHS_Type == WHS_TYPE_NEW)
{
waste_seq_step1();// include 1Sec delay <- to open !!!!
- }
+ }*/
//Trigger_WHS_MAX11614_Read_Gas_Sensor();
}
//ROM_IntMasterEnable();
diff --git a/Software/Embedded_SW/Embedded/Modules/Control/control.h b/Software/Embedded_SW/Embedded/Modules/Control/control.h
index 78e24f495..4b6a80967 100644
--- a/Software/Embedded_SW/Embedded/Modules/Control/control.h
+++ b/Software/Embedded_SW/Embedded/Modules/Control/control.h
@@ -21,6 +21,7 @@ typedef enum {
eHundredMillisecond = 100,
eOneSecond = 1000,
eOneMinute = 60000,
+ eTenMinutes = 600000,
eOneHour = 3600000
}CTRL_TIMING_ENUM;
typedef enum
diff --git a/Software/Embedded_SW/Embedded/Modules/Diagnostics/Diagnostics.c b/Software/Embedded_SW/Embedded/Modules/Diagnostics/Diagnostics.c
index 8e01fe18e..421206b45 100644
--- a/Software/Embedded_SW/Embedded/Modules/Diagnostics/Diagnostics.c
+++ b/Software/Embedded_SW/Embedded/Modules/Diagnostics/Diagnostics.c
@@ -864,10 +864,10 @@ void DiagnosticOneSecCollection(void)
tempFlow = HeadFlowMeter;
}*/
WasteLevel = GetWHSWasteTankLevelMiliLiter()/1000;//change from ml to litter
- static double InitCounter = 0;
- if (GetMachineState()<MACHINE_STATE_NO_PROCESS_PARAMS)
+ static double InitCounter = 60.0;
+ if ((GetMachineState()<MACHINE_STATE_NO_PROCESS_PARAMS) &&(GetMachineState()>=MACHINE_STATE_WAIT_FOR_COOLER))
{
- InitCounter+=1.0;
+ InitCounter-=1.0;
DiagnosticsMonitor.chillertemperature = &InitCounter;
}
@@ -1058,7 +1058,8 @@ void SendDiagnostics(void)
DiagnosticsMonitor.dancer2angle = dancer2angle;
DiagnosticsMonitor.dancer3angle = dancer3angle;
*/
- if ((JobIsActive())&&(DiagnosticMode >= Diagnostic_Extended_Mode))
+// if ((JobIsActive())&&(DiagnosticMode >= Diagnostic_Extended_Mode))
+ if (DiagnosticMode >= Diagnostic_Extended_Mode)
{
DiagnosticsMonitor.n_dancer1angle = DancerCounterIndex[0];
DiagnosticsMonitor.n_dancer2angle = DancerCounterIndex[1];
diff --git a/Software/Embedded_SW/Embedded/Modules/General/Safety.c b/Software/Embedded_SW/Embedded/Modules/General/Safety.c
index 89ac8d020..099ac1769 100644
--- a/Software/Embedded_SW/Embedded/Modules/General/Safety.c
+++ b/Software/Embedded_SW/Embedded/Modules/General/Safety.c
@@ -46,7 +46,7 @@ uint32_t Safety_Main_State(uint32_t IfIndex, uint32_t BusyFlag)
bool mDrierDoorAlarmState = false;
bool mAirFlowAlarmState = false;
bool mAirFilterAlarmState = false;
- //bool mWasteOverflowAlarmState = false;
+ bool mWasteOverflowAlarmState = false;
#ifdef CONTROL_DEBUG
uint32_t tempp,tempq,delta;
uint32_t sys_ticks_start = msec_millisecondCounter,sys_ticks_end,max = 0,dev = 0;
@@ -91,6 +91,16 @@ uint32_t Safety_Main_State(uint32_t IfIndex, uint32_t BusyFlag)
mDrierDoorAlarmState = true;
DrierDoorAlarmState = true;
}
+ else
+ {
+ //if (WHS_GPI_WASTE_OVERFULL()) - cannot read this switch
+ {
+ //report and handle waste overflow
+ AlarmHandlingSetAlarm(EVENT_TYPE__CHILLER_DRY_CONTACT, true);
+ mWasteOverflowAlarmState = true;
+ WasteOverflowAlarmState = true;
+ }
+ }
}
}
@@ -224,6 +234,12 @@ uint32_t Safety_Main_State(uint32_t IfIndex, uint32_t BusyFlag)
AlarmHandlingSetAlarm(EVENT_TYPE__AIR_FILTER_NOT_INSTALLED, false);
AirFilterAlarmState = mAirFilterAlarmState;
}
+ if ((mWasteOverflowAlarmState != WasteOverflowAlarmState)|| (mWasteOverflowAlarmState == false))
+ {
+ //alarm went off
+ AlarmHandlingSetAlarm(EVENT_TYPE__WASTE_CONTAINER_OVERFLOW, false);
+ WasteOverflowAlarmState = mWasteOverflowAlarmState;
+ }
#ifdef CONTROL_DEBUG
tempq = HibernateRTCSSGet();
if (tempq < tempp)
diff --git a/Software/Embedded_SW/Embedded/Modules/General/buttons.h b/Software/Embedded_SW/Embedded/Modules/General/buttons.h
index 646861bc7..6a15d3765 100644
--- a/Software/Embedded_SW/Embedded/Modules/General/buttons.h
+++ b/Software/Embedded_SW/Embedded/Modules/General/buttons.h
@@ -59,7 +59,6 @@ uint32_t Buttons_Init(void);
uint32_t Button_load_Init(void);
uint32_t Button_JOG_Init(void);
bool SetPowerMachineState(PBmachineState state);
-void Ink_Cart_Led();
diff --git a/Software/Embedded_SW/Embedded/Modules/General/process.c b/Software/Embedded_SW/Embedded/Modules/General/process.c
index bf7d761dd..30a99ac86 100644
--- a/Software/Embedded_SW/Embedded/Modules/General/process.c
+++ b/Software/Embedded_SW/Embedded/Modules/General/process.c
@@ -119,7 +119,7 @@ uint32_t HandleProcessParameters(ProcessParameters* ProcessParams,bool saveData)
}
if (saveData == true)
{
- if ((ProcessParams->dryerzone1temp > 0.1)&&(ProcessParams->headzone2temp > 0.1)&&(ProcessParams->headzone3temp > 0.1)&&(ProcessParams->headzone4temp > 0.1))//NOT turning off heaters
+ if ((ProcessParams->dryerzone1temp > 0.1)&&(ProcessParams->headzone2temp > 0.1)&&(ProcessParams->headzone3temp > 0.1)&&(ProcessParams->headzone1temp > 0.1))//NOT turning off heaters
{
Bytes = sizeof(ProcessParameters);
FileWrite(ProcessParams,Bytes,ProcessParamsConfigPath,BIOS_WAIT_FOREVER);
diff --git a/Software/Embedded_SW/Embedded/Modules/IDS/IDS_Cleaning.c b/Software/Embedded_SW/Embedded/Modules/IDS/IDS_Cleaning.c
index 8f10a0e5d..0be1e7ebe 100644
--- a/Software/Embedded_SW/Embedded/Modules/IDS/IDS_Cleaning.c
+++ b/Software/Embedded_SW/Embedded/Modules/IDS/IDS_Cleaning.c
@@ -55,17 +55,20 @@ uint32_t IDS_Cleaning_Move_Actuators()
return OK;
if (CleaningStageCounter == 1)
{
- Trigger_Head_Actuators_Control(ACTIN, LOW,true);
+ Trigger_Head_Actuators_Stub(ACTIN, true, true);
+ //Trigger_Head_Actuators_Control(ACTIN, LOW,true);
Report("IDS_Cleaning_Move_ActuatorUp", __FILE__, __LINE__, 1, RpWarning, CleaningStageCounter, 0);
}
else if (CleaningStageCounter == Tup)
{
- Trigger_Head_Actuators_Disable();
+ Trigger_Head_Actuators_Stub(ACTIN, false, false);
+ //Trigger_Head_Actuators_Disable();
Report("IDS_Cleaning_Stop_Actuator", __FILE__, __LINE__, Tup, RpWarning, CleaningStageCounter, 0);
}
else if (CleaningStageCounter == Tdelay1)
{
- Trigger_Head_Actuators_Control(ACTIN, LOW,false);
+ Trigger_Head_Actuators_Stub(ACTIN, true, false);
+ //Trigger_Head_Actuators_Control(ACTIN, LOW,false);
Report("IDS_Cleaning_MoveDown", __FILE__, __LINE__, Tdelay1, RpWarning, CleaningStageCounter, 0);
}
else if (CleaningStageCounter == Tdelay2)
diff --git a/Software/Embedded_SW/Embedded/Modules/IDS/IDS_dispenser.c b/Software/Embedded_SW/Embedded/Modules/IDS/IDS_dispenser.c
index 3798e9aee..7693d1520 100644
--- a/Software/Embedded_SW/Embedded/Modules/IDS/IDS_dispenser.c
+++ b/Software/Embedded_SW/Embedded/Modules/IDS/IDS_dispenser.c
@@ -347,19 +347,20 @@ void IDS_Dispenser_Content_Calculation (char DispenserId)
!= DispenserIdToMotorId[DispenserId])
return;
+ /********* THIS FUNCTION IS NOW CALLED EVERY 400 MILISECONDS!!!!!!!!!! ***************************/
//int dir = (IDS_Dispenser_Data[DispenserId].direction==1)?1:-1;
//double consumedintimeframe = (double)(CurrentDispenserSpeed[DispenserId])*(double)(IDS_Dispenser_Data[DispenserId].microsteps)*
// IDS_Dispenser_Data[DispenserId].nanolitterperpulse ;//* dir;
//double consumedintimeframe = (double)(CurrentDispenserSpeed[DispenserId]); //pulses only
//consumedintimeframe = 10+DispenserId;
- IDS_Dispenser_Data[DispenserId].consumedinnanolitter += (CurrentDispenserSpeed[DispenserId]/10);//100 milliseconds ==> speed/10
+ IDS_Dispenser_Data[DispenserId].consumedinnanolitter += (CurrentDispenserSpeed[DispenserId]*4/10);//100 milliseconds ==> speed/10
if (IDS_Dispenser_Data[DispenserId].consumedinnanolitter<0)
IDS_Dispenser_Data[DispenserId].consumedinnanolitter = 0;
if (CurrentDispenserSpeed[DispenserId]>0.1)
{
DispenserDataUpdated = true;
IDS_Dispenser_Data[DispenserId].totalconsumedinnanolitter += (CurrentDispenserSpeed[DispenserId]/10);
- if (seconds_counter%6000 == 0)
+ if (seconds_counter%1500 == 0) //1500*400MILI = 600000
{
Report("IDS_Dispenser_Data ",__FILE__,DispenserId,(int)IDS_Dispenser_Data[DispenserId].consumedinnanolitter,RpWarning,(int)CurrentDispenserSpeed[DispenserId],0);
}
diff --git a/Software/Embedded_SW/Embedded/Modules/IDS/IDS_print.c b/Software/Embedded_SW/Embedded/Modules/IDS/IDS_print.c
index b4442c996..ac9bd0deb 100644
--- a/Software/Embedded_SW/Embedded/Modules/IDS/IDS_print.c
+++ b/Software/Embedded_SW/Embedded/Modules/IDS/IDS_print.c
@@ -43,6 +43,8 @@ typedef struct
HardwarePidControl *DispensersControl;
HardwarePidControl DispensersCtrl[MAX_SYSTEM_DISPENSERS];
#define MAX_DYE_DISPENSERS 6
+#define IDS_PRESEGMENT_TIME_STEP 50
+
int32_t DispenserSamples[MAX_SYSTEM_DISPENSERS][MAX_CONTROL_SAMPLES] = {0};
int DispenserSamplePointer[MAX_SYSTEM_DISPENSERS] = {0};
double DispenserNormalizedErrorCoEfficient[MAX_SYSTEM_DISPENSERS] = {0};
@@ -117,8 +119,9 @@ void IDS_Dispenser_SetPreSegmentWFCFValues(double dispenserpresegmentwfcf, doubl
LeftRockerSpeed = ids_leftcleaningmotorspeed;
if ( ids_rightcleaningmotorspeed)
RightRockerSpeed = ids_rightcleaningmotorspeed;
- Report("IDS_Dispenser_SetPreSegmentCleaningValues ",__FILE__,__LINE__,CleaningDispenserSpeed,RpWarning,(int)LeftRockerSpeed,0);
+ Report("IDS_Dispenser_SetPreSegmentCleaningValues ",__FILE__,__LINE__,RightRockerSpeed,RpWarning,(int)LeftRockerSpeed,0);
Report("IDS_Dispenser_SetPreSegmentCleaningValues ",__FILE__,__LINE__,InterSegmentStartSprayCleaner,RpWarning,(int)InterSegmentCenterRockers,0);
+ Report("IDS_Dispenser actuator times ",__FILE__,(int)LeftRockerSpeed/100*IDS_PRESEGMENT_TIME_STEP,(int)LeftRockerSpeed%100*IDS_PRESEGMENT_TIME_STEP,RpWarning,(int)RightRockerSpeed*IDS_PRESEGMENT_TIME_STEP,0);
}
@@ -590,7 +593,7 @@ uint32_t InactiveDispenserHome(uint32_t DispenserId, uint32_t ReadValue)
Report("pressureReady = true or timeout;",__FILE__,DispenserBuildTimeCounter,NumofReadyDispensers,RpWarning,(int)NumOfActiveDispensers,0);
}
}
- else if (endOfPrepareWCF == false)
+ else if ((endOfPrepareWCF == false)&&(NumOfActiveDispensers))
{
if ((DispenserBuildTimeCounter == PRESSURE_READ_TIME_GAP)&&(FirstBrushStop))
{
@@ -683,6 +686,13 @@ uint32_t InactiveDispenserHome(uint32_t DispenserId, uint32_t ReadValue)
}
}
+ else if (NumOfActiveDispensers == 0)
+ {
+ endOfPrepareWCF = true;
+ FreeBrushStopFileData(FirstBrushStop);
+ FirstBrushStop =NULL;
+ Report("endOfPrepareWCF = true;",__FILE__,DispenserBuildTimeCounter,NumofReadyDispensers,RpWarning,(int)NumOfActiveDispensers,0);
+ }
//start new stage
if (endOfPrepareWCF == true)
{
@@ -1027,7 +1037,6 @@ uint32_t InactiveDispenserHome(uint32_t DispenserId, uint32_t ReadValue)
//********************************************************************************************************************
-
uint32_t IDSPreSegmentStateCallbackRunner(uint32_t IfIndex, uint32_t ReadValue)
{
JobDispenser **Dispensers;
@@ -1065,7 +1074,7 @@ uint32_t IDS_Cleaning_Spray_Cleaning_Solution (int dispenserSpeed,callback_fptr
uint32_t IDS_Cleaning_Stop_Cleaning_Solution (callback_fptr callback);
*/
//InterSegmentStepsLimit = lInterSegmentLength*10;//100 millisec steps
- InterSegmentStepsCount+=100;
+ InterSegmentStepsCount+=IDS_PRESEGMENT_TIME_STEP;
if (InterSegmentStepsCount >= lInterSegmentLength)
{
//IDS_Valve_PresegmentReady(1,0);
@@ -1259,7 +1268,7 @@ uint32_t IDSPreSegmentState(void *SegmentDetails, int SegmentId)
lInterSegmentLength = ((IntersegmentLength*100)*1000/dyeingspeed);
lInterSegmentLength-=(lInterSegmentLength%100); //round to a 100 multiplication
InterSegmentStepsCount = 0;
- DispenserPreSegmentControlId = AddControlCallback(NULL,IDSPreSegmentStateCallbackRunner, 100,TemplateDataReadCBFunction ,0, 0, 0 );
+ DispenserPreSegmentControlId = AddControlCallback(NULL,IDSPreSegmentStateCallbackRunner, IDS_PRESEGMENT_TIME_STEP,TemplateDataReadCBFunction ,0, 0, 0 );
if (DispenserPreSegmentControlId == 0xFF)
{
Report("Add control callback failed",__FILE__,__LINE__,(int)100,RpWarning,(int)0,0);
@@ -1292,7 +1301,7 @@ uint32_t IDSPreSegmentState(void *SegmentDetails, int SegmentId)
lInterSegmentLength = (dryerbufferCentimeters*1000/dyeingspeed);
lInterSegmentLength-=(lInterSegmentLength%100); //round to a 100 multiplication
InterSegmentStepsCount = 0;
- DispenserPreSegmentControlId = AddControlCallback( IDSPreSegmentStateCallbackRunner, 100,TemplateDataReadCBFunction ,0, 0, 0 );
+ DispenserPreSegmentControlId = AddControlCallback( IDSPreSegmentStateCallbackRunner, IDS_PRESEGMENT_TIME_STEP,TemplateDataReadCBFunction ,0, 0, 0 );
if (DispenserPreSegmentControlId == 0xFF)
{
Report("Add control callback failed",__FILE__,__LINE__,(int)100,RpWarning,(int)0,0);
@@ -1695,7 +1704,7 @@ uint32_t IDSSegmentState(void *SegmentDetails, int SegmentId)
lInterSegmentLength = (dryerbufferCentimeters*1000/dyeingspeed);
lInterSegmentLength-=(lInterSegmentLength%100); //round to a 100 multiplication
InterSegmentStepsCount = 0;
- DispenserPreSegmentControlId = AddControlCallback("IDS DTS", IDSPreSegmentStateCallbackRunner, 100,TemplateDataReadCBFunction ,0, 0, 0 );
+ DispenserPreSegmentControlId = AddControlCallback("IDS DTS", IDSPreSegmentStateCallbackRunner, IDS_PRESEGMENT_TIME_STEP,TemplateDataReadCBFunction ,0, 0, 0 );
if (DispenserPreSegmentControlId == 0xFF)
{
Report("Add control callback failed",__FILE__,__LINE__,(int)100,RpWarning,(int)0,0);
diff --git a/Software/Embedded_SW/Embedded/Modules/IFS/ifs.c b/Software/Embedded_SW/Embedded/Modules/IFS/ifs.c
index 5af90c3d1..974b022d7 100644
--- a/Software/Embedded_SW/Embedded/Modules/IFS/ifs.c
+++ b/Software/Embedded_SW/Embedded/Modules/IFS/ifs.c
@@ -8,14 +8,15 @@
* @author Shai
*/
+#include <DataDef.h>
#include "PMR/Diagnostics/CartridgeSlot.pb-c.h"
#include "PMR/Diagnostics/CartridgeTagContent.pb-c.h"
#include <Drivers/I2C_Communication/RFID_NFC/RFIDTagInfo.h>
-
-#include <DataDef.h>
+#include "drivers/FPGA/FPGA_GPIO/FPGA_GPIO.h"//#include "FPGA_GPIO.h" // use for FPGA IO
+#include "drivers/I2C_Communication/ADC_MUX/ADC_MUX.h"
+#include "StateMachines/Initialization/PowerOffSequence.h"
#include "include.h"
-#include "Modules/Waste/Waste.h"
#include "Modules/IDS/ids_ex.h"
#include "Modules/IFS/ifs.h"
#include "Modules/AlarmHandling/AlarmHandling.h"
@@ -23,256 +24,147 @@
#include "CartridgeValidationResponse.pb-c.h"
#include <PMR/Diagnostics/EventType.pb-c.h>
#include "drivers/Valves/Valve.h"
-#include "Modules/Waste/Waste.h"
#include "../control/control.h"
+#include "Modules/General/buttons.h"
+
+#define CARTRIDGE_EMPTY_QUANTITY_LIMIT 10
+#define CARTRIDGE_EMPTY_CALCULATION_TIME 12
+#define FIVE_SECONDS 5
+
+//#define IFS_DEBUG
+
+int CartridgeInkTimeout = CARTRIDGE_INK_TIMEOUT;
+int CartridgeCheckTime = FIVE_SECONDS;
-bool IFS_TimeOutAlarm(bool status);
-bool ColorMatch();
-bool MidTankValvesAction(bool action);
+double midTankCapacity;
+MidTank_t midTankCartColor;
+bool prevDoorState;
+bool doorState;
+uint8_t inkAuthenticationPass;
+uint32_t midTankTimeoutCounter = 0;
+double MidTankEmptyLimit = MidTank_Pressure_EMPTY;
+MidTankStateEnum midTankState = 0;
+
+char CartridgeRequestToken[36+1];
+int CartridgeRequestId = 0x01010101;
+
+bool RdInkCartridgeSensor()
+{
+ return Is_Cartridge_Present(CART_1);
+}
bool IFS_CartridgeLowerPresent()
{
- return IFS_info.IFS_Ink_precense_sensor;
+ return RdInkCartridgeSensor();
}
bool IFS_MidTankFilling(void)
{
- return (IFS_info.Ink.time_out > 0);
+ return (midTankTimeoutCounter > 0);
}
+
MidTank_t IFS_MidTankIsActive(void)
{
- return (IFS_info.Ink.cart_color);
+ return midTankCartColor;
}
-NFC_Tag NFCTag[MAX_CARTRIDGES];
+uint32_t MidTankReading(void)
+{
+ if (midTankTimeoutCounter > 0)
+ return ERROR;
+ return OK;
+}
-void IFS_Init(void)
+bool MidTankValvesAction(bool action)
{
- int i;
- for (i=0;i<MAX_CARTRIDGES;i++)
- {
- //TagInitialize(&TagContent[i]);
- memset(NFCTag[i].Buf,0,sizeof(NFCTag[i]));
+ bool ret = true;
+ if (action == Cartridge_MidTank_ON) {
+ Enable_MidTank_Pressure_Reading(midTankCartColor);
+ } else {
+ Disable_MidTank_Pressure_Reading(midTankCartColor);
+ }
+ if (IDS_IsHomingActive(midTankCartColor)==false) {
+ Valve_Set(IDS_Id_to_AirValve[midTankCartColor], action);
}
+ Valve_Set(IDS_Id_to_CartrideValve[midTankCartColor], action);
+ return ret;
}
-/**
- *
- * @brief detect cartridge INK Empty
- * this function detect changes in IFS INK cartridge
- * when MidTank average is bigger the 98% of midtank pressure
- * the INK cartridge is empty
- * @return bool ret OK = 0 , CartridgeFinished = 1
- */
-#define CARTRIDGE_EMPTY_QUANTITY_LIMIT 10
-#define CARTRIDGE_EMPTY_CALCULATION_TIME 12
bool DetectIfCartridgeFinished(int int_MidTank_Pressure_1000)
{
-
-#define CartridgeFinished 1
-
- bool ret = OK;
+ bool ret = false;
static int measure_midtank[CARTRIDGE_EMPTY_CALCULATION_TIME] ;
static int count_measure_midtank = 0;
int i=0;
int sum = 0;
int average = 0;
- if ( count_measure_midtank == CARTRIDGE_EMPTY_CALCULATION_TIME)
+ if (count_measure_midtank == CARTRIDGE_EMPTY_CALCULATION_TIME)
count_measure_midtank = 0;
measure_midtank[count_measure_midtank] = int_MidTank_Pressure_1000;
count_measure_midtank += 1;
for (i=0;i<CARTRIDGE_EMPTY_CALCULATION_TIME;i++)
sum += measure_midtank[i];
average = sum/CARTRIDGE_EMPTY_CALCULATION_TIME;
- if (abs(average - int_MidTank_Pressure_1000)<CARTRIDGE_EMPTY_QUANTITY_LIMIT) ret = CartridgeFinished;
- //if (average > (int_MidTank_Pressure_1000 * 0.98) ) ret = CartridgeFinished;
-
+ if (abs(average - int_MidTank_Pressure_1000)<CARTRIDGE_EMPTY_QUANTITY_LIMIT)
+ ret = true;
return ret;
}
-
-
-/**
- *
- * @brief detect changes in cartridge INK presence
- * this function detect changes in IFS presence cartridge
- * when changes are happens it update the presence status
- * and the correct event
- * @return IFS_INK_presence_sensor or WHS_no_event event
- */
-
-WHS_sensor CartridgeInkCallBackFunction()
+#ifdef IFS_DEBUG
+bool CartridgeInkFull()
{
- WHS_sensor ret = WHS_no_event;
-
- if (IFS_info.IFS_Ink_precense_sensor != RdInkCartridgeSensor())
- {
- WHS_info.event = IFS_INK_presence_sensor;
- IFS_info.IFS_Ink_precense_sensor = !IFS_info.IFS_Ink_precense_sensor;
- Report("------------ find : IFS_Ink_presence_sensor event -----------------", __FILE__,__LINE__, IFS_info.IFS_Ink_precense_sensor, RpMessage, 0, 0);
- ret = IFS_INK_presence_sensor;
+ static int count = 1;
+ if((count++ % 60) == 0) {
+ return true;
+ } else {
+ return false;
}
- return ret;
}
+#else
+int CartridgeFinishedCount = 0;
-/**
- *
- * @brief detect TimeOut
- * we have 2 way to stop filling:
- * 1. time out
- * 2. detect Midtank is full.
- *
- * 1. time out process is:
- * 1. detect timeout after 5 minutes
- * 2. close and open the valves
- * 3. count 5 minutes again
- *2. measure MidTank capacity
- * if MidTank is full stop count
- *
- * @return IFS_INK_presence_sensor or WHS_no_event event
- */
-WHS_sensor CartridgeInkTimeOutCallBackFunction()
+bool CartridgeInkFull()
{
- WHS_sensor ret = WHS_no_event;
double MidTank_Pressure = 0;
int int_MidTank_Pressure_1000 = 0;
-
- //Enable_MidTank_Pressure_Reading(IFS_info.Ink.cart_color);
- MidTank_Pressure = Read_MidTank_Pressure_Sensor(IFS_info.Ink.cart_color);// Get_MidTank_Pressure_Sensor(IFS_info.Ink.cart_color);
- //Disable_MidTank_Pressure_Reading(IFS_info.Ink.cart_color);
+ MidTank_Pressure = Read_MidTank_Pressure_Sensor(midTankCartColor);
int_MidTank_Pressure_1000 = ((int)(MidTank_Pressure*1000));
- Report("------------ IFS_info.Ink.time_out and Pressure -----------------", __FILE__,__LINE__,(IFS_info.Ink.time_out * SECONDS_5), RpMessage, (int_MidTank_Pressure_1000), 0);
-
- if (IFS_info.Ink.time_out) IFS_info.Ink.time_out += 1; /*** counter ***/
-
/*** detect the MidTank capacity is full ***/
- //Read_MidTank_Pressure_Sensor(IFS_info.Ink.cart_color);
- if (MidTank_Pressure >= IFS_info.MidTank_capacity + CARTRIDGE_CAPATICY)
- {
- IFS_info.Ink.time_out = 0;
- WHS_info.event = IFS_MidTankFull;
- return IFS_MidTankFull;
- }
-
- /**** detect if the MidTank_Pressure is the same, 5 times ****/
- if (DetectIfCartridgeFinished(int_MidTank_Pressure_1000))
- {
- Report("------------ INK Cartrigde is empty (by average) -----------------", __FILE__,__LINE__,(IFS_info.Ink.time_out * SECONDS_5), RpMessage, (int_MidTank_Pressure_1000), 0);
- IFS_info.Ink.time_out = 0;
- WHS_info.event = IFS_MidTankFull;
- return IFS_MidTankFull;
- }
-
-
- int timeout = CARTRIDGE_INK_TIMEOUT;
- int secondtimeout = CARTRIDGE_INK_TIMEOUTx2;
- if (IFS_info.Ink.cart_color == MIDTANK_8)//lubricant
- {
- timeout = CARTRIDGE_INK_TIMEOUT*3;
- secondtimeout = CARTRIDGE_INK_TIMEOUTx2 * 3;
- }
- /*** first TimeOut ***/
- if (IFS_info.Ink.time_out == timeout)
- {
- Report("------------ first IFS_info.Ink.time_out, close valves -----------------", __FILE__, __LINE__, (IFS_info.Ink.time_out * SECONDS_5), RpMessage, (int_MidTank_Pressure_1000), 0);
- //IFS_info.Ink.time_out = 0;
- //return IFS_info.event = IFS_Timeout;
+ //Read_MidTank_Pressure_Sensor(IFS_info.Ink.midTankCartColor);
+ if (MidTank_Pressure >= midTankCapacity + CARTRIDGE_CAPATICY)
+ return true;
- // try again :
- // start timeout
- // close and open the correct valves
-
- IFS_info.Ink.time_out = 0;
- MidTankValvesAction(Cartridge_MidTank_OFF);
- IFS_info.Ink.time_out = timeout;
+ if (CartridgeFinishedCount++>=CartridgeCheckTime ) {
+ CartridgeFinishedCount = 0;
+ Report("IFS_filling ", __FILE__,__LINE__,int_MidTank_Pressure_1000, RpMessage, int_MidTank_Pressure_1000, 0);
+ /**** detect if the MidTank_Pressure is the same, 5 times ****/
+ if (DetectIfCartridgeFinished(int_MidTank_Pressure_1000))
+ return true;
}
-
- if (IFS_info.Ink.time_out == (timeout + 1)) //need to open the valve for second chance
- {
- Report("------------ IFS_Timeout open valves for second timeout -----------------", __FILE__, __LINE__, (IFS_info.Ink.time_out * SECONDS_5), RpMessage, (int_MidTank_Pressure_1000), 0);
- MidTankValvesAction(Cartridge_MidTank_ON);
- IFS_info.Ink.time_out = timeout;
- }
-
- if (IFS_info.Ink.time_out >= (secondtimeout + 1))
- {
- Report("------------ IFS_Timeout_Second_Time -----------------", __FILE__, __LINE__, (IFS_info.Ink.time_out * SECONDS_5), RpMessage, (int_MidTank_Pressure_1000), 0);
- IFS_info.Ink.time_out = 0;
- MidTankValvesAction(Cartridge_MidTank_OFF);
- WHS_info.event = IFS_Timeout_Second;
- return IFS_Timeout_Second;
- }
- return ret;
+ return false;
}
+#endif
-/**
- *
- * @brief IFS Time Out Alarm
- *
- * @return OK
- */
-bool IFS_TimeOutAlarm(bool status)
+bool midTankCart_door()
{
- bool ret = OK;
-
- AlarmHandlingSetAlarm( EVENT_TYPE__MID_TANK_1_FILL_TIMEOUT+IFS_info.Ink.cart_color, status);
-
-
- return ret;
-}
+ bool door;
-/**
- *
- * @brief MidTank Valves Action
- * the MidTank have 2 Valves:
- * 1. Ink Color Valve to get INK from the INK Cartridge to Midtank
- * 2. Air valve to get INK in the Midtank we have to open the Air valve so the air can go out
- *
- * @return action to open the Valve use: Cartridge_MidTank_ON/Atm_MidTank_ON
- * to close the Valve use : Cartridge_MidTank_OFF/Atm_MidTank_OFF
- */
-bool MidTankValvesAction(bool action) //Cartridge_MidTank_ON of Cartridge_MidTank_OFF
-{
- bool ret = false;
- if (action == Cartridge_MidTank_ON)
+ if(Get_COVER_1_State(CartridgesDoor))//to check the polarity
{
- Enable_MidTank_Pressure_Reading(IFS_info.Ink.cart_color);
+ door = OPEN;
}
else
{
- Disable_MidTank_Pressure_Reading(IFS_info.Ink.cart_color);
+ door = CLOSE;
}
- if (IDS_IsHomingActive(IFS_info.Ink.cart_color)==false)
- Valve_Set(IDS_Id_to_AirValve[IFS_info.Ink.cart_color], action ); //Atm_MidTank_OFF/ON
- Valve_Set(IDS_Id_to_CartrideValve[IFS_info.Ink.cart_color], action ); //Atm_MidTank_OFF/ON
-
- ret = true;
- return ret;
-}
-
-bool ColorMatch()
-{
- bool ret = false;
-
- ret = true;
- return ret;
+ return door;
}
-char CartridgeRequestToken[36+1];
-int CartridgeRequestId = 0x01010101;
-
-/**
- *
- * @brief create message to PPC
- * temporary message RFID will replace that message.
- * send a request to PPC to know the MidTank number
- * @return OK
- */
-uint32_t ReadCartridgeData(cartridge_name cart_name)
+uint32_t ReadInkCartridgeData()
{
//this function triggers reading and validation of the cartridge information
// for now it sends a request to the tablet to inquire for the ink color/midtank id
@@ -306,16 +198,9 @@ uint32_t ReadCartridgeData(cartridge_name cart_name)
return OK;
}
-/**
- *
- * @brief PPC answers the MidTank number and call WasteTankCBFunction() function.
- * temporary message RFID will replace that message.
- *
- * @return OK
- */
bool CartridgeValidationResponseFunc(MessageContainer* requestContainer)
{
- bool ret = notOK;
+ bool ret = ERROR;
CartridgeValidationResponse* response = cartridge_validation_response__unpack(NULL, requestContainer->data.len, requestContainer->data.data);
@@ -324,118 +209,150 @@ bool CartridgeValidationResponseFunc(MessageContainer* requestContainer)
// 2. the index is out of rang
if (response == NULL)
{
- ReportWithPackageFilter(WHS_filling,"------------ IFS_filling message from PPC is null!!! -----------------", __FILE__,__LINE__,0, RpMessage, 0, 0);
+ Report("IFS_filling message from PPC is null!!!", __FILE__,__LINE__,0, RpMessage, 0, 0);
return ret;
}
if (response->index < NUM_OF_MIDTANKS)
{
- IFS_info.Ink.cart_color = response->index; // midtank 1-8
- ReportWithPackageFilter(WHS_filling,"------------ IFS get message response->index is -----------------", __FILE__, __LINE__, response->index, RpMessage, 0, 0);
- WHS_info.event = IFS_INK_authentication_pass;
+ midTankCartColor = response->index; // midtank 1-8
+ Report("IFS get message response->index is", __FILE__, __LINE__, response->index, RpMessage, 0, 0);
+ inkAuthenticationPass = true;
}
else
{
- ReportWithPackageFilter(WHS_filling,"------------ IFS get message response->index is out of rang -----------------", __FILE__, __LINE__, response->index, RpMessage, 0, 0);
- WHS_info.event = IFS_INK_authentication_fail;
+ Report("IFS get message response->index is out of rang", __FILE__, __LINE__, response->index, RpMessage, 0, 0);
+ inkAuthenticationPass = false;
}
-
- WasteTankCBFunction();//call cart is ok
- ret = OK;
-
-return ret;
+ return OK;
}
-
-/**
- *
- * @brief that response is from STUB. replace the PPC
- * use stub : Poweroff_progress.cs from P:\Users - Public\Shai_Frieder
- * ProgressRequest progressRequest = new ProgressRequest();
- * progressRequest.Amount = 0xCC; //porgress id is 0xCC
- * progressRequest.Delay = 1; //midtank number from 0-7
- *
- *
- * @return OK
- */
void ResponseDemo(int MidtankId)
{
- WHS_info.event = IFS_INK_authentication_pass;
- //global mid tank id = MidtankId;
- IFS_info.Ink.cart_color = MidtankId;
- WasteTankCBFunction();//call cart is ok
+ inkAuthenticationPass = true;
+ midTankCartColor = MidtankId;
}
-uint32_t MidTankReadControlId = 0xFF;
-int MidTankCounter = 0;
-uint32_t MidTankCallBackFunction(uint32_t IfIndex, uint32_t BusyFlag)
+
+void midTankStateMachine(void)
{
- int MidTankOpenAir = 8;
- int MidTankReadPressure = 16;
- int MidTankCloseAir = 40;
- int MidTankEnd = 48;
- int portId;
+ static int init = 1;
+ static int authenticationTimeOutCounter = 0;
- if (MidTankCounter >= MidTankEnd)
- {
- SafeRemoveControlCallback(MidTankReadControlId, MidTankCallBackFunction);
+ if (init) {
+ doorState = midTankCart_door();
+ prevDoorState = doorState;
+ init = 0;
+ } else {
+#ifndef IFS_DEBUG
+ doorState = midTankCart_door();
+#endif
}
- else if (MidTankCounter >= MidTankCloseAir)
- {
- //close air valve for midtank (MidTankCounter-MidTankCloseAir)
- portId = (MidTankCounter - MidTankCloseAir) ; //0-7
- if (IDS_IsHomingActive(portId) == false)
- {
- Disable_MidTank_Pressure_Reading(portId);
- Valve_Set(IDS_Id_to_AirValve[portId], Atm_MidTank_OFF ); //Atm_MidTank_OFF/ON
+ if (!RdInkCartridgeSensor()) { // cartridge not presence
+ Pannel_Leds( CART_1, MODE_OFF);
+ cart1.color = colorOFF;
+ if (IFS_MidTankFilling()) {
+ MidTankValvesAction(Cartridge_MidTank_OFF);
+ Report("Cartridge extracted during filling!!!", __FILE__, __LINE__, midTankState, RpMessage, 0, 0);
+ Report("Mid-tank # filling fail", __FILE__, __LINE__, midTankState, RpMessage, 0, 0);
+ midTankState = MidTankStateIdle;
}
- }
- else if (MidTankCounter >= MidTankReadPressure)
- {
- //read pressure for midtank (MidTankCounter-MidTankCloseAir)
- for (portId = 0;portId < MAX_SYSTEM_DISPENSERS;portId++)
- {
- Read_MidTank_Pressure_Sensor(portId);
+ } else { // cartridge presence
+ if (cart1.color == colorOFF) {
+ Pannel_Leds( CART_1, MODE_ON);
+ cart1.color = colorON;
}
}
- else if (MidTankCounter >= MidTankOpenAir)
+ switch (midTankState)
{
- //open air valve for midtank (MidTankCounter-MidTankOpenAir)
- portId = (MidTankCounter - MidTankOpenAir) ; //0-7
- Enable_MidTank_Pressure_Reading(portId);
- Valve_Set(IDS_Id_to_AirValve[portId], Atm_MidTank_ON ); //Atm_MidTank_OFF/ON
- }
- MidTankCounter++;
- return OK;
-}
+ case MidTankStateIdle:
+ if ((doorState == CLOSE) && (prevDoorState == OPEN)) {
+ //check if power down in process
+ if (PowerOffInProcessGetState()) {
+ Report("Power-down in process", __FILE__, __LINE__, 0, RpMessage, 0, 0);
+ break;
+ }
-uint32_t MidTankReading(void)
-{
- MidTankCounter = 0;
- if (IFS_info.Ink.time_out > 0)
- return ERROR;
- MidTankReadControlId = AddControlCallback("MidTankReading", MidTankCallBackFunction, 300/*eHundredMillisecond*/, TemplateDataReadCBFunction,0,0, 0 );
+ //check RFID? (TBD)
- return OK;
-}
+ // send request for validation to ppc
+ inkAuthenticationPass = 2; //not defined
+ authenticationTimeOutCounter = 0;
+ ReadInkCartridgeData();
-bool INKCartridgeAuthentication(cartridge_name cart_name)
-{
- bool ret = notOK;
- // TBD;
- switch (cart_name)
- {
- case INK_cartridge:
- IFS_info.Ink.autheticate = PASSED; //todo
- //Pannel_Leds(CART_1, MODE_ON);
+ //move to next state
+ midTankState = MidTankStateWait;
+ Report("move to midTankStateWait", __FILE__, prevDoorState, doorState, RpMessage, midTankState, 0);
+ }
+ if (doorState != prevDoorState) {
+ prevDoorState = doorState;
+ }
break;
+ case MidTankStateWait:
+ if (inkAuthenticationPass == 2) {
+ authenticationTimeOutCounter++;
+ Report("MidTank Cartridge authentication wait...", __FILE__, __LINE__, authenticationTimeOutCounter, RpMessage, 0, 0);
+ if (authenticationTimeOutCounter > 60) {
+ midTankState = MidTankStateIdle;
+ }
+ break;
+ }
+ if (inkAuthenticationPass == false) {
+ Report("MidTank Cartridge authentication fail", __FILE__, __LINE__, 0, RpMessage, 0, 0);
+ midTankState = MidTankStateIdle;
+ break;
+ }
+
+ midTankCapacity = Get_MidTank_Pressure_Sensor(midTankCartColor);
+ if (midTankCapacity > MidTankEmptyLimit)
+ {
+ Pannel_Leds(CART_1, MODE_ON);
+ cart1.color = fastBILNK;
+ Report("Mid-tank not empty", __FILE__, __LINE__, midTankCapacity, RpMessage, MidTankEmptyLimit, 0);
+ midTankState = MidTankStateIdle;
+ break;
+ }
+ Report("Mid-tank filling in process", __FILE__,__LINE__,(int)(MidTankEmptyLimit*1000), RpMessage, (int)(midTankCapacity*1000), 0);
+ Pannel_Leds(CART_1, MODE_ON);
+ cart1.color = BLINK;
+
+ if (midTankCartColor == MIDTANK_8)
+ {
+ CartridgeInkTimeout = CARTRIDGE_INK_TIMEOUT*4;
+ CartridgeCheckTime = FIVE_SECONDS*3;
+ }
+ // set valve selection
+ MidTankValvesAction(Cartridge_MidTank_ON);
+ Report("midTankStateWait set valve", __FILE__, __LINE__, 0, RpMessage, 0, 0);
+
+ // RFID change status - TBD
+ // set count down
+ midTankTimeoutCounter = 1;
+
+ //start filling
+ midTankState = MidTankStateFilling;
+ break;
+ case MidTankStateFilling:
+ // if time out or emptying done - idle
+ if (midTankTimeoutCounter++ > CartridgeInkTimeout) {
+ midTankTimeoutCounter = 0;
+ Pannel_Leds(CART_1, MODE_ON);
+ cart1.color = fastBILNK;
+ MidTankValvesAction(Cartridge_MidTank_OFF);
+ Report("Mid-tank # filling fail", __FILE__, __LINE__, midTankState, RpMessage, 0, 0);
+ Report("Call customer support", __FILE__, __LINE__, midTankState, RpMessage, 0, 0);
+ midTankState = MidTankStateIdle;
+ } else if (CartridgeInkFull()) {
+ midTankTimeoutCounter = 0;
+ Pannel_Leds(CART_1, MODE_OFF);
+ cart1.color = colorOFF;
+ MidTankValvesAction(Cartridge_MidTank_OFF);
+ Report("Mid-tank # filling done", __FILE__, __LINE__, midTankState, RpMessage, 0, 0);
+ midTankState = MidTankStateIdle;
+ }
+ break;
default:
- //WHS_info.cartridge_1.autheticate = FAILED; //todo
- // WHS_info.cartridge_2.autheticate = FAILED; //todo
- //Pannel_Leds(CART_2, MODE_OFF);
- //Pannel_Leds(CART_3, MODE_OFF);
+ Report("wrong state", __FILE__, __LINE__, midTankState, RpMessage, 0, 0);
break;
}
- ret = OK;
- return ret;
}
diff --git a/Software/Embedded_SW/Embedded/Modules/IFS/ifs.h b/Software/Embedded_SW/Embedded/Modules/IFS/ifs.h
index 6225dc1d4..bf42c0e9a 100644
--- a/Software/Embedded_SW/Embedded/Modules/IFS/ifs.h
+++ b/Software/Embedded_SW/Embedded/Modules/IFS/ifs.h
@@ -11,55 +11,17 @@
#ifndef MODULES_IFS_IFS_H_
#define MODULES_IFS_IFS_H_
-#include "Modules/Waste/Waste.h"
+#define CARTRIDGE_INK_TIMEOUT 420
+#define MidTank_Pressure_EMPTY 0.5
+#define CARTRIDGE_CAPATICY 1500
-//void IFS_Init(void)
-#define SECONDS_5 5 /**< 5seconds */
-#define SECONDS_300 300 /**< 300 seconds = 5 minutes */
-#define SECONDS_420 (7*60) /**< 420 seconds = 7 minutes */
-#define SECONDS_600 600 /**< 600 seconds = 10 minutes */
-#define SECONDS_2_DLY 0 /**< dly 0 seconds */
-#define CARTRIDGE_INK_TIMEOUT (SECONDS_420 / SECONDS_5) /**< TimeOut (7 minutes) for finishing transfer the Ink from Ink cartridge to MidTank */
-#define CARTRIDGE_INK_TIMEOUTx2 (CARTRIDGE_INK_TIMEOUT * 2) /**< TimeOut (7 minutes) for second try finishing transfer the Ink from Ink cartridge to MidTank */
-#define CartridgeInkTimeOutCallBackTime (eOneSecond * SECONDS_5)
-#define CartridgeInkCallBackTime eOneSecond
-#define MidTank_Pressure_EMPTY 0.3 //todo get from Moti the correct number (Oleg -> 300cc)
-#define MidTank_PP_Pressure_EMPTY 0.5 //todo get from Moti the correct number (Oleg -> 300cc)
-#define CARTRIDGE_CAPATICY 1500 //todo get from Moti the correct number
-#define FULL 1000 //todo get from Moti the correct number
-
-
-
-/**
- * A structure to represent IFS_information
- */
-struct IFS_information
-{
- struct cartridge_params Ink; /**< cartridge_params */
- CarteidgPrecenseSensorStatus IFS_Ink_precense_sensor; /**< INK cartridge presence(1) or not_precense(0) */
- uint32_t Cartridge_Ink_device_Id; /**< INK device_Id number for callback */
- uint32_t Cartridge_Ink_TimeOut_device_Id; /**< INK device_Id number for TimeOut callback */
- uint32_t INK_isOK_flag ; /**< INK cartridge pass authentication (from PPC) */
- double MidTank_capacity; /**< MidTank current capacity */
-};
-
-struct IFS_information IFS_info;
-
-WHS_sensor CartridgeInkCallBackFunction();
-WHS_sensor CartridgeInkTimeOutCallBackFunction();
-uint32_t ReadCartridgeData(cartridge_name cart_name);
-bool INKCartridgeAuthentication(cartridge_name cart_name);
-bool MidTankValvesAction(bool action); //Cartridge_MidTank_ON of Cartridge_MidTank_OFF
-bool ColorMatch();
-bool IFS_TimeOutAlarm(bool status);
-void ResponseDemo(int MidtankId);
-bool IFS_MidTankFilling(void);
-MidTank_t IFS_MidTankIsActive(void);
-
-bool IFS_CartridgeLowerPresent();
-
-bool CartridgeValidationResponseFunc(MessageContainer* requestContainer);
+typedef enum{
+ MidTankStateIdle,
+ MidTankStateWait,
+ MidTankStateFilling
+}MidTankStateEnum;
+void midTankStateMachine(void);
uint32_t MidTankReading(void);
-
+void ResponseDemo(int MidtankId);
#endif /* MODULES_IFS_IFS_H_ */
diff --git a/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Progress.c b/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Progress.c
index 4a7008a7a..bfea7b13b 100644
--- a/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Progress.c
+++ b/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Progress.c
@@ -63,6 +63,7 @@ extern uint8_t Test_Read_Buf[4];
extern uint8_t Head_Fan_PWM_Command[2];
extern uint16_t Head_Fan_Tach[2];
+extern bool doorState;
bool RestartNeeded = false;
@@ -525,6 +526,14 @@ void Stub_ProgressRequest(MessageContainer* requestContainer)
response.has_progress = true;
}
else
+ if(request->amount == 0xAD9) //halt
+ {
+ LOG_ERROR(request->delay,"halt");
+ memset (0,0,100000);
+ response.progress = IgnoreConeMissing;
+ response.has_progress = true;
+ }
+ else
if((request->amount == 0x01) && ((request->delay &0x010000) == 0x010000)) //change mode powerset01
{
response.progress = Power_Step_01_Mode(((request->delay &0x00FF00)>>8), request->delay &0x0000FF);
@@ -1051,6 +1060,16 @@ void Stub_ProgressRequest(MessageContainer* requestContainer)
response.has_progress = true;
}
else
+ if(request->amount == 0xB9) //fast refresh for pressure
+ {
+ if ((request->delay == 0) || (request->delay == 1)) {
+ doorState = request->delay;
+ LOG_ERROR(request->delay,"door");
+ }
+ response.progress = request->delay;
+ response.has_progress = true;
+ }
+ else
if(request->amount == 0xC3) //suspend I2C task
{
if (request->delay == 0)
diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c
index 42a56ae8a..1c52a9b68 100644
--- a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c
+++ b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c
@@ -352,9 +352,9 @@ uint32_t PoolerThreadLengthCBFunction(uint32_t IfIndex, uint32_t ReadValue)
}
if ((CurrentProcessedLength>=CurrentRequestedLength )&&(CurrentRequestedLength > 0.0))
{
- usnprintf(Lenstr, 100, "Total processed length: Feeder: %d Pooler %d",(int)TotalProcessedLength,(int)PoolerTotalProcessedLength);
+ usnprintf(Lenstr, 100, "Total processed length: Feeder: %d Puller %d",(int)TotalProcessedLength,(int)PoolerTotalProcessedLength);
SendJobProgress(0.0,0,false, Lenstr);
- ReportWithPackageFilter(ThreadFilter,Lenstr,__FILE__,__LINE__,(int)TotalProcessedLength,RpWarning,(int)PoolerTotalProcessedLength,0);
+ ReportWithPackageFilter(ThreadFilter,Lenstr,__FILE__,__LINE__,(int)(TotalProcessedLength*100),RpWarning,(int)(PoolerTotalProcessedLength*100),0);
// segment/intersegment/distance to spool finished
if (ProcessedLengthFuncPtr)
ProcessedLengthFuncPtr();
@@ -696,18 +696,19 @@ uint32_t ThreadControlCBFunction(uint32_t IfIndex, uint32_t ReadValue)
}*`/
}*/
calculated_speed = (1-MotorControlConfig[index].m_calculatedError)*OriginalMotorSpd_2PPS[index];
+ calculated_speed = calculated_speed*InitialDryerSpeed/OriginalMotorSpd_2PPS[DRYER_MOTOR];
//calculated_speed = (1-MotorControlConfig[index].m_calculatedError)*CurrentControlledSpeed[index];
- //if (JobCounter % eHundredMillisecond == 50)
- if (FirstCalcInJob == true)
+ if (0)//(JobCounter % 1000 == 0)
+ //if (JobCounter < 100)//(FirstCalcInJob == true)
{
- if (index == POOLER_MOTOR)
+ if (index == FEEDER_MOTOR)
{
- FirstCalcInJob = false;
- len = usnprintf(TMessage, 150, "read %d avg %d error(6) %d integral(9) %d,delta(9) %d, calc(3) %d speed %d",
- ReadValue,avreageSampleValue,(int)(MotorControlConfig[index].m_mesuredParam*1000000),
+ // FirstCalcInJob = false;
+ len = usnprintf(TMessage, 150, "read %d avg %d error(6) %d integral(9) %d,delta(9) %d, calc(3) %d speed %d %d",
+ TranslatedReadValue,avreageSampleValue,(int)(MotorControlConfig[index].m_mesuredParam*1000000),
(int)(MotorControlConfig[index].m_integral*1000000000),(int)((MotorControlConfig[index].m_mesuredParam*MotorControlConfig[index].m_params.dt)*1000000000),
- (int)(MotorControlConfig[index].m_calculatedError*1000),(int)calculated_speed);
- ReportWithPackageFilter(ThreadFilter,TMessage,__FILE__,__LINE__,DancerId,RpError,ReadValue,0);
+ (int)(MotorControlConfig[index].m_calculatedError*1000),(int)calculated_speed, (int)(InitialDryerSpeed*100/OriginalMotorSpd_2PPS[DRYER_MOTOR]));
+ ReportWithPackageFilter(ThreadFilter,TMessage,__FILE__,MotorSamplePointer[index],JobCounter,RpError,ReadValue,0);
}
}
@@ -720,6 +721,11 @@ uint32_t ThreadControlCBFunction(uint32_t IfIndex, uint32_t ReadValue)
{
if (calculated_speed>5.0)
{
+ if (calculated_speed>(CurrentControlledSpeed[index]+100))
+ {
+ ReportWithPackageFilter(ThreadFilter,"limit acceleration",__FILE__,calculated_speed,CurrentControlledSpeed[index],RpError,CurrentControlledSpeed[index]+100,0);
+ calculated_speed=CurrentControlledSpeed[index]+100;
+ }
CurrentControlledSpeed[index] = calculated_speed;
MotorSetSpeed(ThreadMotorIdToMotorId[index], calculated_speed);
}
@@ -845,6 +851,7 @@ uint32_t Release_Right_TFU_Tension()
return status;
}
int SecondFeederCorrection = 4;
+int PrepareWaitCount = 0;
uint32_t Adjust_Right_TFU_Tension_2nd_Callback(uint32_t MotorId, uint32_t ReadValue)
{
MotorStop (HARDWARE_MOTOR_TYPE__MOTO_RDANCER,Soft_Stop); //per L6470 errata between mov and run commands
@@ -854,6 +861,18 @@ uint32_t Adjust_Right_TFU_Tension_2nd_Callback(uint32_t MotorId, uint32_t ReadVa
Report("release tension - job aborted",__FILE__,__LINE__,MotorId,RpMessage,0,0);
Release_Right_TFU_Tension();
}
+ if (PrepareWaitCount)
+ {
+ ReportWithPackageFilter(ThreadFilter,"ThreadPrepare_TensionCallback",__FILE__,__LINE__,2,RpWarning,PrepareWaitCount,0);
+ PrepareWaitCount--;
+ }
+ if ((PrepareWaitCount == 0)&&(PrepareState == true))
+ {
+ PrepareState = false;
+ ReportWithPackageFilter(ThreadFilter,"ThreadPrepare_TensionCallback Prepare Ready",__FILE__,__LINE__,2,RpWarning,PrepareWaitCount,0);
+ PrepareReady(Module_Thread,ModuleDone);
+ }
+
return OK;
}
uint32_t Adjust_Right_TFU_Tension_Callback(uint32_t MotorId, uint32_t ReadValue)
@@ -869,16 +888,16 @@ uint32_t Adjust_Right_TFU_Tension(double tension)
uint32_t status = OK;
if (tension > 0.5) //0 = lower position, 1 = high position
{
+ //PrepareWaitCount++;
if (FPGA_Read_limit_Switches(GPI_LS_RDANCER_UP) == NO_LIMIT)
{
- MotorMovetoLimitSwitch (HARDWARE_MOTOR_TYPE__MOTO_RDANCER,1-MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_RDANCER].directionthreadwize, 40, GPI_LS_RDANCER_UP, Adjust_Right_TFU_Tension_Callback,15000);
+ MotorMovetoLimitSwitch (HARDWARE_MOTOR_TYPE__MOTO_RDANCER,1-MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_RDANCER].directionthreadwize, 15, GPI_LS_RDANCER_UP, Adjust_Right_TFU_Tension_Callback,15000);
Report("Adjust_Right_TFU_Tension",__FILE__,1-MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_RDANCER].directionthreadwize,HARDWARE_MOTOR_TYPE__MOTO_RDANCER,RpMessage,GPI_LS_RDANCER_UP,0);
}
}
return status;
}
-int PrepareWaitCount = 0;
uint32_t ThreadPrepare_TensionCallback (int DancerId, double tension)
{
if (PrepareWaitCount)
@@ -886,7 +905,7 @@ uint32_t ThreadPrepare_TensionCallback (int DancerId, double tension)
ReportWithPackageFilter(ThreadFilter,"ThreadPrepare_TensionCallback",__FILE__,__LINE__,DancerId,RpWarning,PrepareWaitCount,0);
PrepareWaitCount--;
}
- if (PrepareWaitCount == 0)
+ if ((PrepareWaitCount == 0)&&(PrepareState == true))
{
PrepareState = false;
ReportWithPackageFilter(ThreadFilter,"ThreadPrepare_TensionCallback Prepare Ready",__FILE__,__LINE__,DancerId,RpWarning,PrepareWaitCount,0);
@@ -1046,71 +1065,73 @@ uint32_t ThreadPrepareState(void *JobDetails)
{
HW_Motor_Id = ThreadMotorIdToMotorId[Motor_i];
Pid_Id = Motor_i;/*ThreadMotorIdToControlId[Motor_i];*/
- MotorControlConfig[Motor_i].m_params.MAX = 1;
- MotorControlConfig[Motor_i].m_params.MIN = MotorsControl[Pid_Id].outputproportionalpowerlimit*-1;
- MotorControlConfig[Motor_i].m_params.Kd = MotorsControl[Pid_Id].derivativetime;
- MotorControlConfig[Motor_i].m_params.Kp = MotorsControl[Pid_Id].proportionalgain;
- MotorControlConfig[Motor_i].m_params.Ki = MotorsControl[Pid_Id].integraltime;
- MotorControlConfig[Motor_i].m_params.IntegralErrorMultiplier = MotorsControl[Pid_Id].setpointramprateorsoftstartramp;
- MotorControlConfig[Motor_i].m_params.ProportionalErrorMultiplier = MotorsControl[Pid_Id].outputonoffhysteresisvalue;
- MotorControlConfig[Motor_i].m_params.epsilon = MotorsControl[Pid_Id].epsilon;
- MotorControlConfig[Motor_i].m_params.dt = MotorsControl[Pid_Id].controloutputtype;
- MotorControlConfig[Motor_i].m_ingnoreValue = MotorsControl[Pid_Id].sensorcorrectionadjustment; // the minimal change required to change the motor speed in pulses
- MotorControlConfig[Motor_i].m_calculatedError = 0;
- MotorControlConfig[Motor_i].m_integral = 0;
- MotorControlConfig[Motor_i].m_isEnabled = true;
- MotorControlConfig[Motor_i].m_isReady = true;
- MotorControlConfig[Motor_i].m_mesuredParam = 0;
- MotorControlConfig[Motor_i].m_preError = 0;
- MotorControlConfig[Motor_i].m_SetParam = 0;//need to update SetParams on presegment stage
+ MotorControlConfig[Motor_i].m_params.MAX = 1;
+ MotorControlConfig[Motor_i].m_params.MIN = MotorsControl[Pid_Id].outputproportionalpowerlimit*-1;
+ MotorControlConfig[Motor_i].m_params.Kd = MotorsControl[Pid_Id].derivativetime;
+ MotorControlConfig[Motor_i].m_params.Kp = MotorsControl[Pid_Id].proportionalgain;
+ MotorControlConfig[Motor_i].m_params.Ki = MotorsControl[Pid_Id].integraltime;
+ MotorControlConfig[Motor_i].m_params.IntegralErrorMultiplier = MotorsControl[Pid_Id].setpointramprateorsoftstartramp;
+ MotorControlConfig[Motor_i].m_params.ProportionalErrorMultiplier = MotorsControl[Pid_Id].outputonoffhysteresisvalue;
+ MotorControlConfig[Motor_i].m_params.epsilon = MotorsControl[Pid_Id].epsilon;
+ MotorControlConfig[Motor_i].m_params.dt = MotorsControl[Pid_Id].controloutputtype;
+ MotorControlConfig[Motor_i].m_ingnoreValue = MotorsControl[Pid_Id].sensorcorrectionadjustment; // the minimal change required to change the motor speed in pulses
+ MotorControlConfig[Motor_i].m_calculatedError = 0;
+ MotorControlConfig[Motor_i].m_integral = 0;
+ MotorControlConfig[Motor_i].m_isEnabled = true;
+ MotorControlConfig[Motor_i].m_isReady = true;
+ MotorControlConfig[Motor_i].m_mesuredParam = 0;
+ MotorControlConfig[Motor_i].m_preError = 0;
+ MotorControlConfig[Motor_i].m_SetParam = 0;//need to update SetParams on presegment stage
- HandleJobThreadControlParameters(JobTicket->threadparameters); //OVERRIDES CONFIGURATION PARAMETERS!!!
+ HandleJobThreadControlParameters(JobTicket->threadparameters); //OVERRIDES CONFIGURATION PARAMETERS!!!
- temp_dt = MotorControlConfig[Motor_i].m_params.dt/0.001;
- MotorTiming[Motor_i] = (int)temp_dt;
- if (MotorTiming[Motor_i])
- {
- MotorTimer[Motor_i] = MotorTiming[Motor_i]-1;
- ReportWithPackageFilter(ThreadFilter,"MotorTiming",__FILE__,Motor_i,MotorTiming[Motor_i],RpWarning,MotorTimer[Motor_i],0);
- }
+ temp_dt = MotorControlConfig[Motor_i].m_params.dt/0.001;
+ MotorTiming[Motor_i] = (int)temp_dt;
+ if (MotorTiming[Motor_i])
+ {
+ MotorTimer[Motor_i] = MotorTiming[Motor_i]-1;
+ ReportWithPackageFilter(ThreadFilter,"MotorTiming",__FILE__,Motor_i,MotorTiming[Motor_i],RpWarning,MotorTimer[Motor_i],0);
+ }
//////////////////////////////////////////////////
- for (i = 0;i < (int)MotorsControl[Motor_i].pvinputfilterfactormode; i++)
- {
- //if (Motor_i == DRYER_MOTOR) // dryer motor is speed controlled. later a speed sensor will be utilized, but for now it will not be controlled
- MotorSamples[Motor_i][i] = 0;
- // else if ((Motor_i == POOLER_MOTOR)||(Motor_i == FEEDER_MOTOR))
- // MotorSamples[Motor_i][i] = DancersCfg[ThreadMotorIdToDancerId[Motor_i]].zeropoint;
- //MotorSpeedSamples[Motor_i][i] = 0;
- }
- MotorSamplePointer[Motor_i] = 0;
+ for (i = 0;i < (int)MotorsControl[Motor_i].pvinputfilterfactormode; i++)
+ {
+ //if (Motor_i == DRYER_MOTOR) // dryer motor is speed controlled. later a speed sensor will be utilized, but for now it will not be controlled
+ MotorSamples[Motor_i][i] = 0;
+ if (Motor_i == FEEDER_MOTOR)
+ MotorSamples[Motor_i][i] = -500;
+ // else if ((Motor_i == POOLER_MOTOR)||(Motor_i == FEEDER_MOTOR))
+ // MotorSamples[Motor_i][i] = DancersCfg[ThreadMotorIdToDancerId[Motor_i]].zeropoint;
+ //MotorSpeedSamples[Motor_i][i] = 0;
+ }
+ MotorSamplePointer[Motor_i] = 0;
/////////////////////////////////////////////////////
- MotorSetDirection((TimerMotors_t)HW_Motor_Id,MotorsCfg[HW_Motor_Id].directionthreadwize);
+ MotorSetDirection((TimerMotors_t)HW_Motor_Id,MotorsCfg[HW_Motor_Id].directionthreadwize);
- if (Motor_i == FEEDER_MOTOR) // dryer motor is speed controlled. later a speed sensor will be utilized, but for now it will not be controlled
+ if (Motor_i == FEEDER_MOTOR) // dryer motor is speed controlled. later a speed sensor will be utilized, but for now it will not be controlled
+ {
+ ReportWithPackageFilter(ThreadFilter,"Feeder Control",__FILE__,Motor_i,MotorControlConfig[Motor_i].m_params.Kp,RpWarning,MotorControlConfig[Motor_i].m_params.Ki,0);
+ if (SpeedControlId != 0xFF)
{
- ReportWithPackageFilter(ThreadFilter,"Feeder Control",__FILE__,Motor_i,MotorControlConfig[Motor_i].m_params.Kp,RpWarning,MotorControlConfig[Motor_i].m_params.Ki,0);
- if (SpeedControlId != 0xFF)
- {
- RemoveControlCallback(SpeedControlId,ThreadLengthCBFunction);
- SpeedControlId = 0xFF;
- }
- //SetMotHome(ThreadMotorIdToMotorId[Motor_i]);
- LengthCalculationMultiplier = (MotorsCfg[ThreadMotorIdToMotorId[Motor_i]].pulleyradius*2*PI)/(MotorsCfg[ThreadMotorIdToMotorId[Motor_i]].pulseperround*MotorsCfg[ThreadMotorIdToMotorId[Motor_i]].microstep);
- SpeedControlId = AddControlCallback(NULL,ThreadLengthCBFunction, eHundredMillisecond,MotorGetPositionFromFPGA,(IfTypeThread*0x100+Motor_i),ThreadMotorIdToMotorId[Motor_i],Motor_i);
+ RemoveControlCallback(SpeedControlId,ThreadLengthCBFunction);
+ SpeedControlId = 0xFF;
}
- if (Motor_i == POOLER_MOTOR) // dryer motor is speed controlled. later a speed sensor will be utilized, but for now it will not be controlled
+ //SetMotHome(ThreadMotorIdToMotorId[Motor_i]);
+ LengthCalculationMultiplier = (MotorsCfg[ThreadMotorIdToMotorId[Motor_i]].pulleyradius*2*PI)/(MotorsCfg[ThreadMotorIdToMotorId[Motor_i]].pulseperround*MotorsCfg[ThreadMotorIdToMotorId[Motor_i]].microstep);
+ SpeedControlId = AddControlCallback(NULL,ThreadLengthCBFunction, eHundredMillisecond,MotorGetPositionFromFPGA,(IfTypeThread*0x100+Motor_i),ThreadMotorIdToMotorId[Motor_i],Motor_i);
+ }
+ if (Motor_i == POOLER_MOTOR) // dryer motor is speed controlled. later a speed sensor will be utilized, but for now it will not be controlled
+ {
+ ReportWithPackageFilter(ThreadFilter,"Puller Control",__FILE__,Motor_i,MotorControlConfig[Motor_i].m_params.Kp,RpWarning,MotorControlConfig[Motor_i].m_params.Ki,0);
+ if (PoolerSpeedControlId != 0xFF)
{
- ReportWithPackageFilter(ThreadFilter,"Puller Control",__FILE__,Motor_i,MotorControlConfig[Motor_i].m_params.Kp,RpWarning,MotorControlConfig[Motor_i].m_params.Ki,0);
- if (PoolerSpeedControlId != 0xFF)
- {
- if (RemoveControlCallback(PoolerSpeedControlId,PoolerThreadLengthCBFunction)!=OK)
- ReportWithPackageFilter(ThreadFilter,"Remove Control Failed.",__FILE__,__LINE__,(int)Motor_i,RpError,(int)PoolerSpeedControlId,0);
- PoolerSpeedControlId = 0xFF;
- }
- //SetMotHome(ThreadMotorIdToMotorId[Motor_i]);
- PoolerLengthCalculationMultiplier = (MotorsCfg[ThreadMotorIdToMotorId[Motor_i]].pulleyradius*2*PI)/(MotorsCfg[ThreadMotorIdToMotorId[Motor_i]].pulseperround*MotorsCfg[ThreadMotorIdToMotorId[Motor_i]].microstep);
- PoolerSpeedControlId = AddControlCallback(NULL,PoolerThreadLengthCBFunction, eHundredMillisecond,MotorGetPositionFromFPGA,(IfTypeThread*0x100+Motor_i),ThreadMotorIdToMotorId[Motor_i],Motor_i);
+ if (RemoveControlCallback(PoolerSpeedControlId,PoolerThreadLengthCBFunction)!=OK)
+ ReportWithPackageFilter(ThreadFilter,"Remove Control Failed.",__FILE__,__LINE__,(int)Motor_i,RpError,(int)PoolerSpeedControlId,0);
+ PoolerSpeedControlId = 0xFF;
}
+ //SetMotHome(ThreadMotorIdToMotorId[Motor_i]);
+ PoolerLengthCalculationMultiplier = (MotorsCfg[ThreadMotorIdToMotorId[Motor_i]].pulleyradius*2*PI)/(MotorsCfg[ThreadMotorIdToMotorId[Motor_i]].pulseperround*MotorsCfg[ThreadMotorIdToMotorId[Motor_i]].microstep);
+ PoolerSpeedControlId = AddControlCallback(NULL,PoolerThreadLengthCBFunction, eHundredMillisecond,MotorGetPositionFromFPGA,(IfTypeThread*0x100+Motor_i),ThreadMotorIdToMotorId[Motor_i],Motor_i);
+ }
if (Motor_i == FEEDER_MOTOR) // dryer motor is speed controlled. later a speed sensor will be utilized, but for now it will not be controlled
{
if (ControlIdtoMotorId[Motor_i] != 0xFF)
@@ -1152,10 +1173,6 @@ uint32_t ThreadPrepareState(void *JobDetails)
ControlIdtoMotorId[Motor_i] = AddControlCallback(NULL,ThreadControlCBFunction, eOneMillisecond,Control_Read_Dancer_Position,(IfTypeThread*0x100+Motor_i),ThreadMotorIdToDancerId[Motor_i],Motor_i);
#endif
}
-// if (HW_Motor_Id == HARDWARE_MOTOR_TYPE__MOTO_DRYER_DRIVING) // dryer motor is speed controlled. later a speed sensor will be utilized, but for now it will not be controlled
-// AddControlCallback(ThreadSpeedControlCBFunction, eOneMillisecond,TemplateDataReadCBFunction,(IfTypeThread*0x100+Motor_i),ThreadMotorIdToMotorId[Motor_i],0);
- if (Motor_i == ThreadMotorIdToMotorId[DRYER_MOTOR]) // dryer motor is speed controlled. later a speed sensor will be utilized, but for now it will not be controlled
- continue;
}
#ifdef TEST_PID_THREAD
@@ -1382,7 +1399,7 @@ char Endstr[150];
int Motor_i;
ThreadControlActive = false;
uint32_t status = OK;
- usnprintf(Endstr, 100, "Total _processed length: Feeder: %d Pooler %d",(int)TotalProcessedLength,(int)PoolerTotalProcessedLength);
+ usnprintf(Endstr, 100, "Total _processed length: Feeder: %d Puller %d",(int)TotalProcessedLength,(int)PoolerTotalProcessedLength);
SendJobProgress(0.0,0,false, Endstr);
ReportWithPackageFilter(ThreadFilter,Endstr,__FILE__,__LINE__,(int)TotalProcessedLength,RpWarning,(int)PoolerTotalProcessedLength,0);
diff --git a/Software/Embedded_SW/Embedded/Modules/Waste/Waste_ex.h b/Software/Embedded_SW/Embedded/Modules/Waste/Waste_ex.h
index 2fdd3a479..7d6837018 100644
--- a/Software/Embedded_SW/Embedded/Modules/Waste/Waste_ex.h
+++ b/Software/Embedded_SW/Embedded/Modules/Waste/Waste_ex.h
@@ -1,5 +1,5 @@
-#ifndef WASTE_MAINT_H
-#define WASTE_MAINT_H
+#ifndef WASTE_EX_H
+#define WASTE_EX_H
typedef enum {
CartridgeStateOUT,
diff --git a/Software/Embedded_SW/Embedded/Modules/Waste/Waste_init.c b/Software/Embedded_SW/Embedded/Modules/Waste/Waste_init.c
index 03ee73daf..870463321 100644
--- a/Software/Embedded_SW/Embedded/Modules/Waste/Waste_init.c
+++ b/Software/Embedded_SW/Embedded/Modules/Waste/Waste_init.c
@@ -1,4 +1,5 @@
/* ---- WHS */
+#if 0
#include <Container.h>
#include <DataDef.h>
#include "include.h"
@@ -1446,7 +1447,7 @@ U8 WHS_HW_test()
return ret;
}
-
+#endif
/*------------------------------------------------------------------------------------------------*/
diff --git a/Software/Embedded_SW/Embedded/Modules/Waste/Waste_maint.c b/Software/Embedded_SW/Embedded/Modules/Waste/Waste_maint.c
index 099fc0c2e..dc76a3390 100644
--- a/Software/Embedded_SW/Embedded/Modules/Waste/Waste_maint.c
+++ b/Software/Embedded_SW/Embedded/Modules/Waste/Waste_maint.c
@@ -32,6 +32,10 @@ uint32_t Cartridge_Cover_Control;
button *CartLed[MaxWasteCartridges] = {0, &cart2, &cart3};
WasteTankStateEnum WasteTankState = WasteTankStateIdle;
+int init = 1;
+
+bool setWasteValve (WasteCartridgeEnum WasteCartridge);
+
#define WASTE_CARTRIDGE_SIZE 1500
#define WASTE_LEVEL_OVERFLOW 2700
#define WASTE_LEVEL_FULL 2300
@@ -65,6 +69,8 @@ void cartCART_EXTRACTED(WasteCartridgeEnum CartId) //{called from polling functi
Report("Cartridges Cart extracted", __FILE__, __LINE__, CartId, RpMessage, CartState[CartId], 0);
CartState[CartId] = CartridgeStateOUT;
CartLed[CartId]->color = colorOFF;
+ if (init==0)
+ WHS_Set_IFS_Clearing_Suction(NUM_OF_MIDTANKS);
}
WasteCartridgeEnum cartSELECT_CART(void) //{ if there is no SELECTED cartridge select the first cartridge in IN state. If there is none, return -1}
@@ -113,6 +119,8 @@ void cartFILLING_END(void)
} else {
Report("Cartridges end with no active cartridge", __FILE__, __LINE__, CartState[WasteCartridge_middle], RpMessage, CartState[WasteCartridge_lower], 0);
}
+ setWasteValve(WasteCartridge_middle);
+
}
CartridgeStateEnum cartGetState(WasteCartridgeEnum CartId)
@@ -163,6 +171,119 @@ WasteCartridgeEnum cartNotAllFull()
return false;
}
+bool SetWastePump( bool power)
+{
+ if ( power == OPEN ) {
+ if (WHS_Type == WHS_TYPE_UNKNOWN) {
+ Pumps_Control(WHS_WTANKPUMP2, OPEN); //waste_pump_power_on();
+ } else { //new WHS
+ Trigger_SetWHSPump(OPEN);
+ }
+ return OPEN;
+ } else {
+ if (WHS_Type == WHS_TYPE_UNKNOWN) {
+ Pumps_Control(WHS_WTANKPUMP2, CLOSE); //waste_pump_power_on();
+ } else { //new WHS
+ Trigger_SetWHSPump(CLOSE);
+ }
+ return CLOSE;
+ }
+}
+
+bool setWasteValve (WasteCartridgeEnum WasteCartridge)
+{
+ bool direction;
+
+ if (WasteCartridge == WasteCartridge_lower) {
+ direction = true;
+ } else {
+ direction = false;
+ }
+
+ if (WHS_Type == WHS_TYPE_UNKNOWN) {
+ Valve_Set(VALVE_WASTE_TANK,direction);
+ } else { //new WHS
+ Trigger_SetWHSValveWatseCartridge(direction);
+ }
+ return direction;
+}
+
+bool RdWasteTankEmptySensor()
+{
+ //double WasteLevel = 0.0;
+
+ if (WHS_Type == WHS_TYPE_UNKNOWN) {
+ return WHS_GPI_WCONTAINER_WARN();
+ } else { //new WHS
+ //WasteLevel = GetWHSWasteTankLevelMiliLiter();
+ if (wasteLevel < wasteLevelEmpty)
+ return 1; //Empty
+ }
+ return 0;
+}
+
+bool RdWasteTankFullSensor()
+{
+ //double WasteLevel = 0.0;
+
+ if (WHS_Type == WHS_TYPE_UNKNOWN) {
+ return WHS_GPI_WCONTAINER_FULL();
+ } else { //new WHS
+ //WasteLevel = GetWHSWasteTankLevelMiliLiter();
+ if (wasteLevel >= wasteLevelFull)
+ return 1; //full
+ }
+ return 0;
+}
+
+bool RdWasteTankOverFlowSensor()
+{
+ //double WasteLevel = 0.0;
+
+ if (WHS_Type == WHS_TYPE_UNKNOWN) {
+ return WHS_GPI_WASTE_OVERFULL();
+ } else {//new WHS
+ //WasteLevel = GetWHSWasteTankLevelMiliLiter();
+ if (wasteLevel > wasteLevelOverflow)
+ return 1; //overflow
+ }
+ return 0;
+}
+
+bool WHS_IsContainerFull()
+{
+ return RdWasteTankFullSensor();
+}
+
+bool WHS_IsContainerEmpty()
+{
+ return RdWasteTankEmptySensor();
+}
+
+bool WHS_IsContainerOverflow()
+{
+ return RdWasteTankOverFlowSensor();
+}
+
+bool WHS_WasteCartridgeLowerPresent()
+{
+ return Is_Cartridge_Present(CART_3);
+}
+
+bool WHS_WasteCartridgeMiddlePresent()
+{
+ return Is_Cartridge_Present(CART_2);
+}
+
+bool WHS_IsEmptying()
+{
+ if (WasteTankState == WasteTankStateEmptying) {
+ return true;
+ } else {
+ return false;
+ }
+}
+
void Waste_Init()
{
CartState[WasteCartridge_middle] = CartridgeStateOUT;
@@ -186,7 +307,6 @@ bool cartCart_door()//Polled by polling function. Notify waste. Poll each 1 seco
return DoorState;
}
-//Waste_DoorOpenDuringEmptying
uint32_t Waste_DoorOpenDuringEmptying(uint32_t IfIndex, uint32_t ReadValue)
{
cartCart_door();
@@ -212,7 +332,6 @@ uint32_t Waste_DoorOpenDuringEmptying(uint32_t IfIndex, uint32_t ReadValue)
void Waste_StateMachine_OneSecond_Call(void)
{
- static int init = 1;
static WasteTankStateEnum prev_state = 0;
static int prev_wasteLevel = 0;
@@ -263,7 +382,7 @@ void Waste_StateMachine(void)
switch (WasteTankState)
{
case WasteTankStateIdle:
- if (wasteLevel > wasteLevelOverFlow) {
+ if(WHS_IsContainerOverflow()) {
AlarmHandlingSetAlarm( EVENT_TYPE__WASTE_CONTAINER_OVERFLOW, true);
} else {
AlarmHandlingSetAlarm( EVENT_TYPE__WASTE_CONTAINER_OVERFLOW, false);
@@ -271,7 +390,7 @@ void Waste_StateMachine(void)
if (cartNotAllFull() == true) {
AlarmHandlingSetAlarm( EVENT_TYPE__ALL_WASTE_CARTRIDGES_FULL, false);
}
- if (wasteLevel > wasteLevelFull) {
+ if(WHS_IsContainerFull()) {
//check if power down in process
if ( PowerOffInProcessGetState() ) {
Report("Power-down in process", __FILE__, __LINE__, 0, RpMessage, 0, 0);
@@ -307,9 +426,8 @@ void Waste_StateMachine(void)
// set valve selection
activeCart = cartGetActiveCart();
- Valve_Set(VALVE_WASTE_TANK, activeCart);
- Report("WasteTankStateEmptying set valve", __FILE__, __LINE__, activeCart, RpMessage, 0, 0);
-
+ //Report("WasteTankStateEmptying set valve", __FILE__, __LINE__, activeCart, RpMessage, 0, 0);
+ setWasteValve(activeCart);
// RFID change status - TBD
// set count down
@@ -317,6 +435,7 @@ void Waste_StateMachine(void)
// set emptying limit
wasteLevelEmpty = wasteLevel - WASTE_CARTRIDGE_SIZE;
+ waste_seq_step1_cont();
// start a timer to observe door opening
Cartridge_Cover_Control = AddControlCallback("Cartridge Cover Door", Waste_DoorOpenDuringEmptying, 100, cartCart_door, 0, 0, 0);
@@ -338,15 +457,18 @@ void Waste_StateMachine(void)
Report("WasteTankStateEmptying TimeOut", __FILE__, __LINE__, 0, RpMessage, 0, 0);
AlarmHandlingSetAlarm( EVENT_TYPE__WASTE_CONTAINER_EMPTYING_TIMEOUT, true);
RemoveControlCallback(Cartridge_Cover_Control, Waste_DoorOpenDuringEmptying);
- } else if (wasteLevel < wasteLevelEmpty) {
+ timeout_counter = 0;
+ } else if (WHS_IsContainerEmpty()) {
SetWastePump(CLOSE);
cartFILLING_END();
+ waste_seq_cont_stop();
// RFID change status - TBD
WasteTankState = WasteTankStateIdle;
RemoveControlCallback(Cartridge_Cover_Control, Waste_DoorOpenDuringEmptying);
if (cartNotAllFull() == false)
AlarmHandlingSetAlarm( EVENT_TYPE__ALL_WASTE_CARTRIDGES_FULL, true);
Report("WasteTankStateEmptying done", __FILE__, __LINE__, 0, RpMessage, 0, 0);
+ timeout_counter = 0;
}
#ifdef WHS_DEBUG
wasteLevel -= 100;
@@ -355,6 +477,21 @@ void Waste_StateMachine(void)
break;
case WasteTankStatePaused:
Report("WasteTankStatePaused...", __FILE__, __LINE__, 0, RpMessage, 0, 0);
+ activeCart = cartGetActiveCart();
+ if (activeCart == MaxWasteCartridges)
+ {
+ SetWastePump(CLOSE);
+ cartFILLING_END();
+ waste_seq_cont_stop();
+ // RFID change status - TBD
+ WasteTankState = WasteTankStateIdle;
+ RemoveControlCallback(Cartridge_Cover_Control, Waste_DoorOpenDuringEmptying);
+ if (cartNotAllFull() == false)
+ AlarmHandlingSetAlarm( EVENT_TYPE__ALL_WASTE_CARTRIDGES_FULL, true);
+ Report("WasteTankStatePaused done", __FILE__, __LINE__, 0, RpMessage, 0, 0);
+ timeout_counter = 0;
+
+ }
break;
default:
Report("wrong state", __FILE__, WasteTankState, 0, RpMessage, SelectedCard, 0);
diff --git a/Software/Embedded_SW/Embedded/Modules/Waste/Waste_maint.h b/Software/Embedded_SW/Embedded/Modules/Waste/Waste_maint.h
deleted file mode 100644
index e69de29bb..000000000
--- a/Software/Embedded_SW/Embedded/Modules/Waste/Waste_maint.h
+++ /dev/null
diff --git a/Software/Embedded_SW/Embedded/Modules/Waste/Waste_print.c b/Software/Embedded_SW/Embedded/Modules/Waste/Waste_print.c
deleted file mode 100644
index e69de29bb..000000000
--- a/Software/Embedded_SW/Embedded/Modules/Waste/Waste_print.c
+++ /dev/null
diff --git a/Software/Embedded_SW/Embedded/Software Release Notes.txt b/Software/Embedded_SW/Embedded/Software Release Notes.txt
index 8857b69eb..66a039a7d 100644
--- a/Software/Embedded_SW/Embedded/Software Release Notes.txt
+++ b/Software/Embedded_SW/Embedded/Software Release Notes.txt
@@ -2,10 +2,28 @@ Embedded SW Release note - Version 1.4.6.35 - Pack Mid alpha
=============================================================
Arc head - activate arc heaters gradually
stop FPGA Reinit after 20 trials
-Head cleaning - move actuators (with stub - 0xAD7)
+Head cleaning - move actuators
fix RML PID support
-head open prevent job - (with stub - 0xAD6)
-add stub to overrule cone missing - 0xAD8
+head open prevent job
+add stub to overrule cone missing
+
+fixed I2C delays - will help in real time and disconnection
+new blower bug - prevent turning blower off
+new blower- minimal voltage 2400 (moti)
+
+motor alarms - new approach (warning, rises immediately).
+new WASTE handling
+new IFS handling
+IDS - cleaning. FIXED ink calculation info
+thread - fix initial feeder dancer drop on job start
+
+stubs:
+skip open lids test (amount = 0xAD6)
+skip actuators cleaning sequence (amount = 0xAD7)
+skip spool presence check (amount = 0xAD8)
+watchdog activity check (amount = 0xAD9)
+
+
Embedded SW Release note - Version 1.4.6.34 - Pack 2+
=============================================================
diff --git a/Software/Embedded_SW/Embedded/StateMachines/Initialization/PowerOffSequence.c b/Software/Embedded_SW/Embedded/StateMachines/Initialization/PowerOffSequence.c
index 169772480..dfd9ffaa5 100644
--- a/Software/Embedded_SW/Embedded/StateMachines/Initialization/PowerOffSequence.c
+++ b/Software/Embedded_SW/Embedded/StateMachines/Initialization/PowerOffSequence.c
@@ -34,6 +34,7 @@
#include "drivers/I2C_Communication/ADC_MUX/ADC_MUX.h"
#include "drivers/Heater/TemperatureSensor.h"
#include "drivers/Valves/Valve.h"
+#include <Drivers/I2C_Communication/I2C.h>
#include <Drivers/I2C_Communication/WHS_Card/D_Max5805_ADC_Blower/WHS_Blower.h>
#include "StateMachines/Printing/PrintingSTM.h"
@@ -484,6 +485,7 @@ uint32_t PowerOffTurnOffCooler(void)
uint32_t PowerOffTurnOffBlower(void)
{
WHS_Set_SetPoint_Q_value(0);
+ Control_Voltage_To_Blower(500);
Turn_the_Blower_Off();//Turn off
PowerOffMachineState++;
return OK;
@@ -492,6 +494,8 @@ uint32_t PowerOffTurnOffBlower(void)
uint32_t PowerOffPowerOff(void)
{
int i;
+ Task_setPri (I2C_Task_Handle,-1);
+
for (i = 0;i<10;i++)
{
REPORT_MSG (10-i, "Power off in x seconds");
diff --git a/Software/Embedded_SW/Embedded/src/makefile.libs b/Software/Embedded_SW/Embedded/src/makefile.libs
index f262762ef..ae6999352 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 0f63ec463..a8280a913 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.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
+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
-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
index 93c4f5655..50096cc7a 100644
--- a/Software/Embedded_SW/Embedded/src/sysbios/sysbios.aem4f
+++ b/Software/Embedded_SW/Embedded/src/sysbios/sysbios.aem4f
Binary files differ