aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.c
diff options
context:
space:
mode:
Diffstat (limited to 'Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.c')
-rw-r--r--Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.c80
1 files changed, 76 insertions, 4 deletions
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];
+}
+