From 6a1dff8d05740d86d8fbcfc582818f802d62b13c Mon Sep 17 00:00:00 2001 From: Avi Levkovich Date: Mon, 26 Oct 2020 17:33:41 +0200 Subject: Update Shinko --- Software/Embedded_SW/Embedded/DataDef.h | 1 - .../Embedded/Drivers/I2C_Communication/I2C_Task.c | 14 ++ .../Embedded/Drivers/I2C_Communication/I2C_Task.h | 3 + .../WHS_Card/IO_Extender_Ports_TCA9555/WHS_IO.c | 18 ++- .../WHS_Card/IO_Extender_Ports_TCA9555/WHS_IO.h | 3 +- .../WHS_Controller_Comm/WHS_UART/WHS_Uart.c | 169 +++++++++------------ .../WHS_Controller_Comm/WHS_UART/WHS_Uart.h | 13 +- Software/Embedded_SW/Embedded/Main.c | 9 +- .../Embedded/Modules/Control/MillisecTask.c | 33 ++-- .../Embedded/Modules/Control/MillisecTask.h | 1 - .../Embedded/Modules/General/GeneralHardware.c | 6 - .../Embedded/Modules/Waste/newWHS_init.c | 4 - .../StateMachines/Initialization/InitSequence.c | 2 +- .../stubs/Scripts/WHS_Test_EEPROM.cs | 4 +- 14 files changed, 129 insertions(+), 151 deletions(-) (limited to 'Software') diff --git a/Software/Embedded_SW/Embedded/DataDef.h b/Software/Embedded_SW/Embedded/DataDef.h index e87d406c8..fa3feb5cb 100644 --- a/Software/Embedded_SW/Embedded/DataDef.h +++ b/Software/Embedded_SW/Embedded/DataDef.h @@ -43,7 +43,6 @@ extern bool Special_Dispensers; //#define Use_WHS_Card //for real card only #define USE_OLD_HEAD_EEPROM -//#define USE_SHINKO_AUTO_COMM //Temporary //#define USE_RFID //#define USE_VOC_BUZZER_ALARM 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 ce462876b..ea804fc04 100644 --- a/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/I2C_Task.c +++ b/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/I2C_Task.c @@ -84,6 +84,7 @@ typedef enum WHS_SET_CLEAN_AIR, WHS_I2C_EEPROM_WRITE, WHS_I2C_EEPROM_READ, + WHS_I2C_RS485_DIRECTION_INIT, WHS_I2C_RS485_DIRECTION, WHS_stop }I2C_ReadingMessages; @@ -621,6 +622,16 @@ void Trigger_RS485_Direction(bool TX_OR_RX) return; } +void Trigger_RS485_Direction_Init() +{ + I2C_ReadingMessageStruc I2C_ReadingMessage; + + I2C_ReadingMessage.messageId = WHS_I2C_RS485_DIRECTION_INIT; + if (I2C_ReadingMsgQ != NULL) + Mailbox_post(I2C_ReadingMsgQ , &I2C_ReadingMessage, BIOS_NO_WAIT); + return; +} + void I2C_ReadingTask(UArg arg0, UArg arg1); void I2C_ReadingTask_Init(void) { @@ -837,6 +848,9 @@ void I2C_ReadingTask(UArg arg0, UArg arg1) case WHS_I2C_EEPROM_READ: // WHS_I2C_EEprom_Read(I2C_ReadingMessage.parameter, I2C_ReadingMessage.parameter2, I2C_ReadingMessage.parameter3); break; + case WHS_I2C_RS485_DIRECTION_INIT: + WHS_IO_RS485_Init(); + break; case WHS_I2C_RS485_DIRECTION: RS485_Change_Direction(I2C_ReadingMessage.parameter); break; 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 7aab3b448..387a8f692 100644 --- a/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/I2C_Task.h +++ b/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/I2C_Task.h @@ -18,6 +18,9 @@ void Trigger_WHS_MAX11614_Init(void); void Trigger_WHS_Rheostat_init(void); void Trigger_WHS_I2C_EEprom_Write(uint32_t address, uint16_t size, uint8_t *p_data); void Trigger_WHS_I2C_EEprom_Read(uint32_t address, uint16_t size, uint8_t *p_data); +void Trigger_RS485_Direction_Init(); +void Trigger_RS485_Direction(bool TX_OR_RX); + void Trigger_SetWHSFanSpeed (uint8_t fan_id, uint8_t speed); void Trigger_ReadWHSFanTacho (uint8_t fan_id); //todo diff --git a/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/WHS_Card/IO_Extender_Ports_TCA9555/WHS_IO.c b/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/WHS_Card/IO_Extender_Ports_TCA9555/WHS_IO.c index 5ce04aab9..3e36d3bba 100644 --- a/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/WHS_Card/IO_Extender_Ports_TCA9555/WHS_IO.c +++ b/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/WHS_Card/IO_Extender_Ports_TCA9555/WHS_IO.c @@ -13,6 +13,7 @@ #include #include #include +#include WHS_I2C_EXP_U3_0x40_DIRECTION Whs_I2C_EXP_U3_0x40_DIRECTION; @@ -210,6 +211,17 @@ bool WHS_IO_Init() return status; } +bool WHS_IO_RS485_Init() +{ + bool status = OK; + + Whs_I2C_EXP_U4_0x42_DIRECTION.bits.OUTPUT_ACTLOW_DE_REn = D_TCA9555_DIR_OUTPUT; //P00 + + WHS_TCA9555Config(I2CExp2_ADDRESS);//direction + + return status; +} + bool WHS_IO_Init_HW_0() { @@ -717,12 +729,12 @@ uint8_t RS485_Change_Direction(bool TX_OR_RX)//TX or RX - trigger i2c task uint8_t RS485_Direction(bool TX_OR_RX)//TX or RX { - if(TX_OR_RX == TX) +/* if(TX_OR_RX == TX) Write_WHS_9555_io_value(I2CExp2_ADDRESS, D_TCA9555_PORT_0, 0, true); else Write_WHS_9555_io_value(I2CExp2_ADDRESS, D_TCA9555_PORT_0, 0, false); - - //RS485_Change_Direction(TX_OR_RX); +*/ + Trigger_RS485_Direction(TX_OR_RX); return OK; diff --git a/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/WHS_Card/IO_Extender_Ports_TCA9555/WHS_IO.h b/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/WHS_Card/IO_Extender_Ports_TCA9555/WHS_IO.h index e017bb14a..155e5f2aa 100644 --- a/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/WHS_Card/IO_Extender_Ports_TCA9555/WHS_IO.h +++ b/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/WHS_Card/IO_Extender_Ports_TCA9555/WHS_IO.h @@ -1,5 +1,5 @@ /* - * WHD_IO.h + * WHS_IO.h * * Created on: Jun 30, 2019 * Author: Shai @@ -164,6 +164,7 @@ extern WHS_I2C_EXP_U4_0x42_VALUE Whs_I2C_EXP_U4_0x42_VALUE; bool WHS_IO_Init(); +bool WHS_IO_RS485_Init(); bool WHS_TCA9555Config(uint8_t TCA9555_ADDRESS); bool Write_WHS_9555_io_value(uint8_t addr, uint8_t port, uint8_t pin, bool value); bool WHS_Write_IO_AllReg(uint8_t TCA9555_ADDRESS); diff --git a/Software/Embedded_SW/Embedded/Drivers/Uart_Comm/WHS_Controller_Comm/WHS_UART/WHS_Uart.c b/Software/Embedded_SW/Embedded/Drivers/Uart_Comm/WHS_Controller_Comm/WHS_UART/WHS_Uart.c index ebefafbdd..36bef086d 100644 --- a/Software/Embedded_SW/Embedded/Drivers/Uart_Comm/WHS_Controller_Comm/WHS_UART/WHS_Uart.c +++ b/Software/Embedded_SW/Embedded/Drivers/Uart_Comm/WHS_Controller_Comm/WHS_UART/WHS_Uart.c @@ -25,13 +25,14 @@ #include "drivers/Uart_Comm/WHS_Controller_Comm/WHS_UART/WHS_Uart.h" #include "Modules/Control/MillisecTask.h" #include +#include //uint8_t Uart3_Tx_Buff[100]; //uint8_t Uart3_Rx_Buff[100]; -void InitConsole_WHS_UART3(void) +void InitConsole_WHS_UART3(int32_t ui32SysClock) { - uint32_t ui32SysClock = MAP_SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ | SYSCTL_OSC_MAIN | SYSCTL_USE_PLL | SYSCTL_CFG_VCO_480), SYS_CLK_FREQ); + //uint32_t ui32SysClock = MAP_SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ | SYSCTL_OSC_MAIN | SYSCTL_USE_PLL | SYSCTL_CFG_VCO_480), SYS_CLK_FREQ); SysCtlPeripheralEnable(SYSCTL_PERIPH_UART3); // @@ -78,17 +79,17 @@ void InitConsole_WHS_UART3(void) //ROM_UARTConfigSetExpClk(UART3_BASE,ROM_SysCtlClockGet(), 115200, (UART_CONFIG_WLEN_8| UART_CONFIG_STOP_ONE |UART_CONFIG_PAR_NONE)); //MAP_UARTConfigSetExpClk(UART3_BASE, ui32SysClock, 9600,(UART_CONFIG_WLEN_8 |UART_CONFIG_STOP_ONE | UART_CONFIG_PAR_NONE)); MAP_UARTConfigSetExpClk(UART3_BASE, ui32SysClock, 9600,(UART_CONFIG_WLEN_7 |UART_CONFIG_STOP_ONE | UART_CONFIG_PAR_EVEN));//Shinko protocol - - - } +int Uart3TransmitResult = 0; uint8_t Uart3_Transmit(uint8_t * Uart3_Tx_Buff, uint32_t Length) { uint8_t i,Status = OK; + Uart3TransmitResult = 0; + uint8_t temp_buf[Size_Shinko_Req]; for(i = 1;i < Length;i++) //swap the order to switch endianness - need to send the LSB first @@ -100,7 +101,7 @@ uint8_t Uart3_Transmit(uint8_t * Uart3_Tx_Buff, uint32_t Length) for(i=0;i #include "Sys_PinOut_Config/MCU_MAIN_pinout.h" #include +#include "drivers/Uart_Comm/WHS_Controller_Comm/WHS_UART/WHS_Uart.h" +#include /* #include "Drivers/SPI_SDCARD/SDSPI.h" @@ -226,7 +228,6 @@ int main(void) //Set the clock 120MHz uint32_t ui32SysClock = MAP_SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ | SYSCTL_OSC_MAIN | SYSCTL_USE_PLL | SYSCTL_CFG_VCO_480), SYS_CLK_FREQ); - // Enable the system tick. ROM_SysTickPeriodSet(ui32SysClock / TICKS_PER_SECOND); ROM_SysTickIntEnable(); @@ -320,6 +321,12 @@ int main(void) Set_Speed_Sensor_TypeII_Registers(10,5);//set default values #endif + if (WHS_Type == WHS_TYPE_NEW) + { + InitConsole_WHS_UART3(ui32SysClock);//Init WHS UART Shinko RS485 Communication + Trigger_RS485_Direction_Init();//init i/o + } + //EMAC_initEMAC(); ControlInit(); diff --git a/Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.c b/Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.c index d668657b5..ddbda4bca 100644 --- a/Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.c +++ b/Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.c @@ -598,7 +598,6 @@ void setRapidPressureRead(bool value) if (GetDiagnosticMode() == Diagnostic_Extreme_Mode) RapidPressureRead = true; } -bool Shinko_Read = false; uint16_t PumpCounter = 0; uint16_t realtimetest[101]; uint32_t MillisecLowLoop(uint32_t tick) @@ -640,6 +639,7 @@ uint32_t MillisecLowLoop(uint32_t tick) //Screw_ENC_Velocity_to_DAC(); - for testing the screw enc if (Head_Type > HEAD_TYPE_FLAT_WITHOUT_CARD) StartPT100 = TEMP_SENSE_ANALOG_DRYER_TEMP1; + if (Ten_msTick) { //Speed_Data = Read_Speed_Sensor_TypeII(); @@ -738,26 +738,6 @@ uint32_t MillisecLowLoop(uint32_t tick) if (isMotorConfigured(Motor_i)) MotorGetStatusFromFPGA(Motor_i); } -#ifdef USE_SHINKO_AUTO_COMM - if ((WHS_Type == WHS_TYPE_NEW)&&(Shinko_Read == true)) - { - if(ShinkoTempDeg.Read_Setup == 0x00)//didn't read it yet - { - WHS_Shinko_Communication(R_SETUP); - } - else - /*if(0)//TBD - need stop condition to write only once (all the steps) , Read_Setup != setup, Read_Setup != 0, Read_Setup != Prev_Read_Setup - { - // option to wrte + read setup and stop when read = write - WHS_Shinko_Communication(W_SETUP); - } - else*/ - { - //finish reading the setup before start reading the value - WHS_Shinko_Communication(R_Value); // Reading every fourth cycle (Set HW, Request, Set HW, Response) - } - } -#endif } if ((O500Millisecond_Tick)&&(RapidPressureRead == false)) { @@ -820,6 +800,11 @@ uint32_t MillisecLowLoop(uint32_t tick) Whs_emptying_cycle++; } */ + + if(Shinko_first_read < 2)//read the two steps once and than in cycle every 10 minutes, also will be used to read after updating the temperature + { + Shinko_Cycle_Comm(); + } } if (Head_Type == HEAD_TYPE_ARC) { HeadBlowersControlLoop(); @@ -845,7 +830,6 @@ uint32_t MillisecLowLoop(uint32_t tick) } #endif - Shinko_Read = true;//start cycle of R/W setup or value every 10Sec } if (OneMinute_Tick) { @@ -876,7 +860,10 @@ uint32_t MillisecLowLoop(uint32_t tick) { waste_seq_step1();// include 1Sec delay <- to open !!!! }*/ - + if (WHS_Type == WHS_TYPE_NEW) + { + Shinko_Cycle_Comm(); + } } if (OneHourTick) { diff --git a/Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.h b/Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.h index f7351d0b1..0d7c42ad6 100644 --- a/Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.h +++ b/Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.h @@ -50,7 +50,6 @@ void MillisecLogClose(void); #endif -extern bool Shinko_Read; extern bool watchdogCriticalAlarm; extern Task_Handle Millisecond_Task_Handle; diff --git a/Software/Embedded_SW/Embedded/Modules/General/GeneralHardware.c b/Software/Embedded_SW/Embedded/Modules/General/GeneralHardware.c index 1defda43c..2f9088cf1 100644 --- a/Software/Embedded_SW/Embedded/Modules/General/GeneralHardware.c +++ b/Software/Embedded_SW/Embedded/Modules/General/GeneralHardware.c @@ -186,12 +186,6 @@ uint32_t HWConfigurationInit(void) //WHS_init(); // remove call to old WHS #endif - if (WHS_Type == WHS_TYPE_NEW) - { -/* WHS_IO_Init(); - Task_sleep(1);//wait for WHS_IO_Init*/ - InitConsole_WHS_UART3();//WHS Shinko communication - } // Waste Init (WHS) Waste_Init(); diff --git a/Software/Embedded_SW/Embedded/Modules/Waste/newWHS_init.c b/Software/Embedded_SW/Embedded/Modules/Waste/newWHS_init.c index 614fd05eb..070f3c7e7 100644 --- a/Software/Embedded_SW/Embedded/Modules/Waste/newWHS_init.c +++ b/Software/Embedded_SW/Embedded/Modules/Waste/newWHS_init.c @@ -86,10 +86,6 @@ bool newWHS_init(void) //Set_All_WHS_Fans(0xFF); // delayms(4000); //Trigger_SetWHSBlowerVoltage (0x0C00); - //Task_sleep(1); - //InitConsole_WHS_UART3();//WHS Shinko communication - - return status; } diff --git a/Software/Embedded_SW/Embedded/StateMachines/Initialization/InitSequence.c b/Software/Embedded_SW/Embedded/StateMachines/Initialization/InitSequence.c index 399831531..71a06cd93 100644 --- a/Software/Embedded_SW/Embedded/StateMachines/Initialization/InitSequence.c +++ b/Software/Embedded_SW/Embedded/StateMachines/Initialization/InitSequence.c @@ -620,7 +620,7 @@ uint32_t InitSequenceStartHeating(void) TimerMotors_t MotorId = HARDWARE_MOTOR_TYPE__MOTO_DH_LID; SetMachineReadyForHeating(true); - Shinko_Read = true; + if(Head_Type == HEAD_TYPE_ARC) { MotorMovetoLimitSwitch(MotorId,1-MotorsCfg[MotorId].directionthreadwize, 30, Motor_Id_to_LS_IdDown[MotorId], cleaningMotorCBFunction,30000); } else if(Head_Type == HEAD_TYPE_FLAT){ diff --git a/Software/Stubs Collection/stubs/Scripts/WHS_Test_EEPROM.cs b/Software/Stubs Collection/stubs/Scripts/WHS_Test_EEPROM.cs index 88de4de01..5c3708af7 100644 --- a/Software/Stubs Collection/stubs/Scripts/WHS_Test_EEPROM.cs +++ b/Software/Stubs Collection/stubs/Scripts/WHS_Test_EEPROM.cs @@ -12,9 +12,9 @@ using Tango.Stubs; //---------------------- const Int32 I2C_ID = 3; //MCU_I2C3 -const Int32 TCA9548A_address = 0xE2; +const Int32 TCA9548A_address = 0xE0; const Int32 I2C_Slave_Add = 0xA0; // //eeprom address - 32kByte -int Head_Mux_Channel_ID = 0; //WHS MUX channel +int Head_Mux_Channel_ID = 1; //WHS MUX channel //---------------------- -- cgit v1.3.1