aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Embedded_SW/Embedded/Modules
diff options
context:
space:
mode:
authorShlomo Hecht <shlomo@twine-s.com>2018-04-24 10:26:10 +0300
committerShlomo Hecht <shlomo@twine-s.com>2018-04-24 10:26:10 +0300
commit56d8d91c96cfa1bb7b0f48ee50ebca8dbf6aa71c (patch)
tree86a5d9a2830426ac9745a4991fbd5e1d897ac7b3 /Software/Embedded_SW/Embedded/Modules
parentf1347b9bea5562781e1f2d0440981a15c52b5144 (diff)
downloadTango-56d8d91c96cfa1bb7b0f48ee50ebca8dbf6aa71c.tar.gz
Tango-56d8d91c96cfa1bb7b0f48ee50ebca8dbf6aa71c.zip
PT100 FPGA interface through 1 millisec task
Diffstat (limited to 'Software/Embedded_SW/Embedded/Modules')
-rw-r--r--Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.c55
-rw-r--r--Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.h3
2 files changed, 55 insertions, 3 deletions
diff --git a/Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.c b/Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.c
index 44e5e682f..b4ceebbc2 100644
--- a/Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.c
+++ b/Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.c
@@ -63,7 +63,7 @@ uint32_t Dancer_Data[NUM_OF_DANCERS] = {0};
MillisecMotorDataStruc MotorData[NUM_OF_MOTORS] = {0};
MillisecMotorDataStruc SpeedSetPending[NUM_OF_MOTORS] = {0};
-
+MillisecMotorDataStruc PT100Data[MAX_TEMPERATURE_SENSOR_ID] = {0};
/******************** GLOBAL PARAMETERS ********************************************/
Mailbox_Handle MillisecMsgQ = NULL;
Mailbox_Handle MotorsMsgQ[NUM_OF_MOTORS] = {NULL};
@@ -152,6 +152,25 @@ void OneMilliSecondMillisecInterrupt(UArg arg0)
ROM_IntMasterEnable();
return ;
}
+int32_t MillisecWriteToTempSensor(uint32_t TempSensorId, unsigned long Data, int Length, MSecFptr Callback)
+{
+ if (TempSensorId >= MAX_TEMPERATURE_SENSOR_ID) return -1;
+ PT100Data[TempSensorId].Callback = Callback;
+ PT100Data[TempSensorId].Data = Data;
+ PT100Data[TempSensorId].Length = Length;
+ PT100Data[TempSensorId].DataRequired = false;
+ PT100Data[TempSensorId].Active = true;
+}
+int32_t MillisecReadFromTempSensor(uint32_t TempSensorId, unsigned long Data, int Length, MSecFptr Callback)
+{
+ if (TempSensorId >= MAX_TEMPERATURE_SENSOR_ID) return -1;
+ PT100Data[TempSensorId].Callback = Callback;
+ PT100Data[TempSensorId].Data = Data;
+ PT100Data[TempSensorId].Length = Length;
+ PT100Data[TempSensorId].DataRequired = true;
+ PT100Data[TempSensorId].Active = true;
+
+}
//typedef uint32_t (* MSecFptr)(uint32_t deviceID, uint32_t ReadValue);
int32_t MillisecSetMotorSpeed(TimerMotors_t MotorId, unsigned long Data, int Length, MSecFptr Callback)
{
@@ -188,7 +207,7 @@ int32_t MillisecReadFromMotor(TimerMotors_t MotorId, unsigned long Data, int Len
}
uint32_t MillisecLoop(uint32_t tick)
{
- int Motor_i;
+ int Motor_i,Sensor_i;
unsigned int MotorInfo = 0;
//call all modules Millisec functions
//test dancers and speed encoders
@@ -236,7 +255,37 @@ uint32_t MillisecLoop(uint32_t tick)
}
}
Dancer_Data[FEEDER_DANCER] = Read_Dancer_Position(FEEDER_DANCER);
-
+ if (Hundred_msTick)
+ {
+ //FPGA_GetTempSensorBusy();
+ for (Sensor_i = 0;Sensor_i < NUM_OF_MOTORS;Sensor_i++)
+ {
+ //if (TempDriverDriverResponse[Sensor_i].Busy == true)
+ // continue;
+ if (PT100Data[Sensor_i].WaitForData == true) //Read request sent, data is waiting
+ {
+ if (MotorGetFPGAResponse(Sensor_i,&MotorInfo) == OK) //got the data from the FPGA
+ {
+ PT100Data[Sensor_i].WaitForData = false;
+ if (PT100Data[Sensor_i].Callback)
+ PT100Data[Sensor_i].Callback(Sensor_i,MotorInfo);
+ }
+ }
+ if (PT100Data[Sensor_i].Active == true)
+ {
+ MotorSendFPGARequest(Sensor_i,PT100Data[Sensor_i].Data,PT100Data[Sensor_i].Length);
+ if (PT100Data[Sensor_i].DataRequired == true)
+ {
+ PT100Data[Sensor_i].WaitForData = true; // mark the motor for data request next round
+ }
+ else
+ {
+ if (PT100Data[Sensor_i].Callback)
+ PT100Data[Sensor_i].Callback(Sensor_i,0); // call the callback to report execution
+ }
+ }
+ }
+ }
#ifndef EVALUATION_BOARD
/* this cannot be done within one millisecond, and not needed
* instead, check if there is a motor waiting with data to send or read request
diff --git a/Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.h b/Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.h
index d27018031..f0009b43b 100644
--- a/Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.h
+++ b/Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.h
@@ -18,6 +18,9 @@ int32_t MillisecWriteToMotor(TimerMotors_t MotorId, unsigned long Data, int Leng
int32_t MillisecSetMotorSpeed(TimerMotors_t MotorId, unsigned long Data, int Length, MSecFptr Callback);
int32_t MillisecReadFromMotor(TimerMotors_t MotorId, unsigned long Data, int Length, MSecFptr Callback);
+int32_t MillisecWriteToTempSensor(uint32_t TempSensorId, unsigned long Data, int Length, MSecFptr Callback);
+int32_t MillisecReadFromTempSensor(uint32_t TempSensorId, unsigned long Data, int Length, MSecFptr Callback);
+
uint32_t getMotorStatusData(int MotorId);
uint32_t getMotorSpeedData(int MotorId);
uint32_t getTemperatureSensorData(int SensorId);