diff options
| author | Avi Levkovich <avi@twine-s.com> | 2019-03-07 17:08:42 +0200 |
|---|---|---|
| committer | Avi Levkovich <avi@twine-s.com> | 2019-03-07 17:08:42 +0200 |
| commit | 7256fe1c07cf5ecbe485c3cdac238b88dfc2cd1d (patch) | |
| tree | c3dd4234b9499f913ddf3aee79b3adc65644f650 /Software/Embedded_SW/Embedded/Drivers/FPGA/FPGA.c | |
| parent | 09f93935c9b8b3e758d3539a8d5f84cd17f615c0 (diff) | |
| download | Tango-7256fe1c07cf5ecbe485c3cdac238b88dfc2cd1d.tar.gz Tango-7256fe1c07cf5ecbe485c3cdac238b88dfc2cd1d.zip | |
Add system fans + read the tacho of the new small drawer fans
Diffstat (limited to 'Software/Embedded_SW/Embedded/Drivers/FPGA/FPGA.c')
| -rw-r--r-- | Software/Embedded_SW/Embedded/Drivers/FPGA/FPGA.c | 103 |
1 files changed, 80 insertions, 23 deletions
diff --git a/Software/Embedded_SW/Embedded/Drivers/FPGA/FPGA.c b/Software/Embedded_SW/Embedded/Drivers/FPGA/FPGA.c index 8efa3998f..454e82c28 100644 --- a/Software/Embedded_SW/Embedded/Drivers/FPGA/FPGA.c +++ b/Software/Embedded_SW/Embedded/Drivers/FPGA/FPGA.c @@ -9,6 +9,7 @@ #include "FPGA_Rename.h" #include "FPGA_COMM.h" +#include <DataDef.h> #include "driverlib/sysctl.h" //for SysCtlDelay #include <driverlib/sysctl.h> @@ -191,20 +192,29 @@ uint32_t Calculate_Tacho_Fan_Speed(uint32_t OSC_IN, uint8_t PPR, uint16_t Presca } +uint32_t Fans_Speed_RPM[MAX_FANS]; + -uint32_t Read_Fans_Tacho() +FANS_STATUS Read_Fans_Tacho() { - uint32_t Status = 0; - uint32_t Drawer_Fan_Speed_RPM = 0; + FANS_STATUS Fans_Status; + #ifndef EVALUATION_BOARD // The big Fan in the drawer - Drawer_Fan_Speed_RPM = Calculate_Tacho_Fan_Speed(29166666, 0X02, F1_Prescaler1_reg5, F1_Tacho_reg0); + Fans_Speed_RPM[DRAWER_B] = Calculate_Tacho_Fan_Speed(29166666, 0X02, F1_Prescaler1_reg5, F1_Tacho_reg0); + Fans_Speed_RPM[DRAWER_S0] = Calculate_Tacho_Fan_Speed(29166666, 0X02, F1_Prescaler1_reg5, F1_Tacho_reg1); + Fans_Speed_RPM[DRAWER_S1] = Calculate_Tacho_Fan_Speed(29166666, 0X02, F1_Prescaler1_reg5, F1_Tacho_reg2); + Fans_Speed_RPM[DRAWER_S2] = Calculate_Tacho_Fan_Speed(29166666, 0X02, F1_Prescaler1_reg5, F1_Tacho_reg3); + Fans_Speed_RPM[DRAWER_S3] = Calculate_Tacho_Fan_Speed(29166666, 0X02, F1_Prescaler1_reg5, F1_Tacho_reg4); + Fans_Speed_RPM[SYSTEM_0] = Calculate_Tacho_Fan_Speed(29166666, 0X02, F1_Prescaler1_reg5, F1_Tacho_reg5); + Fans_Speed_RPM[SYSTEM_1] = Calculate_Tacho_Fan_Speed(29166666, 0X02, F1_Prescaler1_reg5, F1_Tacho_reg6); + Fans_Speed_RPM[SYSTEM_2] = Calculate_Tacho_Fan_Speed(29166666, 0X02, F1_Prescaler1_reg5, F1_Tacho_reg7); - if( Drawer_Fan_Speed_RPM < 1000 ) // need to work around 3000 RPM - Status|= 0x01;// not working / Low Speed + if( Fans_Speed_RPM[DRAWER_B] < 1000 ) // need to work around 3000 RPM + Fans_Status.DRAWER_BIG = ERROR;// not working / Low Speed else - Status&= ~0x01;//working (Speed ~0x400) + Fans_Status.DRAWER_BIG = OK;//working (Speed ~0x400) // The 4 small Fans in the drawer // F1_gpi_FANS @@ -212,7 +222,10 @@ uint32_t Read_Fans_Tacho() // “1” Fan working if (F1_gpi_FANS == 0x0F ) { - Status&= ~(0x0F<<1);//working + Fans_Status.DRAWER_SMALL0 = OK;//working + Fans_Status.DRAWER_SMALL1 = OK;//working + Fans_Status.DRAWER_SMALL2 = OK;//working + Fans_Status.DRAWER_SMALL3 = OK;//working } else { @@ -221,28 +234,72 @@ uint32_t Read_Fans_Tacho() bool F1_FAN3_TACH = (F1_gpi_FANS & 0x04)>>0x02; bool F1_FAN4_TACH = (F1_gpi_FANS & 0x08)>>0x03; - if( F1_FAN1_TACH == 0) // Small Fan in the drawer - Status|= (0x01<<1);// not working + if(( Fans_Speed_RPM[DRAWER_S0] < 3000 ) && ( F1_FAN1_TACH == 0)) // need to work around 5000 RPM + { + Fans_Status.DRAWER_SMALL0 = ERROR;/// not working / Low Speed + } else - Status&= ~(0x01<<1);//working + { + Fans_Status.DRAWER_SMALL0 = OK;//working (Speed ~0x400) + } - if( F1_FAN2_TACH == 0) // Small Fan in the drawer - Status|= (0x01<<2);// not working + if(( Fans_Speed_RPM[DRAWER_S1] < 3000 ) && ( F1_FAN2_TACH == 0)) // Small Fan in the drawer // need to work around 5000 RPM + { + Fans_Status.DRAWER_SMALL1 = ERROR;// not working / Low Speed + } else - Status&= ~(0x01<<2);//working - - if( F1_FAN3_TACH == 0) // Small Fan in the drawer - Status|= (0x01<<3);// not working + { + Fans_Status.DRAWER_SMALL1 = OK;//working (Speed ~0x400) + } + if(( Fans_Speed_RPM[DRAWER_S2] < 3000 ) && ( F1_FAN3_TACH == 0)) // Small Fan in the drawer // need to work around 5000 RPM + { + Fans_Status.DRAWER_SMALL2 = ERROR;// not working / Low Speed + } else - Status&= ~(0x01<<3);//working - - if( F1_FAN4_TACH == 0) // Small Fan in the drawer - Status|= (0x01<<4);// not working + { + Fans_Status.DRAWER_SMALL2 = OK;//working (Speed ~0x400) + } + if(( Fans_Speed_RPM[DRAWER_S3] < 3000 ) && ( F1_FAN4_TACH == 0)) // Small Fan in the drawer // need to work around 3050 RPM + { + Fans_Status.DRAWER_SMALL3 = ERROR;// not working / Low Speed + } else - Status&= ~(0x01<<4);//working + { + Fans_Status.DRAWER_SMALL3 = OK;//working (Speed ~0x400) < 1000 ) // need to work around 5000 RPM + } + + } + + if( Fans_Speed_RPM[SYSTEM_0] < 1000 ) // need to work around 3050 RPM + { + Fans_Status.SYSTEM_FAN0 = ERROR;// not working / Low Speed } + else + { + Fans_Status.SYSTEM_FAN0 = OK;//working (Speed ~0x400) + } + + if( Fans_Speed_RPM[SYSTEM_1] < 1000 ) // need to work around 3050 RPM + { + Fans_Status.SYSTEM_FAN1 = ERROR;// not working / Low Speed + } + else + { + Fans_Status.SYSTEM_FAN1 = OK;//working (Speed ~0x400) + } + + if( Fans_Speed_RPM[SYSTEM_2] < 1000 ) // need to work around 3050 RPM + { + Fans_Status.SYSTEM_FAN2 = ERROR;// not working / Low Speed + } + else + { + Fans_Status.SYSTEM_FAN2 = OK;//working (Speed ~0x400) + } + #endif - return Status; + + return Fans_Status; } //------------------------- WHS ---------------------- |
