diff options
| author | Shlomo Hecht <shlomo@twine-s.com> | 2018-03-19 12:08:17 +0200 |
|---|---|---|
| committer | Shlomo Hecht <shlomo@twine-s.com> | 2018-03-19 12:08:17 +0200 |
| commit | cc4129c557405accb3ced68f7b6cb19dbdb87a24 (patch) | |
| tree | f86827ef77a6ef6733805f8190bd961934543e5c /Software/Embedded_SW/Embedded/Modules | |
| parent | 9d04bbb2b4a2eb2eb14cc813103c856b7bde975a (diff) | |
| download | Tango-cc4129c557405accb3ced68f7b6cb19dbdb87a24.tar.gz Tango-cc4129c557405accb3ced68f7b6cb19dbdb87a24.zip | |
Driver structures and prototypes
Diffstat (limited to 'Software/Embedded_SW/Embedded/Modules')
12 files changed, 344 insertions, 50 deletions
diff --git a/Software/Embedded_SW/Embedded/Modules/Control/DriverWithCallbackExample.c b/Software/Embedded_SW/Embedded/Modules/Control/DriverWithCallbackExample.c index 216779f8b..1de8ac0de 100644 --- a/Software/Embedded_SW/Embedded/Modules/Control/DriverWithCallbackExample.c +++ b/Software/Embedded_SW/Embedded/Modules/Control/DriverWithCallbackExample.c @@ -1,7 +1,53 @@ /* * DriverWithCallbackExample.c * - * Created on: 11 במרץ 2018 + * Created on: 11 march 2018 * Author: shlomo */ -uint32_t +#include "include.h" +#include "control.h" + + +uint32_t KeepParameter = 0; +callback_fptr ModuleCallback = 0; +bool isValid (uint32_t deviceID); +uint32_t ControlCallBackFunction(uint32_t deviceID, uint32_t ReadValue); + + + +uint32_t DriverActionWithCallback (uint32_t deviceId, uint32_t parameter, callback_fptr callback) +{ + assert (callback); + assert (isValid(deviceId)); + + //call driver action to device id with the parameter + //SetMotorSpeed (deviceId, parameter); + KeepParameter = parameter; + ModuleCallback = callback; + //start control: + + uint32_t ControlId = AddControlCallback( callback, eOneMillisecond, NULL, deviceId, parameter ); + return ControlId; + +} + +uint32_t ControlCallBackFunction(uint32_t deviceId, uint32_t ReadValue) +{ + if (ReadValue == KeepParameter) + { + //stop this control loop + RemoveControlCallback(deviceId, ControlCallBackFunction ); + //possibly: start regular control (speed etc) + //uint32_t ControlId = AddControlCallback(ControlCBFunction Callback, eOneMillisecond, NULL, deviceId, Parameter ); + + //call the module callback + ModuleCallback(deviceId,ReadValue); + + } + return OK; +} + +bool isValid (uint32_t deviceID) +{ + return true; +} diff --git a/Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.c b/Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.c index 6f3a59852..ded4c9f9e 100644 --- a/Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.c +++ b/Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.c @@ -22,6 +22,10 @@ #include "drivers/adc_sampling/adc.h" #include "control.h" + +#include "drivers/Motors/Motor.h" +#include "drivers/Heater/TemperatureSensor.h" + /******************** Definitions ********************************************/ #define INVALID_MSG_ID 0xFFFF #define MAX_TANGO_CONTROL_DEVICES 200 @@ -30,7 +34,7 @@ typedef enum { OneMillisec, -}nillisecMessages; +}MillisecMessages; typedef struct MillisecMessage{ uint16_t messageId; @@ -38,6 +42,13 @@ typedef struct MillisecMessage{ uint32_t tick; uint8_t messageData[20]; }MillisecMessageStruc; + +uint32_t ADC_Data[MAX_ADC_DEVICES] = {0}; +uint32_t TemperatureSensor_Data[MAX_TEMPERATURE_SENSOR_ID] = {0}; +uint32_t MotorSpeed_Data[MOTOR_SPARE1_1] = {0}; +uint32_t MotorStatus_Data[MOTOR_SPARE1_1] = {0}; +bool MotorBusy_Data[MOTOR_SPARE1_1] = {true}; + /******************** GLOBAL PARAMETERS ********************************************/ Mailbox_Handle MillisecMsgQ = NULL; bool MillisecRestart; @@ -105,9 +116,6 @@ void OneMilliSecondMillisecInterrupt(UArg arg0) else ROM_TimerDisable(Millisec_timerBase,TIMER_A); - //trigger the ADC collection - check and set priorities to make sure handling timing is correct. - //we might want to call it from the task, afetr execution of other taks!!! - ADC_TriggerCollection(); //send message to the Millisec task Message.messageId = OneMillisec; Message.tick = UsersysTickGet(); @@ -133,7 +141,46 @@ uint32_t MillisecLoop(uint32_t tick) Hundred_msTick = (tick%eHunderdMillisecond == 0) ?true:false; Onesecond_Tick = (tick%eOneSecond == 0) ?true:false; + //gather Motor data from FPGA + MotorSpeed_Data[MOTOR_DRYER_DRIVING] = MotorGetSpeedFromFPGA(MOTOR_DRYER_DRIVING); + MotorStatus_Data[MOTOR_DRYER_DRIVING] = MotorGetStatusFromFPGA(MOTOR_DRYER_DRIVING); + MotorSpeed_Data[MOTOR_SCREW] = MotorGetSpeedFromFPGA(MOTOR_SCREW); + MotorStatus_Data[MOTOR_SCREW] = MotorGetStatusFromFPGA(MOTOR_SCREW); + MotorSpeed_Data[MOTOR_WINDER] = MotorGetSpeedFromFPGA(MOTOR_WINDER); + MotorStatus_Data[MOTOR_WINDER] = MotorGetStatusFromFPGA(MOTOR_WINDER); + MotorSpeed_Data[MOTOR_LDRIVING] = MotorGetSpeedFromFPGA(MOTOR_LDRIVING); + MotorStatus_Data[MOTOR_LDRIVING] = MotorGetStatusFromFPGA(MOTOR_LDRIVING); + MotorSpeed_Data[MOTOR_RDRIVING] = MotorGetSpeedFromFPGA(MOTOR_RDRIVING); + MotorStatus_Data[MOTOR_RDRIVING] = MotorGetStatusFromFPGA(MOTOR_RDRIVING); + //gather Dancer data from FPGA //gather data from FPGA + + if (Hundred_msTick) + { + int adc_i; + for (adc_i = 0; adc_i < MAX_ADC_DEVICES ; adc_i++) + ADC_Data[adc_i] = ADC_GetReading(adc_i); + //trigger the ADC collection - check and set priorities to make sure handling timing is correct. + //we might want to call it from the task, after execution of other tasks!!! + ADC_TriggerCollection(); + + TEMPERATURE_SENSOR_ID_ENUM pt100_i; + for (pt100_i = 0; pt100_i < (int)MAX_TEMPERATURE_SENSOR_ID ; pt100_i++) + TemperatureSensor_Data[pt100_i] = TemperatureSensorReadFromFPGA(pt100_i); + MotorGetnBusyFromFPGA(); // get all motors nBusy bit status from the FPGAs + TimerMotors_t motor_i; + for (motor_i = 0; motor_i < MOTOR_SPARE1_1 ; motor_i++) + { + MotorBusy_Data[motor_i] = MotorGetnBusyState(motor_i); + if (MotorBusy_Data[motor_i] == false) //can get data + { + MotorSpeed_Data[motor_i] = MotorGetSpeedFromFPGA(motor_i); + MotorStatus_Data[motor_i] = MotorGetStatusFromFPGA(motor_i); + } + } + } + //gather data from FPGA + return OK; } /****************************************************************************** @@ -163,3 +210,28 @@ void MillisecTask(UArg arg0, UArg arg1) } } } + + +uint32_t getMotorStatusData(int MotorId) +{ + assert (MotorId < MOTOR_SPARE1_1); + return MotorStatus_Data[MotorId]; +} +uint32_t getMotorSpeedData(int MotorId) +{ + assert (MotorId < MOTOR_SPARE1_1); + return MotorSpeed_Data[MotorId]; +} + +uint32_t getTemperatureSensorData(int SensorId) +{ + assert (SensorId < MAX_TEMPERATURE_SENSOR_ID); + return TemperatureSensor_Data[SensorId]; +} + +uint32_t getADCData(int DeviceId) +{ + assert (DeviceId < MAX_ADC_DEVICES); + return ADC_Data[DeviceId]; +} + diff --git a/Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.h b/Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.h new file mode 100644 index 000000000..0c9d66201 --- /dev/null +++ b/Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.h @@ -0,0 +1,25 @@ +/* + * MillisecTask.h + * + * Created on: 15 במרץ 2018 + * Author: shlomo + */ + +#ifndef MODULES_CONTROL_MILLISECTASK_H_ +#define MODULES_CONTROL_MILLISECTASK_H_ + +#include "drivers/adc_sampling/adc.h" +#include "control.h" +#include "drivers/Motors/Motor.h" +#include "drivers/Heater/TemperatureSensor.h" + + +uint32_t getMotorStatusData(int MotorId); +uint32_t getMotorSpeedData(int MotorId); +uint32_t getTemperatureSensorData(int SensorId); +uint32_t getADCData(int DeviceId); + + + + +#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 abc61972d..1d9686124 100644 --- a/Software/Embedded_SW/Embedded/Modules/Control/control.c +++ b/Software/Embedded_SW/Embedded/Modules/Control/control.c @@ -62,7 +62,8 @@ typedef struct { uint32_t PartId; // the identity of the inspected/controlled part in the Devices enum. bool ControlActive; - uint32_t Parameter; + uint32_t Parameter1; + uint32_t Parameter2; DataReadCBFunction ControlDataReadPtr; ControlCBFunction ControlCallbackPtr; CTRL_TIMING_ENUM ControlTiming; @@ -97,7 +98,7 @@ void OneMilliSecondFunction(UArg arg0); //********************************************************************** /******************** CODE ********************************************/ //********************************************************************** -uint32_t TemplateDataReadCBFunction (uint32_t deviceID, uint32_t Parameter) +uint32_t TemplateDataReadCBFunction (uint32_t deviceID, uint32_t Parameter1, uint32_t Parameter2) { return 0; } @@ -160,23 +161,34 @@ 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) * ***************************************************************************************************************************************************/ -int AddControlCallback(uint32_t deviceId, ControlCBFunction Callback, CTRL_TIMING_ENUM CtrlFrequency, DataReadCBFunction DriverfPtr, uint32_t Parameter ) +uint32_t AddControlCallback( ControlCBFunction Callback, CTRL_TIMING_ENUM CtrlFrequency, DataReadCBFunction DriverfPtr, uint32_t Parameter1, uint32_t Parameter2 ) { - assert(deviceId < MAX_TANGO_CONTROL_DEVICES); assert(Callback); assert(DriverfPtr); unsigned int key; - + uint32_t device_i; + uint32_t deviceId = 0xFFFFFFFF; + for(device_i = 0;device_i < MAX_TANGO_CONTROL_DEVICES;device_i++) + { + if (ControlArray[device_i].ControlActive == false) + { + deviceId = device_i; + break; + } + } + if (deviceId == 0xFFFFFFFF) + return 0xFFFFFFFF; key = GateMutex_enter(gateControlDB); ControlArray[deviceId].ControlTiming = CtrlFrequency; ControlArray[deviceId].ControlCallbackPtr = Callback; ControlArray[deviceId].ControlActive = true; ControlArray[deviceId].ControlDataReadPtr = DriverfPtr; - ControlArray[deviceId].Parameter = Parameter; + ControlArray[deviceId].Parameter1 = Parameter1; + ControlArray[deviceId].Parameter2 = Parameter2; GateMutex_leave(gateControlDB, key); - return OK; + return deviceId; } int RemoveControlCallback(uint32_t deviceId , ControlCBFunction Callback) @@ -212,9 +224,6 @@ void OneMilliSecondControlInterrupt(UArg arg0) else ROM_TimerDisable(Control_timerBase, TIMER_A); - //trigger the ADC collection - check and set priorities to make sure handling timing is correct. - //we might want to call it from the task, afetr execution of other taks!!! - ADC_TriggerCollection(); //send message to the control task Message.messageId = OneMillisec; Message.tick = UsersysTickGet(); @@ -243,33 +252,41 @@ uint32_t ControlLoop(uint32_t tick) for (Device_i = 0; Device_i < MAX_TANGO_CONTROL_DEVICES;Device_i++) { - if (ControlArray[Device_i].ControlDataReadPtr) - ControlDatalog[Device_i] = ControlArray[Device_i].ControlDataReadPtr(Device_i, ControlArray[Device_i].Parameter); if (ControlArray[Device_i].ControlActive) { switch (ControlArray[Device_i].ControlTiming) { case eOneMillisecond: + ControlDatalog[Device_i] = ControlArray[Device_i].ControlDataReadPtr(Device_i, ControlArray[Device_i].Parameter1,ControlArray[Device_i].Parameter2); ControlArray[Device_i].ControlCallbackPtr(Device_i, ControlDatalog[Device_i]); break; case eTenMilliSecond: if (Ten_msTick) + { + ControlDatalog[Device_i] = ControlArray[Device_i].ControlDataReadPtr(Device_i, ControlArray[Device_i].Parameter1,ControlArray[Device_i].Parameter2); ControlArray[Device_i].ControlCallbackPtr(Device_i, ControlDatalog[Device_i]); + } break; case eHunderdMillisecond: if (Hundred_msTick) + { + ControlDatalog[Device_i] = ControlArray[Device_i].ControlDataReadPtr(Device_i, ControlArray[Device_i].Parameter1,ControlArray[Device_i].Parameter2); ControlArray[Device_i].ControlCallbackPtr(Device_i, ControlDatalog[Device_i]); + } break; case eOneSecond: if (Onesecond_Tick) + { + ControlDatalog[Device_i] = ControlArray[Device_i].ControlDataReadPtr(Device_i, ControlArray[Device_i].Parameter1,ControlArray[Device_i].Parameter2); ControlArray[Device_i].ControlCallbackPtr(Device_i, ControlDatalog[Device_i]); + } break; default: LOG_ERROR (ControlArray[Device_i].ControlTiming, "Invalid control timing value"); break; - } - } - } + } //switch + } //if control active + } //for return OK; } diff --git a/Software/Embedded_SW/Embedded/Modules/Control/control.h b/Software/Embedded_SW/Embedded/Modules/Control/control.h index 292bbeb82..f443a10d7 100644 --- a/Software/Embedded_SW/Embedded/Modules/Control/control.h +++ b/Software/Embedded_SW/Embedded/Modules/Control/control.h @@ -10,7 +10,7 @@ //typedef uint32_t (* DeviceDataFunction)(uint32_t deviceID, uint32_t *Value); typedef uint32_t (* ControlCBFunction)(uint32_t deviceID, uint32_t ReadValue); -typedef uint32_t (* DataReadCBFunction)(uint32_t deviceID, uint32_t Parameter); +typedef uint32_t (* DataReadCBFunction)(uint32_t deviceID, uint32_t Parameter1, uint32_t Parameter2); typedef enum { eNoControl = 0, eOneMillisecond = 1, @@ -20,10 +20,11 @@ typedef enum { }CTRL_TIMING_ENUM; -void ControlInit(void); -void ControlStop(void); -void ControlStart(void); -int AddControlCallback(uint32_t deviceId, ControlCBFunction Callback, CTRL_TIMING_ENUM CtrlFrequency, DataReadCBFunction DriverfPtr, uint32_t Parameter ); -int RemoveControlCallback(uint32_t deviceId, ControlCBFunction Callback ); -uint32_t TemplateDataReadCBFunction (uint32_t deviceId, uint32_t Parameter); +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 ); +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/Heaters/Heaters_init.c b/Software/Embedded_SW/Embedded/Modules/Heaters/Heaters_init.c index 1162ff11e..b835cf8f1 100644 --- a/Software/Embedded_SW/Embedded/Modules/Heaters/Heaters_init.c +++ b/Software/Embedded_SW/Embedded/Modules/Heaters/Heaters_init.c @@ -23,6 +23,7 @@ #include "include.h" #include <driverlib/timer.h> +#include "heaters_ex.h" #include "heaters.h" #include "Drivers/Heater/Heater.h" @@ -50,6 +51,7 @@ HeaterControlConfig_t HeaterPIDConfig[MAX_HEATERS_NUM] = {0}; uint32_t DeviceId2Heater[MAX_HEATERS_NUM] = {0}; bool AcHeaterConfigured[MAX_AC_HEATERS] = {0}; +bool FastHeating = 1; /******************** CODE ********************************************/ /* * HeatersInit @@ -107,6 +109,10 @@ uint32_t HeaterConfigRequestMessage(HardwarePidControl* request) LOG_ERROR (ValidationError, "Validation Error in Heaters Control"); return ERROR; } + else + { + HeaterConfigSetSharedHeatersParams(1000,120000*12); // initial setting 50Mhz + } } return OK; } diff --git a/Software/Embedded_SW/Embedded/Modules/Heaters/Heaters_print.c b/Software/Embedded_SW/Embedded/Modules/Heaters/Heaters_print.c index f1920f68f..398f9463b 100644 --- a/Software/Embedded_SW/Embedded/Modules/Heaters/Heaters_print.c +++ b/Software/Embedded_SW/Embedded/Modules/Heaters/Heaters_print.c @@ -23,8 +23,22 @@ #include "heaters.h" #include "Drivers/Heater/Heater.h" +#include "Drivers/Heater/TemperatureSensor.h" +/******************** Data Structures ********************************************/ +typedef enum +{ + HeatersControl, +}HeatersControlMessages; + +typedef struct HeatersControlMessage{ + uint16_t messageId; + uint16_t msglen; + uint32_t tick; + uint8_t messageData[20]; +}HeatersControlMessageStruc; + /******************** GLOBAL PARAMETERS ********************************************/ HeaterCommand HeaterCmd[MAX_HEATERS_NUM] = {}; int NumberOFSlicesInUse = 0; @@ -35,16 +49,64 @@ uint32_t Heater_timerBase = TIMER2_BASE; //Timer handle uint32_t OutputProportionalCycleTime = 0; //A/C Heaters Cycle time in milliseconds - one for all heaters char TimeSliceAllocation[MAX_TIMESLICES] = {0xFF}; -bool InitialHeatingState = false; +bool InitialHeatingState = true; +bool TimerActivated = false; + +Mailbox_Handle HeatersControlMsgQ = NULL; + /******************** FUNCTIONS ********************************************/ uint32_t HeaterControlCBFunction(uint32_t deviceID, uint32_t ReadValue); uint32_t PrepareHeater(int HeaterId, uint32_t SetTemperatue); +void HeatersStartControlTimer (void); -/* +//********************************************************************** +//******************** CODE *******************************************/ +//********************************************************************** + +void HeatersControlInit(void) +{ + + HeatersControlMsgQ = Mailbox_create(sizeof(HeatersControlMessageStruc), 20, NULL,NULL); + + ROM_TimerConfigure(Heater_timerBase, TIMER_CFG_PERIODIC); // 32 bits Timer + ROM_IntEnable(INT_TIMER2A); + ROM_TimerIntEnable(Heater_timerBase, TIMER_TIMA_TIMEOUT); + + HeatersRestart = false; + + return; +} +void HeatersControlStop(void) +{ + Report("HeatersControlStop ", __FILE__,__LINE__,0, RpMessage, 0, 0); + TimerActivated = false; + HeatersRestart = false; +} + +void HeatersControlStart(void) +{ + Report("HeatersControlStart ", __FILE__,__LINE__,0, RpMessage, 0, 0); + HeatersRestart = true; + HeatersStartControlTimer(); +} + +void HeatersStartControlTimer (void) +{ + if (TimerActivated == true) + return; + TimerActivated = true; + ROM_TimerConfigure(Heater_timerBase, TIMER_CFG_PERIODIC); // 32 bits Timer + ROM_IntEnable(INT_TIMER2A); + ROM_TimerIntEnable(Heater_timerBase, TIMER_TIMA_TIMEOUT); + Report("HeatersStartControlTimer ", __FILE__,__LINE__,0, RpMessage, 0, 0); + return OK; +} + +/************************************************************************************** * HeaterCommandRequestMessage * called by: Communication from host * initialized all global data - */ + *************************************************************************************/ uint32_t HeaterCommandRequestMessage(int HeaterId, bool OnOff, int Temperature) { //uint32_t status = NOT_SUPPORTED; @@ -69,9 +131,6 @@ uint32_t HeaterCommandRequestMessage(int HeaterId, bool OnOff, int Temperature) //start the control PrepareHeater(HeaterId,Temperature); //prepare the heaters control info //set the power balance handler (if not set yet) - ROM_TimerConfigure(Heater_timerBase, TIMER_CFG_PERIODIC); // 32 bits Timer - ROM_IntEnable(INT_TIMER2A); - ROM_TimerIntEnable(Heater_timerBase, TIMER_TIMA_TIMEOUT); // if the heater is off (?) start it. ActivateHeater(HeaterId); //set the heater operation mode to fast heating - depended on the current temperature @@ -123,7 +182,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(DeviceId2Heater[HeaterId], HeaterControlCBFunction, eHunderdMillisecond,TemplateDataReadCBFunction,HeaterId); + AddControlCallback( HeaterControlCBFunction, eHunderdMillisecond,TemperatureSensorRead,HeaterId,0); return OK; } @@ -196,6 +255,37 @@ uint32_t HeaterControlCBFunction(uint32_t deviceID, uint32_t ReadValue) int SliceCounter = 0; void EightMilliSecondHeatersInterrupt(UArg arg0) { + + ROM_TimerIntClear(Heater_timerBase, TIMER_TIMA_TIMEOUT); // Clear the timer interrupt + + ROM_IntMasterDisable(); + HeatersControlMessageStruc Message; + bool retcode = false; + + //send message to the HeatersControl task + Message.messageId = HeatersControl; + Message.tick = UsersysTickGet(); + Message.msglen = sizeof(HeatersControlMessageStruc); + if (HeatersControlMsgQ != NULL) + retcode = Mailbox_post(HeatersControlMsgQ , &Message, BIOS_NO_WAIT); + + if (HeatersRestart == true) + { + ROM_TimerLoadSet(Heater_timerBase, TIMER_A,OutputProportionalSingleStep/*twelve millisecond???*/); + } + else + TimerDisable(Heater_timerBase, TIMER_A); + + // + // Enable all interrupts. + // + ROM_IntMasterEnable(); + return ; +} + + +uint32_t HeatersControlLoop(uint32_t tick) +{ char str[100]; uint8_t len = 0; @@ -203,7 +293,6 @@ void EightMilliSecondHeatersInterrupt(UArg arg0) len = usnprintf(str, 100, "\r\n EightMilliSecondHeatersInterrupt SliceCounter %d Owner %d H1000 %d H2000 %d" ,SliceCounter,TimeSliceAllocation[SliceCounter],HeatersRestart,NumberOFSlicesInUse); Report(str, __FILE__,__LINE__,0, RpMessage, SliceCounter, TimeSliceAllocation[SliceCounter]); - ROM_IntMasterDisable(); if (TimeSliceAllocation[SliceCounter] == HARDWARE_PID_CONTROL_TYPE__DryerHeater1000w) { @@ -236,16 +325,32 @@ void EightMilliSecondHeatersInterrupt(UArg arg0) if (SliceCounter >= NumberOFSlicesInUse) SliceCounter = 0; - if (HeatersRestart == true) + return OK; +} +/****************************************************************************** + * ======== messageTsk ======== + * Task for this function is created statically. See the project's .cfg file. + * this message task is created statically in system initialization, + ******************************************************************************/ +void HeatersControlTask(UArg arg0, UArg arg1) +{ + HeatersControlMessageStruc Message; + //char str[60]; + //uint16_t length; + //Clock_setTimeout(HostKAClock, 1000); + //Clock_start(HostKAClock); + HeatersControlInit(); + + while(1) { - ROM_TimerLoadSet(Heater_timerBase, TIMER_A,OutputProportionalSingleStep/*twelve millisecond???*/); + Mailbox_pend(HeatersControlMsgQ , &Message, BIOS_WAIT_FOREVER); + switch (Message.messageId) + { + case HeatersControl: + HeatersControlLoop(Message.tick); + break; + default: + break; + } } - else - TimerDisable(Heater_timerBase, TIMER_A); - - // - // Enable all interrupts. - // - ROM_IntMasterEnable(); - return ; } diff --git a/Software/Embedded_SW/Embedded/Modules/IDS/IDS.h b/Software/Embedded_SW/Embedded/Modules/IDS/IDS.h index 1c9fee547..074923d79 100644 --- a/Software/Embedded_SW/Embedded/Modules/IDS/IDS.h +++ b/Software/Embedded_SW/Embedded/Modules/IDS/IDS.h @@ -1,6 +1,8 @@ +#ifndef MODULES_IDS_IDS_H_ +#define MODULES_IDS_IDS_H_ #include "PMR/common/MessageContainer.pb-c.h" #include "PMR/Hardware/HardwareDispenser.pb-c.h" - +#include "drivers/motors/motor.h" #define MAX_SYSTEM_DISPENSERS 8 typedef struct { @@ -22,4 +24,9 @@ typedef struct int32_t id; }DispenserConfigStruc; + +extern uint32_t DispenserIdToMotorId[MAX_SYSTEM_DISPENSERS]; uint32_t DispenserConfigMessage(HardwareDispenser * request); + + +#endif //MODULES_IDS_IDS_H_ diff --git a/Software/Embedded_SW/Embedded/Modules/IDS/IDS_init.c b/Software/Embedded_SW/Embedded/Modules/IDS/IDS_init.c index 0294615b6..d575b0b6e 100644 --- a/Software/Embedded_SW/Embedded/Modules/IDS/IDS_init.c +++ b/Software/Embedded_SW/Embedded/Modules/IDS/IDS_init.c @@ -12,6 +12,8 @@ DispenserConfigStruc DispensersCfg[ MAX_SYSTEM_DISPENSERS]; +uint32_t DispenserIdToMotorId[MAX_SYSTEM_DISPENSERS] = {MOTOR_DISPENSER_1,MOTOR_DISPENSER_2,MOTOR_DISPENSER_3,MOTOR_DISPENSER_4,MOTOR_DISPENSER_5,MOTOR_DISPENSER_6,MOTOR_DISPENSER_7,MOTOR_DISPENSER_8,}; + uint32_t DispenserConfigMessage(HardwareDispenser * request) diff --git a/Software/Embedded_SW/Embedded/Modules/IDS/IDS_print.c b/Software/Embedded_SW/Embedded/Modules/IDS/IDS_print.c index 32b147569..13ea3d77e 100644 --- a/Software/Embedded_SW/Embedded/Modules/IDS/IDS_print.c +++ b/Software/Embedded_SW/Embedded/Modules/IDS/IDS_print.c @@ -11,6 +11,7 @@ #include "PMR/Hardware/Hardwaremotor.pb-c.h" #include "PMR/Hardware/HardwareDispenser.pb-c.h" #include "StateMachines/Printing/printingSTM.h" +#include "drivers/motors/motor.h" diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/Thread.h b/Software/Embedded_SW/Embedded/Modules/Thread/Thread.h index 475f63795..f0dd35da9 100644 --- a/Software/Embedded_SW/Embedded/Modules/Thread/Thread.h +++ b/Software/Embedded_SW/Embedded/Modules/Thread/Thread.h @@ -1,3 +1,7 @@ + +#ifndef MODULES_THREAD_THREAD_H_ +#define MODULES_THREAD_THREAD_H_ + #include "PMR/common/MessageContainer.pb-c.h" #include "PMR/Hardware/HardwareMotor.pb-c.h" #include "PMR/Hardware/HardwareMotorType.pb-c.h" @@ -53,3 +57,7 @@ uint32_t MotorsConfigMessage(HardwareMotor * request); uint32_t InternalWindingConfigMessage(JobSpool* request); uint32_t DancerConfigMessage(HardwareDancer * request); + + +#endif //MODULES_THREAD_THREAD_H_ + diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c index 13c81fb39..44e5c8936 100644 --- a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c +++ b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c @@ -10,6 +10,9 @@ #include "../control/pidalgo.h" #include "PMR/Hardware/HardwareMotor.pb-c.h" #include "PMR/Hardware/HardwareMotorType.pb-c.h" +#include "drivers/Motors/Motor.h" +#include "drivers/Heater/TemperatureSensor.h" +#include "drivers/Heater/Heater.h" ////////////////////////////////State machine operation//////////////////////////////////// //the state machine operation is used to operate in runtime correct profile flow execution //by recieved esign flow of the user from the UI @@ -186,8 +189,9 @@ static ReturnCode PrepareState(void *JobDetails) 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 - AddControlCallback(DeviceId2Motor[Motor_i], ThreadControlCBFunction, eOneMillisecond,TemplateDataReadCBFunction,Motor_i); + AddControlCallback(ThreadControlCBFunction, eOneMillisecond,TemplateDataReadCBFunction,Motor_i,0); } + //set 3 dancers to the profile positions return NextState; } @@ -196,10 +200,10 @@ static ReturnCode PrepareState(void *JobDetails) static ReturnCode PreSegmentState(void *JobDetails) { - int Motor_i; + TimerMotors_t Motor_i; for (Motor_i = 0;Motor_i < MAX_THREAD_MOTORS_NUM;Motor_i++) { - MotorControlConfig[Motor_i].m_SetParam = getMotorFreq(Motor_i);//need to update SetParams on presegment stage + MotorControlConfig[Motor_i].m_SetParam = MotorGetSpeed(getMotorId(Motor_i));//need to update SetParams on presegment stage } // set the new speed in the dryer motor to the speed of the new segment // activate control fr all motors |
