diff options
| author | Avi Levkovich <avi@twine-s.com> | 2018-04-22 14:47:15 +0300 |
|---|---|---|
| committer | Avi Levkovich <avi@twine-s.com> | 2018-04-22 14:47:15 +0300 |
| commit | 91e2d94ec400f700cb16c616df29359aaa414cb7 (patch) | |
| tree | 55b36c9aebf3b2a77e7825796eb5d3b6ceeb4f24 /Software/Embedded_SW | |
| parent | 4340c1e6db16b5d5963dd1617810098ec1955462 (diff) | |
| parent | 531c3aba8b49d38f53890c61aa3addef3b5c28dd (diff) | |
| download | Tango-91e2d94ec400f700cb16c616df29359aaa414cb7.tar.gz Tango-91e2d94ec400f700cb16c616df29359aaa414cb7.zip | |
Merge branch 'master' of https://twinetfs.visualstudio.com/_git/Tango
Diffstat (limited to 'Software/Embedded_SW')
32 files changed, 151 insertions, 78 deletions
diff --git a/Software/Embedded_SW/Embedded/Common/report/reportInit.c b/Software/Embedded_SW/Embedded/Common/report/reportInit.c index e534b9b2c..1799ba648 100644 --- a/Software/Embedded_SW/Embedded/Common/report/reportInit.c +++ b/Software/Embedded_SW/Embedded/Common/report/reportInit.c @@ -24,6 +24,7 @@ /*------------- Includes --------------------------------*/ +#include <Container.h> #include <DataDef.h> #include <stdio.h> /* puts(), etc. */ #include "report.h" @@ -35,7 +36,6 @@ #include "PMR/debugging/DebugLogRequest.pb-c.h" #include "PMR/debugging/DebugLogResponse.pb-c.h" //#include "graphics_adapter.h" -#include "Modules/Stubs_Handler/Container.h" char protobufToken[36] = {0}; /*void SendStatusResponse (uint32_t Code, char *Token) diff --git a/Software/Embedded_SW/Embedded/Communication/CommunicationTask.c b/Software/Embedded_SW/Embedded/Communication/CommunicationTask.c index 485097cbf..839b2ce80 100644 --- a/Software/Embedded_SW/Embedded/Communication/CommunicationTask.c +++ b/Software/Embedded_SW/Embedded/Communication/CommunicationTask.c @@ -7,7 +7,7 @@ #include "include.h" #include "drivers/Uart_Comm/uart.h" - +#include "communicationTask.h" static void (*callback)(char* buffer, size_t length); Mailbox_Handle CommunicationRxMsgQ = NULL; @@ -23,6 +23,7 @@ typedef struct CommTxMessage{ char *Buff; }CommTxMessageStruc; +int CommType = 0xFF; struct serialBuffer { char *buffer; @@ -133,6 +134,15 @@ uint32_t CommunicationTaskSendMessage(char* buffer,size_t length) return OK; } +int32_t SetCommunicationPath(bool UARTorUSB) +{ + if ((CommType != 0xFF)&&(CommType != UARTorUSB)) + { + LOG_ERROR (UARTorUSB, "Sending a second Connection request"); + return -1; + } + CommType = UARTorUSB; +} /****************************************************************************** * ======== communicationTask ======== @@ -153,6 +163,7 @@ void communicationTxTask(UArg arg0, UArg arg1) */ initArray(1); + SetCommunicationPath(isUSB); ui32RxCount = 0; CommunicationTxMsgQ = Mailbox_create(sizeof(CommTxMessageStruc), 10, NULL,NULL); @@ -165,8 +176,10 @@ void communicationTxTask(UArg arg0, UArg arg1) switch (Message.messageId) { case 1: - //USBCDCD_sendData(Message.Buff, Message.msgSize,10); - Uart_Tx(Message.Buff, Message.msgSize); + if (CommType == isUSB) + USBCDCD_sendData(Message.Buff, Message.msgSize,10); + else if (CommType == isUART) + Uart_Tx(Message.Buff, Message.msgSize); free (Message.Buff); break; default: diff --git a/Software/Embedded_SW/Embedded/Communication/CommunicationTask.h b/Software/Embedded_SW/Embedded/Communication/CommunicationTask.h index dd18c1039..5746eb825 100644 --- a/Software/Embedded_SW/Embedded/Communication/CommunicationTask.h +++ b/Software/Embedded_SW/Embedded/Communication/CommunicationTask.h @@ -23,5 +23,8 @@ extern uint32_t CommunicationTaskMessageReceived(uint16_t msgSize); extern uint32_t CommunicationTaskSendMessage(char* buffer,size_t length); +#define isUART true +#define isUSB false +extern int32_t SetCommunicationPath(bool UARTorUSB); #endif /* COMMUNICATION_COMMUNICATIONTASK_H_ */ diff --git a/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Container.c b/Software/Embedded_SW/Embedded/Communication/Container.c index 1b1db8189..a906db096 100644 --- a/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Container.c +++ b/Software/Embedded_SW/Embedded/Communication/Container.c @@ -4,25 +4,25 @@ //#include "usb_serial_adapter.h" //#include "graphics_adapter.h" -#include "Calculate.h" -#include "Progress.h" -#include "Stub_Cartridge.h" -#include "Stub_Dispenser.h" -#include "Stub_GPIO.h" -#include "Stub_Heater.h" -#include "Stub_MotorEncoder.h" -#include "Stub_OptLimitSwitch.h" -#include "Stub_SteperMotor.h" -#include "Stub_Valve.h" -#include "Stub_ExtFlash.h" -#include "Stub_FPGAReadBackReg.h" -#include "Stub_FPGAReadVersion.h" -#include "Stub_L6470.h" -#include "Stub_Motor.h" -#include "Stub_HW_Version.h" +#include "Modules/Stubs_Handler/Calculate.h" +#include "Modules/Stubs_Handler/Progress.h" +#include "Modules/Stubs_Handler/Stub_Cartridge.h" +#include "Modules/Stubs_Handler/Stub_Dispenser.h" +#include "Modules/Stubs_Handler/Stub_GPIO.h" +#include "Modules/Stubs_Handler/Stub_Heater.h" +#include "Modules/Stubs_Handler/Stub_MotorEncoder.h" +#include "Modules/Stubs_Handler/Stub_OptLimitSwitch.h" +#include "Modules/Stubs_Handler/Stub_SteperMotor.h" +#include "Modules/Stubs_Handler/Stub_Valve.h" +#include "Modules/Stubs_Handler/Stub_ExtFlash.h" +#include "Modules/Stubs_Handler/Stub_FPGAReadBackReg.h" +#include "Modules/Stubs_Handler/Stub_FPGAReadVersion.h" +#include "Modules/Stubs_Handler/Stub_L6470.h" +#include "Modules/Stubs_Handler/Stub_Motor.h" +#include "Modules/Stubs_Handler/Stub_HW_Version.h" -#include "General/GeneralHardware.h" -#include "heaters/heaters_ex.h" +#include "Modules/General/GeneralHardware.h" +#include "Modules/heaters/heaters_ex.h" #include "Drivers/USB_Communication/USBCDCD.h" #include "StateMachines/Printing/PrintingSTM.h" diff --git a/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Container.h b/Software/Embedded_SW/Embedded/Communication/Container.h index 2c5d9fa60..1f7ea4a17 100644 --- a/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Container.h +++ b/Software/Embedded_SW/Embedded/Communication/Container.h @@ -1,5 +1,8 @@ #ifndef CONTAINER_H #define CONTAINER_H +#include "include.h" +#include <PMR/Common/MessageContainer.pb-c.h> +#include <PMR/Common/MessageType.pb-c.h> MessageContainer createContainer(MessageType type, char* token, protobuf_c_boolean completed, void* response, size_t (*packPtr)(void*, uint8_t*), size_t (*sizePtr)(void*)); void receive_callback(char* buffer, size_t length); diff --git a/Software/Embedded_SW/Embedded/Drivers/Motors/Motor.c b/Software/Embedded_SW/Embedded/Drivers/Motors/Motor.c index 99cb83885..d5777a88a 100644 --- a/Software/Embedded_SW/Embedded/Drivers/Motors/Motor.c +++ b/Software/Embedded_SW/Embedded/Drivers/Motors/Motor.c @@ -301,7 +301,7 @@ uint32_t MotorMoveWithCallback (TimerMotors_t _motorId,bool direction, uint32_t //start control: //uint32_t AddControlCallback( ControlCBFunction Callback, CTRL_TIMING_ENUM CtrlFrequency, DataReadCBFunction DriverfPtr, uint32_t Parameter1, uint32_t Parameter2 ) - uint32_t ControlId = AddControlCallback( MotorMoveCallBackFunction, eTenMilliSecond, MotorControlGetnBusyState, _motorId, 0 ); + uint32_t ControlId = AddControlCallback( MotorMoveCallBackFunction, eTenMilliSecond, MotorControlGetnBusyState,(IfTypeMotors*0x100+_motorId), _motorId, 0 ); return ControlId; } @@ -313,17 +313,25 @@ uint32_t MotorSetSpeedWithCallback (TimerMotors_t _motorId, uint32_t _freq, int return OK; } -uint32_t MotorMoveCallBackFunction(uint32_t deviceId, uint32_t BusyFlag) //TODO +uint32_t MotorMoveCallBackFunction(uint32_t IfIndex, uint32_t BusyFlag) //TODO { + uint32_t MotorId; + if (IfIndex>>8 != IfTypeMotors) + { + LOG_ERROR (IfIndex, "Wrong Interface type"); + return 0xFFFFFFFF; + } + MotorId = IfIndex&0xFF; + if (BusyFlag == 1) { //stop this control loop - RemoveControlCallback(deviceId, MotorMoveCallBackFunction ); + RemoveControlCallback(MotorId, MotorMoveCallBackFunction ); //possibly: start regular control (speed etc) - //uint32_t ControlId = AddControlCallback(ControlCBFunction Callback, eOneMillisecond, NULL, deviceId, Parameter ); + //uint32_t ControlId = AddControlCallback(ControlCBFunction Callback, eOneMillisecond, (IfTypeMotors*0x100+_motorId), deviceId, Parameter ); //call the module callback - MotorMoveModuleCallback(deviceId,BusyFlag); + MotorMoveModuleCallback(MotorId,BusyFlag); } return OK; diff --git a/Software/Embedded_SW/Embedded/Main.c b/Software/Embedded_SW/Embedded/Main.c index d07edd78e..4473fd99e 100644 --- a/Software/Embedded_SW/Embedded/Main.c +++ b/Software/Embedded_SW/Embedded/Main.c @@ -1,3 +1,4 @@ +#include <Container.h> #include "include.h" /*#include <stdbool.h> #include <stdio.h> @@ -21,7 +22,7 @@ #include "Drivers/Peripheral_GPIO/GPIO.h" #include "drivers/Heater/Heater.h" -#include "Modules/Stubs_Handler/Container.h" +#include "Communication/CommunicationTask.h" #include "drivers/twine_graphicslib/graphics_adapter.h" #include <drivers/Flash_Memory/Flash_Memory.h> diff --git a/Software/Embedded_SW/Embedded/Modules/Control/DriverWithCallbackExample.c b/Software/Embedded_SW/Embedded/Modules/Control/DriverWithCallbackExample.c index 1de8ac0de..881034e40 100644 --- a/Software/Embedded_SW/Embedded/Modules/Control/DriverWithCallbackExample.c +++ b/Software/Embedded_SW/Embedded/Modules/Control/DriverWithCallbackExample.c @@ -26,7 +26,7 @@ uint32_t DriverActionWithCallback (uint32_t deviceId, uint32_t parameter, callba ModuleCallback = callback; //start control: - uint32_t ControlId = AddControlCallback( callback, eOneMillisecond, NULL, deviceId, parameter ); + uint32_t ControlId = AddControlCallback( callback, eOneMillisecond, NULL, (IfTypeNone*0x100+deviceId),deviceId, parameter ); return ControlId; } diff --git a/Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.h b/Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.h index fde3a36b3..286ed7ca0 100644 --- a/Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.h +++ b/Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.h @@ -22,4 +22,8 @@ uint32_t getMotorSpeedData(int MotorId); uint32_t getTemperatureSensorData(int SensorId); uint32_t getADCData(int DeviceId); +void MillisecInit(void); +void MillisecStop(void); +void MillisecStart(void); + #endif /* MODULES_CONTROL_MILLISECTASK_H_ */ diff --git a/Software/Embedded_SW/Embedded/Modules/Control/control.c b/Software/Embedded_SW/Embedded/Modules/Control/control.c index 28b4afb8d..0a4a8b791 100644 --- a/Software/Embedded_SW/Embedded/Modules/Control/control.c +++ b/Software/Embedded_SW/Embedded/Modules/Control/control.c @@ -65,6 +65,7 @@ typedef struct bool ControlActive; uint32_t Parameter1; uint32_t Parameter2; + uint32_t IfIndex; DataReadCBFunction ControlDataReadPtr; ControlCBFunction ControlCallbackPtr; CTRL_TIMING_ENUM ControlTiming; @@ -169,7 +170,7 @@ void ControlStart(void) * both these callbacks can be removed. if a new call is arriving, it invalidates the previous one (no dual control or data) * ***************************************************************************************************************************************************/ -uint32_t AddControlCallback( ControlCBFunction Callback, CTRL_TIMING_ENUM CtrlFrequency, DataReadCBFunction DriverfPtr, uint32_t Parameter1, uint32_t Parameter2 ) +uint32_t AddControlCallback( ControlCBFunction Callback, CTRL_TIMING_ENUM CtrlFrequency, DataReadCBFunction DriverfPtr, uint32_t IfIndex, uint32_t Parameter1, uint32_t Parameter2 ) { assert(Callback); assert(DriverfPtr); @@ -194,6 +195,7 @@ uint32_t AddControlCallback( ControlCBFunction Callback, CTRL_TIMING_ENUM CtrlF ControlArray[deviceId].ControlDataReadPtr = DriverfPtr; ControlArray[deviceId].Parameter1 = Parameter1; ControlArray[deviceId].Parameter2 = Parameter2; + ControlArray[deviceId].IfIndex = IfIndex; GateMutex_leave(gateControlDB, key); return deviceId; @@ -223,7 +225,6 @@ int RemoveControlCallback(uint32_t deviceId , ControlCBFunction Callback) void OneMilliSecondControlInterrupt(UArg arg0) { ControlMessageStruc Message; - bool retcode = false; ROM_IntMasterDisable(); if (ControlRestart == true) { @@ -237,7 +238,7 @@ void OneMilliSecondControlInterrupt(UArg arg0) Message.tick = UsersysTickGet(); Message.msglen = sizeof(ControlMessageStruc); if (ControlMsgQ != NULL) - retcode = Mailbox_post(ControlMsgQ , &Message, BIOS_NO_WAIT); + Mailbox_post(ControlMsgQ , &Message, BIOS_NO_WAIT); ROM_TimerIntClear(Control_timerBase, TIMER_TIMA_TIMEOUT); // Clear the timer interrupt // @@ -266,27 +267,27 @@ uint32_t ControlLoop(uint32_t tick) { case eOneMillisecond: ControlDatalog[Device_i] = ControlArray[Device_i].ControlDataReadPtr( ControlArray[Device_i].Parameter1,ControlArray[Device_i].Parameter2); - ControlArray[Device_i].ControlCallbackPtr(Device_i, ControlDatalog[Device_i]); + ControlArray[Device_i].ControlCallbackPtr(ControlArray[Device_i].IfIndex, ControlDatalog[Device_i]); break; case eTenMilliSecond: if (Ten_msTick) { ControlDatalog[Device_i] = ControlArray[Device_i].ControlDataReadPtr( ControlArray[Device_i].Parameter1,ControlArray[Device_i].Parameter2); - ControlArray[Device_i].ControlCallbackPtr(Device_i, ControlDatalog[Device_i]); + ControlArray[Device_i].ControlCallbackPtr(ControlArray[Device_i].IfIndex, ControlDatalog[Device_i]); } break; case eHunderdMillisecond: if (Hundred_msTick) { ControlDatalog[Device_i] = ControlArray[Device_i].ControlDataReadPtr( ControlArray[Device_i].Parameter1,ControlArray[Device_i].Parameter2); - ControlArray[Device_i].ControlCallbackPtr(Device_i, ControlDatalog[Device_i]); + ControlArray[Device_i].ControlCallbackPtr(ControlArray[Device_i].IfIndex, ControlDatalog[Device_i]); } break; case eOneSecond: if (Onesecond_Tick) { ControlDatalog[Device_i] = ControlArray[Device_i].ControlDataReadPtr( ControlArray[Device_i].Parameter1,ControlArray[Device_i].Parameter2); - ControlArray[Device_i].ControlCallbackPtr(Device_i, ControlDatalog[Device_i]); + ControlArray[Device_i].ControlCallbackPtr(ControlArray[Device_i].IfIndex, ControlDatalog[Device_i]); } break; default: diff --git a/Software/Embedded_SW/Embedded/Modules/Control/control.h b/Software/Embedded_SW/Embedded/Modules/Control/control.h index 23bd13231..9322f562e 100644 --- a/Software/Embedded_SW/Embedded/Modules/Control/control.h +++ b/Software/Embedded_SW/Embedded/Modules/Control/control.h @@ -11,7 +11,7 @@ #include "include.h" //typedef uint32_t (* DeviceDataFunction)(uint32_t deviceID, uint32_t *Value); -typedef uint32_t (* ControlCBFunction)(uint32_t deviceID, uint32_t ReadValue); +typedef uint32_t (* ControlCBFunction)(uint32_t IfIndex, uint32_t ReadValue); typedef uint32_t (* DataReadCBFunction)( uint32_t Parameter1, uint32_t Parameter2); typedef enum { eNoControl = 0, @@ -20,12 +20,23 @@ typedef enum { eHunderdMillisecond = 100, eOneSecond = 1000 }CTRL_TIMING_ENUM; +typedef enum +{ + IfTypeNone, + IfTypeThread, + IfTypeWinder, + IfTypeIDS, + IfTypeHeaters, + IfTypeWaste, + IfTypeMotors, + MAX_INTERFACE_TYPES +}SYSTEM_INTERFACE_TYPES_ID_ENUM; void ControlInit(void); void ControlStop(void); void ControlStart(void); -uint32_t AddControlCallback( ControlCBFunction Callback, CTRL_TIMING_ENUM CtrlFrequency, DataReadCBFunction DriverfPtr, uint32_t Parameter1, uint32_t Parameter2 ); +uint32_t AddControlCallback( ControlCBFunction Callback, CTRL_TIMING_ENUM CtrlFrequency, DataReadCBFunction DriverfPtr, uint32_t IfIndex, uint32_t Parameter1, uint32_t Parameter2 ); int RemoveControlCallback(uint32_t deviceId, ControlCBFunction Callback ); uint32_t TemplateDataReadCBFunction (uint32_t deviceId, uint32_t Parameter1, uint32_t Parameter2); diff --git a/Software/Embedded_SW/Embedded/Modules/General/GeneralHardware.c b/Software/Embedded_SW/Embedded/Modules/General/GeneralHardware.c index 1ccfd3df8..ba0390144 100644 --- a/Software/Embedded_SW/Embedded/Modules/General/GeneralHardware.c +++ b/Software/Embedded_SW/Embedded/Modules/General/GeneralHardware.c @@ -3,6 +3,7 @@ * Control module * ************************************************************************************************************************/ +#include <Container.h> #include <DataDef.h> #include "include.h" #include "GeneralHardware.h" @@ -11,7 +12,6 @@ #include "control/control.h" #include "heaters/heaters_ex.h" #include "PMR/common/MessageContainer.pb-c.h" -#include "Modules/Stubs_Handler/Container.h" #include "PMR/Hardware/UploadHardWareConfigurationRequest.pb-c.h" #include "PMR/Hardware/UploadHardWareConfigurationResponse.pb-c.h" #include "PMR/Hardware/SystemResetRequest.pb-c.h" diff --git a/Software/Embedded_SW/Embedded/Modules/General/GeneralHardware.h b/Software/Embedded_SW/Embedded/Modules/General/GeneralHardware.h index 8deaf7586..0453cc2c8 100644 --- a/Software/Embedded_SW/Embedded/Modules/General/GeneralHardware.h +++ b/Software/Embedded_SW/Embedded/Modules/General/GeneralHardware.h @@ -1,10 +1,10 @@ #ifndef GENERALHARDWARE_H #define GENERALHARDWARE_H +#include "../../Communication/Container.h" #include "../../DataDef.h" #include "include.h" #include "PMR/common/MessageContainer.pb-c.h" -#include "Modules/Stubs_Handler/Container.h" typedef enum { diff --git a/Software/Embedded_SW/Embedded/Modules/Heaters/Heaters_print.c b/Software/Embedded_SW/Embedded/Modules/Heaters/Heaters_print.c index 5dee1301d..2ea54dc90 100644 --- a/Software/Embedded_SW/Embedded/Modules/Heaters/Heaters_print.c +++ b/Software/Embedded_SW/Embedded/Modules/Heaters/Heaters_print.c @@ -42,6 +42,7 @@ typedef struct HeatersControlMessage{ /******************** GLOBAL PARAMETERS ********************************************/ HeaterCommand HeaterCmd[MAX_HEATERS_NUM] = {}; +uint32_t ControlIdtoHeaterId [MAX_HEATERS_NUM] = {0xFF}; int NumberOFSlicesInUse = 0; bool HeatersRestart = false; @@ -185,7 +186,7 @@ uint32_t PrepareHeater(int HeaterId, uint32_t SetTemperatue) HeaterPIDConfig[HeaterId].m_mesuredParam = 0; HeaterPIDConfig[HeaterId].m_preError = 0; HeaterPIDConfig[HeaterId].m_SetParam = SetTemperatue;//need to update SetParams on presegment stage - AddControlCallback( HeaterControlCBFunction, eHunderdMillisecond,TemperatureSensorRead,HeaterId,0); + ControlIdtoHeaterId [HeaterId] = AddControlCallback( HeaterControlCBFunction, eHunderdMillisecond,TemperatureSensorRead,(IfTypeHeaters*0x100+HeaterId),HeaterId,0); return OK; } @@ -196,22 +197,37 @@ uint32_t PrepareHeater(int HeaterId, uint32_t SetTemperatue) * initialized all global data */ -uint32_t HeaterControlCBFunction(uint32_t deviceID, uint32_t ReadValue) +uint32_t HeaterControlCBFunction(uint32_t IfIndex, uint32_t ReadValue) { - int index=MAX_HEATERS_NUM; + int i,index=MAX_HEATERS_NUM; static bool InitialHeating = true; char str[100]; uint8_t len = 0; - - index = deviceID; + if (IfIndex>>8 != IfTypeHeaters) + { + LOG_ERROR (IfIndex, "Wrong Interface type"); + return 0xFFFFFFFF; + } + index = IfIndex&0xFF; + /*for (i=0;i<MAX_HEATERS_NUM;i++) + if (ControlIdtoHeaterId[i] == deviceID) + { + index = i; + break; + } + if (index==MAX_HEATERS_NUM) + { + LOG_ERROR (deviceID, "No Heater for device"); + return 0xFFFFFFFF; + }*/ if (HeaterCmd[index].targettemperatue == 0) { LOG_ERROR (0, "unconfigured"); return ERROR; } static uint32_t Temperature[2] = {0}; - if (deviceID<2) - Temperature[deviceID] = ReadValue; + if (index<2) + Temperature[index] = ReadValue; HeatingTestSendResonse(0, false,GetHeaterState(HARDWARE_PID_CONTROL_TYPE__DryerHeater1000w),GetHeaterState(HARDWARE_PID_CONTROL_TYPE__DryerHeater200w1), Temperature[0],Temperature[1], HeaterPIDConfig[HARDWARE_PID_CONTROL_TYPE__DryerHeater1000w].m_calculatedError, HeaterPIDConfig[HARDWARE_PID_CONTROL_TYPE__DryerHeater200w1].m_calculatedError,"Standard"); diff --git a/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Calculate.c b/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Calculate.c index e1e0c84dc..3da0ddee3 100644 --- a/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Calculate.c +++ b/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Calculate.c @@ -1,4 +1,5 @@ +#include <Container.h> #include <PMR/Common/MessageContainer.pb-c.h> #include <PMR/Stubs/CalculateRequest.pb-c.h> #include <PMR/Stubs/CalculateResponse.pb-c.h> @@ -7,7 +8,6 @@ #include "Drivers/USB_Communication/USBCDCD.h" #include "drivers/twine_graphicslib/graphics_adapter.h" -#include "Container.h" void Stub_CalculateRequest(MessageContainer* requestContainer) { diff --git a/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Progress.c b/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Progress.c index df59f416a..e38abdab3 100644 --- a/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Progress.c +++ b/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Progress.c @@ -1,4 +1,5 @@ +#include <Container.h> #include <PMR/Common/MessageContainer.pb-c.h> #include <PMR/Stubs/ProgressRequest.pb-c.h> #include <PMR/Stubs/ProgressResponse.pb-c.h> @@ -8,7 +9,6 @@ #include "Drivers/USB_Communication/USBCDCD.h" //#include "graphics_adapter.h" -#include "Container.h" void Stub_ProgressRequest(MessageContainer* requestContainer) { diff --git a/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_Cartridge.c b/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_Cartridge.c index f0dc2436a..c79434635 100644 --- a/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_Cartridge.c +++ b/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_Cartridge.c @@ -1,5 +1,6 @@ +#include <Container.h> #include <PMR/Common/MessageContainer.pb-c.h> #include <PMR/Stubs/StubCartridgeReadRequest.pb-c.h> #include <PMR/Stubs/StubCartridgeReadResponse.pb-c.h> @@ -13,7 +14,6 @@ #include "drivers/twine_graphicslib/graphics_adapter.h" -#include "Container.h" #include "Stub_Status.h" void Stub_CartridgeReadRequest(MessageContainer* requestContainer) diff --git a/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_Dispenser.c b/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_Dispenser.c index 9c37ec330..fc9393e23 100644 --- a/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_Dispenser.c +++ b/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_Dispenser.c @@ -1,5 +1,6 @@ +#include <Container.h> #include <PMR/Common/MessageContainer.pb-c.h> #include <PMR/Stubs/StubDispenserRequest.pb-c.h> #include <PMR/Stubs/StubDispenserResponse.pb-c.h> @@ -10,7 +11,6 @@ #include "drivers/twine_graphicslib/graphics_adapter.h" -#include "Container.h" #include "Stub_Status.h" void Stub_DispenserRequest(MessageContainer* requestContainer) diff --git a/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_ExtFlash.c b/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_ExtFlash.c index 96a8e9322..cf50b70ab 100644 --- a/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_ExtFlash.c +++ b/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_ExtFlash.c @@ -1,4 +1,5 @@ +#include <Container.h> #include <PMR/Common/MessageContainer.pb-c.h> #include <PMR/Stubs/StubExtFlashReadRequest.pb-c.h> #include <PMR/Stubs/StubExtFlashReadResponse.pb-c.h> @@ -20,7 +21,6 @@ #include "drivers/twine_graphicslib/graphics_adapter.h" -#include "Container.h" #include "Stub_Status.h" diff --git a/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_FPGARWReg.c b/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_FPGARWReg.c index d71fa764a..65cd3e52e 100644 --- a/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_FPGARWReg.c +++ b/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_FPGARWReg.c @@ -1,4 +1,5 @@ +#include <Container.h> #include <DataDef.h> #include <PMR/Stubs/StubFpgaReadRegRequest.pb-c.h> #include <PMR/Stubs/StubFpgaReadRegResponse.pb-c.h> @@ -19,7 +20,6 @@ #include "MessageContainer.pb-c.h" -#include "Container.h" #include "Stub_Status.h" #include "drivers/FPGA/FPGA.h" #include "drivers/FPGA/FPGA_Comm.h" diff --git a/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_FPGAReadBackReg.c b/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_FPGAReadBackReg.c index 90140afbf..1c5769b62 100644 --- a/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_FPGAReadBackReg.c +++ b/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_FPGAReadBackReg.c @@ -1,4 +1,5 @@ +#include <Container.h> #include <DataDef.h> #include <PMR/Stubs/StubFPGAReadBackRegRequest.pb-c.h> #include <PMR/Stubs/StubFPGAReadBackRegResponse.pb-c.h> @@ -16,7 +17,6 @@ #include "MessageContainer.pb-c.h" -#include "Container.h" #include "Stub_Status.h" #include "drivers/FPGA/FPGA.h" diff --git a/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_FPGAReadVersion.c b/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_FPGAReadVersion.c index 3c719bc59..cfbce40f1 100644 --- a/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_FPGAReadVersion.c +++ b/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_FPGAReadVersion.c @@ -1,4 +1,5 @@ +#include <Container.h> #include <DataDef.h> #include <PMR/Stubs/StubFPGAReadVersionResponse.pb-c.h> #include <PMR/Stubs/StubFPGAReadVersionRequest.pb-c.h> @@ -16,7 +17,6 @@ #include "MessageContainer.pb-c.h" -#include "Container.h" #include "Stub_Status.h" #include "drivers/FPGA/FPGA.h" diff --git a/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_GPIO.c b/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_GPIO.c index 362be2ba8..9e052aa78 100644 --- a/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_GPIO.c +++ b/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_GPIO.c @@ -1,3 +1,4 @@ +#include <Container.h> #include <DataDef.h> #include "include.h" @@ -26,7 +27,6 @@ #include "drivers/twine_graphicslib/graphics_adapter.h" -#include "Container.h" #include <Modules/Stubs_Handler/User_Leds.h> #include "Stub_Status.h" diff --git a/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_HW_Version.c b/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_HW_Version.c index 7bc1aa857..bd59ee2a0 100644 --- a/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_HW_Version.c +++ b/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_HW_Version.c @@ -1,4 +1,5 @@ +#include <Container.h> #include <DataDef.h> #include <PMR/Stubs/StubHWVersionResponse.pb-c.h> #include <PMR/Stubs/StubHWVersionRequest.pb-c.h> @@ -16,7 +17,6 @@ #include "MessageContainer.pb-c.h" -#include "Container.h" #include "Stub_Status.h" #include "drivers/FPGA/FPGA.h" #include "driverlib/rom_map.h" diff --git a/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_Heater.c b/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_Heater.c index 80f9cc7c6..d72a749b1 100644 --- a/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_Heater.c +++ b/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_Heater.c @@ -1,5 +1,6 @@ +#include <Container.h> #include <DataDef.h> #include <PMR/Common/MessageContainer.pb-c.h> #include <PMR/Stubs/StubHeaterRequest.pb-c.h> @@ -18,7 +19,6 @@ #include "drivers/twine_graphicslib/graphics_adapter.h" -#include "Container.h" #include "Stub_Status.h" #include "Drivers/Heater/Heater.h" diff --git a/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_L6470.c b/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_L6470.c index 1508d2d58..dcec8cade 100644 --- a/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_L6470.c +++ b/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_L6470.c @@ -1,4 +1,5 @@ +#include <Container.h> #include <DataDef.h> #include <PMR/Stubs/StubL6470DriverResponse.pb-c.h> #include <PMR/Stubs/StubL6470DriverRequest.pb-c.h> @@ -16,7 +17,6 @@ #include "MessageContainer.pb-c.h" -#include "Container.h" #include "Stub_Status.h" //#include "drivers/FPGA/FPGA.h" #include "drivers/SPI/SPI_Comm.h" diff --git a/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_Motor.c b/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_Motor.c index a56ae348b..506eb4a70 100644 --- a/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_Motor.c +++ b/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_Motor.c @@ -1,4 +1,5 @@ +#include <Container.h> #include <DataDef.h> #include <PMR/Stubs/StubMotorInitRequest.pb-c.h> #include <PMR/Stubs/StubMotorInitResponse.pb-c.h> @@ -33,7 +34,6 @@ #include "MessageContainer.pb-c.h" -#include "Container.h" #include "Stub_Status.h" #include "drivers/FPGA/FPGA.h" #include "drivers/SPI/SPI_Comm.h" diff --git a/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_MotorEncoder.c b/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_MotorEncoder.c index ebc48bf4d..bcc5e16fb 100644 --- a/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_MotorEncoder.c +++ b/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_MotorEncoder.c @@ -1,4 +1,5 @@ +#include <Container.h> #include <DataDef.h> #include <PMR/Common/MessageContainer.pb-c.h> #include <PMR/Stubs/StubMotorEncoderRequest.pb-c.h> @@ -17,7 +18,6 @@ #include "drivers/twine_graphicslib/graphics_adapter.h" -#include "Container.h" #include "Stub_Status.h" void Stub_MotorEncoderRequest(MessageContainer* requestContainer) diff --git a/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_OptLimitSwitch.c b/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_OptLimitSwitch.c index 84878c660..a1fdeb390 100644 --- a/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_OptLimitSwitch.c +++ b/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_OptLimitSwitch.c @@ -1,5 +1,6 @@ +#include <Container.h> #include <DataDef.h> #include <PMR/Common/MessageContainer.pb-c.h> #include <PMR/Stubs/StubOptLimitSwitchRequest.pb-c.h> @@ -18,7 +19,6 @@ #include "drivers/twine_graphicslib/graphics_adapter.h" -#include "Container.h" #include "Stub_Status.h" void Stub_OptLimitSwitchRequest(MessageContainer* requestContainer) diff --git a/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_SteperMotor.c b/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_SteperMotor.c index 8fd6e0484..78fd2ef3b 100644 --- a/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_SteperMotor.c +++ b/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_SteperMotor.c @@ -1,5 +1,6 @@ +#include <Container.h> #include <DataDef.h> #include <PMR/Common/MessageContainer.pb-c.h> #include <PMR/Stubs/StubSteperMotorRequest.pb-c.h> @@ -18,7 +19,6 @@ #include "drivers/twine_graphicslib/graphics_adapter.h" -#include "Container.h" #include "Stub_Status.h" void Stub_SteperMotorRequest(MessageContainer* requestContainer) diff --git a/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_Valve.c b/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_Valve.c index b1cba49e5..86460f119 100644 --- a/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_Valve.c +++ b/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_Valve.c @@ -1,4 +1,5 @@ +#include <Container.h> #include <DataDef.h> #include <PMR/Common/MessageContainer.pb-c.h> #include <PMR/Stubs/StubValveRequest.pb-c.h> @@ -17,8 +18,6 @@ #include "drivers/twine_graphicslib/graphics_adapter.h" -#include "Container.h" - #include "Stub_Status.h" void Stub_ValveRequest(MessageContainer* requestContainer) diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c index fb9740dec..92037d0b5 100644 --- a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c +++ b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c @@ -49,11 +49,17 @@ uint32_t ThreadPreSegmentState(void *JobDetails); //////////////////////////////////////////////////////////////////////////// -uint32_t ThreadSpeedControlCBFunction(uint32_t deviceID, uint32_t ReadValue) +uint32_t ThreadSpeedControlCBFunction(uint32_t IfIndex, uint32_t ReadValue) { //read value is the dancer angle - int i,index=MAX_THREAD_MOTORS_NUM; - for (i=0;i<MAX_THREAD_MOTORS_NUM;i++) + int index=MAX_THREAD_MOTORS_NUM; + if (IfIndex>>8 != IfTypeThread) + { + LOG_ERROR (IfIndex, "Wrong Interface type"); + return 0xFFFFFFFF; + } + index = IfIndex&0xFF; +/* for (i=0;i<MAX_THREAD_MOTORS_NUM;i++) if (ControlIdtoMotorId[i] == deviceID) { index = i; @@ -64,6 +70,7 @@ uint32_t ThreadSpeedControlCBFunction(uint32_t deviceID, uint32_t ReadValue) LOG_ERROR (deviceID, "No motor for device"); return 0xFFFFFFFF; } + */ if(MotorControlConfig[index].m_isEnabled && (MotorControlConfig[index].m_SetParam != 0)) { MotorControlConfig[index].m_mesuredParam = ReadValue; @@ -80,10 +87,9 @@ uint32_t ThreadSpeedControlCBFunction(uint32_t deviceID, uint32_t ReadValue) //SetMotorFreq (index, MotorControlConfig[index].m_calculatedError); } - return OK; } -uint32_t ThreadControlCBFunction(uint32_t MotorId, uint32_t ReadValue) +uint32_t ThreadControlCBFunction(uint32_t IfIndex, uint32_t ReadValue) { //#define MAX_CONTROL_SAMPLES 6 //extern uint32_t MotorSamples[MAX_THREAD_MOTORS_NUM][MAX_CONTROL_SAMPLES]; @@ -94,7 +100,14 @@ uint32_t ThreadControlCBFunction(uint32_t MotorId, uint32_t ReadValue) int Pid_Id,DancerId; int32_t TranslatedReadValue, avreageSampleValue = 0; double NormalizedError; - for (i=0;i<MAX_THREAD_MOTORS_NUM;i++) + if (IfIndex>>8 != IfTypeThread) + { + LOG_ERROR (IfIndex, "Wrong Interface type"); + return 0xFFFFFFFF; + } + index = IfIndex&0xFF; + + /*for (i=0;i<MAX_THREAD_MOTORS_NUM;i++) if (ControlIdtoMotorId[i] == MotorId) { index = i; @@ -104,7 +117,7 @@ uint32_t ThreadControlCBFunction(uint32_t MotorId, uint32_t ReadValue) { LOG_ERROR (MotorId, "No motor for device"); return 0xFFFFFFFF; - } + }*/ if(MotorControlConfig[index].m_isEnabled ) { @@ -181,22 +194,23 @@ uint32_t ThreadInitialTestStub(HardwareMotor * request) MotorControlConfig[Motor_i].m_preError = 0; MotorControlConfig[Motor_i].m_SetParam = 0;//need to update SetParams on presegment stage - MotorSetDirection(HW_Motor_Id,MotorsCfg[HW_Motor_Id].directionthreadwize); + MotorSetDirection((TimerMotors_t)HW_Motor_Id,MotorsCfg[HW_Motor_Id].directionthreadwize); #ifdef DEBUG_TEST_FUNCTIONS + 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 - ControlIdtoMotorId[Motor_i] = AddControlCallback(ThreadControlCBFunction, eOneMillisecond,Control_Read_Dancer_Position,ThreadMotorIdToDancerId[Motor_i],Motor_i); + ControlIdtoMotorId[Motor_i] = AddControlCallback(ThreadControlCBFunction, eOneMillisecond,Control_Read_Dancer_Position,(IfTypeThread*0x100+Motor_i),ThreadMotorIdToDancerId[Motor_i],Motor_i); /*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,MotorGetSpeed,ThreadMotorIdToMotorId[Motor_i],0); + //AddControlCallback(ThreadSpeedControlCBFunction, eOneMillisecond,MotorGetSpeed,(IfTypeThread*0x100+Motor_i),ThreadMotorIdToMotorId[Motor_i],0); // continue; AddControlCallback(ThreadControlCBFunction, eOneMillisecond,Control_Read_Dancer_Position,ThreadMotorIdToDancerId[Motor_i],Motor_i); else if ((HW_Motor_Id == HARDWARE_MOTOR_TYPE__MOTO_WINDER)||(HW_Motor_Id == HARDWARE_MOTOR_TYPE__MOTO_LDRIVING)||(HW_Motor_Id == HARDWARE_MOTOR_TYPE__MOTO_RDRIVING)) - AddControlCallback(ThreadControlCBFunction, eOneMillisecond,Control_Read_Dancer_Position,ThreadMotorIdToDancerId[Motor_i],Motor_i);*/ + AddControlCallback(ThreadControlCBFunction, eOneMillisecond,Control_Read_Dancer_Position,(IfTypeThread*0x100+Motor_i),ThreadMotorIdToDancerId[Motor_i],Motor_i);*/ #else if (Motor_i == 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 continue; - //AddControlCallback(ThreadSpeedControlCBFunction, eOneMillisecond,MotorGetSpeed,ThreadMotorIdToMotorId[Motor_i],Motor_i); + //AddControlCallback(ThreadSpeedControlCBFunction, eOneMillisecond,MotorGetSpeed,(IfTypeThread*0x100+Motor_i),ThreadMotorIdToMotorId[Motor_i],Motor_i); else if ((Motor_i == HARDWARE_MOTOR_TYPE__MOTO_WINDER)||(Motor_i == HARDWARE_MOTOR_TYPE__MOTO_LDRIVING)||(Motor_i == HARDWARE_MOTOR_TYPE__MOTO_RDRIVING)) - AddControlCallback(ThreadControlCBFunction, eOneMillisecond,Control_Read_Dancer_Position,ThreadMotorIdToDancerId[Motor_i],Motor_i); + AddControlCallback(ThreadControlCBFunction, eOneMillisecond,Control_Read_Dancer_Position,(IfTypeThread*0x100+Motor_i),ThreadMotorIdToDancerId[Motor_i],Motor_i); #endif } Winder_Prepare(); |
