aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Embedded_SW
diff options
context:
space:
mode:
authorAvi Levkovich <avi@twine-s.com>2019-05-02 12:05:35 +0300
committerAvi Levkovich <avi@twine-s.com>2019-05-02 12:05:35 +0300
commit02ab024a4011ea113115444da592addd17fffa45 (patch)
tree7466565347860f7b118951003c722e6fa6b6fc3a /Software/Embedded_SW
parent708417903a4c51fa155721976868232700307ded (diff)
downloadTango-02ab024a4011ea113115444da592addd17fffa45.tar.gz
Tango-02ab024a4011ea113115444da592addd17fffa45.zip
Add Read_Screw_Encoder()
Diffstat (limited to 'Software/Embedded_SW')
-rw-r--r--Software/Embedded_SW/Embedded/Drivers/FPGA/FPGA.c45
-rw-r--r--Software/Embedded_SW/Embedded/Drivers/FPGA/FPGA.h12
2 files changed, 56 insertions, 1 deletions
diff --git a/Software/Embedded_SW/Embedded/Drivers/FPGA/FPGA.c b/Software/Embedded_SW/Embedded/Drivers/FPGA/FPGA.c
index aff2e7cd1..41a28b4c1 100644
--- a/Software/Embedded_SW/Embedded/Drivers/FPGA/FPGA.c
+++ b/Software/Embedded_SW/Embedded/Drivers/FPGA/FPGA.c
@@ -9,7 +9,7 @@
#include "FPGA_Rename.h"
#include "FPGA_COMM.h"
-#include <DataDef.h>
+#include "FPGA.h"
#include "driverlib/sysctl.h" //for SysCtlDelay
#include <driverlib/sysctl.h>
@@ -426,3 +426,46 @@ uint32_t Read_Speed_Sensor_TypeII()//must be delay between Set_Speed_Sensor_Type
return Speed_Hz;
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+
+typedef union
+{
+ struct
+ {
+ uint16_t M:10;//0..9
+ uint16_t Direction:1;//10
+ uint8_t Spare:5;//11-15
+ }Bits;
+ uint32_t Word;
+}SCREW_ENC_M;
+
+typedef union
+{
+ struct
+ {
+ uint16_t M;
+ uint16_t L;
+ }Word;
+ uint32_t Position;
+}SCREW_POS;
+
+
+
+
+SCREW_ENC Screw_RotEnc;
+
+void Read_Screw_Encoder()
+{
+ SCREW_ENC_M Screw_Enc_M;
+ SCREW_POS Screw_Pos;
+
+ Screw_Pos.Word.L = F1_SCREW_ROTENC_L; // Must First Read the register of Lsw.
+ Screw_Enc_M.Word = F1_SCREW_ROTENC_M;
+
+ Screw_Pos.Word.M = Screw_Enc_M.Bits.M;
+
+
+ Screw_RotEnc.Position = Screw_Pos.Position;
+ Screw_RotEnc.Direction = Screw_Enc_M.Bits.Direction;
+ Screw_RotEnc.Index = F1_SCREW_ROTENC_I;
+}
diff --git a/Software/Embedded_SW/Embedded/Drivers/FPGA/FPGA.h b/Software/Embedded_SW/Embedded/Drivers/FPGA/FPGA.h
index 0e5cdb66a..8564c2266 100644
--- a/Software/Embedded_SW/Embedded/Drivers/FPGA/FPGA.h
+++ b/Software/Embedded_SW/Embedded/Drivers/FPGA/FPGA.h
@@ -19,4 +19,16 @@ uint32_t Read_Dryer_Fan_Tacho();
void Set_Speed_Sensor_TypeII_Registers(uint32_t Counter, uint32_t Prescaler);
uint32_t Read_Speed_Sensor_TypeII();
+void Read_Screw_Encoder();
+
+typedef struct
+{
+ uint32_t Position;
+ bool Direction;
+ uint16_t Index; // This counter counts the amount of index pulses that have occurred since the last time the register was read.
+
+}SCREW_ENC;
+
+extern SCREW_ENC Screw_RotEnc;;
+
#endif //FPGA_H