📄 dy4thermaltest.c
字号:
/************************************************************************** * * Copyright (c) 2005 Curtiss-Wright Controls, Inc. All rights * reserved. This Source Code is the Property of Curtiss-Wright * Controls, Inc. and can only be used in accordance with Source * Code License Agreement(s) of Curtiss-Wright Controls, Inc. or any * of its subsidiaries. * **************************************************************************//*FILE HEADER************************************************************** * Product Name: 182/183 BSPs * * Header %name: dy4ThermalTest.c % * Instance: kanata_1 * * Description: VME-182/183 temperature sensor test * * %created_by: tissa % * %date_created: Mon Dec 12 17:19:28 2005 % * * Notes: * * History: * 01e,12dec05,tis rename Discovery_II directory to Discovery_III CR#12858. * 01d,20oct05,rsr CR3191: Added bsp.h to includes * 01c,11jan05,rcd ported to VME-183 * 01b,16nov04,mb PT2288: fixed sensor numbering (now numbrd 1-4) * 01a,23oct04,mb PT2250: replaced DEBUGMP with printf * printf seems to be adding stability to demo code * *END FILE HEADER*********************************************************/#include "vxWorks.h"#include "stdio.h"#include "ioLib.h"#include "sysLib.h"#include "taskLib.h"#include "intLib.h"#include "h/drv/dy4/boardName.h"#include "bsp.h"#ifdef VME_182#include "intCtrl182_dy4.h"#include "fpga182_dy4.h"#include "dy4182.h"#endif#ifdef VME_183#include "intCtrl183.h"#include "fpga183.h"#include "cwv183.h"#define TEMP1 TEMPA_INT_SRC#endif#ifdef VME_183#include "h/drv/discovery_III/i2c/gtI2c.h"#else#include "h/drv/discovery_II/i2c/gtI2c.h"#endif#include "h/drv/thermal/dy4max6634.h"extern int tempHandlerRan[DY4THERMAL_MAX];/* --------------------------------------------------------------------------- *//* tempSensTest - test the temperature sensors *//* --------------------------------------------------------------------------- */void tempSensTest ( void ) { int i; int temp[DY4THERMAL_MAX], tempVal; /* * Find out what the tempertures are now */ for (i = 0; i < DY4THERMAL_MAX; i++) { temp[i] = 0; if (dy4ThermalReadTemp(i, DY4THERMAL_CELSIUS, &temp[i]) == OK) { printf("MSG:tempSensTest:Temperature sensor %d reading is: %d C\n", i + 1, temp[i]); } else { printf("MSG:tempSensTest:Temperature sensor %d reading failed\n", i + 1); } } /* * Lets lower the Thigh to less than the current temp * for each sensor, then see if our handlers run * we will need to wait a few seconds for the ints */ for (i = 0; i < DY4THERMAL_MAX; i++) { tempHandlerRan[i] = FALSE; if( dy4ThermalSetHighTemp( i, -45 ) != OK ) { printf("MSG:tempSensTest: Failed to write to Thigh reg for sensor %d\n", i + 1 ); } else { dy4ThermalGetHighTemp(i, &tempVal ); } if( dy4ThermalSetLowTemp( i, -55 ) != OK ) { printf("MSG:tempSensTest: Failed to write to Tlow reg for sensor %d\n", i + 1 ); } else { dy4ThermalGetLowTemp(i, &tempVal ); } } for (i = 0; i < DY4THERMAL_MAX; i++) { intEnable(TEMP1 + i); } taskDelay( 5 * sysClkRateGet() ); for (i = 0; i < DY4THERMAL_MAX; i++) { intDisable(TEMP1 + i); } for (i = 0; i < DY4THERMAL_MAX; i++) { if (tempHandlerRan[i] == TRUE ) { printf("MSG:tempSensTest:Temperature sensor %d detected overtemp\n", i + 1 ); } else { printf("MSG:tempSensTest:Temperature sensor %d did not detect overtemp\n", i + 1 ); } } /* * Find out what the tempertures are now */ for (i = 0; i < DY4THERMAL_MAX; i++) { temp[i] = 0; if (dy4ThermalReadTemp(i, DY4THERMAL_CELSIUS, &temp[i]) == OK) { printf("MSG:tempSensTest:Temperature sensor %d reading is: %d C\n", i + 1, temp[i]); } else { printf("MSG:tempSensTest:Temperature sensor %d reading failed\n", i + 1); } } /* * Restore the high and low temp values */ for (i = 0; i < DY4THERMAL_MAX; i++) { dy4ThermalSetHighTemp( i, dy4ThermalTHighTemps[i] ); dy4ThermalSetLowTemp( i, dy4ThermalTLowTemps[i] ); } taskDelay( sysClkRateGet() ); /* * Lets raise the Tlow to greater than the current temp * for each sensor, then see if our handlers run * we will need to wait a few seconds for the ints */ for (i = 0; i < DY4THERMAL_MAX; i++) { tempHandlerRan[i] = FALSE; if( dy4ThermalSetHighTemp( i, 90 ) != OK ) { printf("MSG:tempSensTest: Failed to write to Tlow reg for sensor %d\n", i + 1 ); } else { dy4ThermalGetHighTemp(i, &tempVal ); } if( dy4ThermalSetLowTemp( i, 80 ) != OK ) { printf("MSG:tempSensTest: Failed to write to Tlow reg for sensor %d\n", i + 1); } else { dy4ThermalGetLowTemp(i, &tempVal ); } } for (i = 0; i < DY4THERMAL_MAX; i++) { intEnable(TEMP1 + i); } taskDelay( 5 * sysClkRateGet() ); for (i = 0; i < DY4THERMAL_MAX; i++) { intDisable(TEMP1 + i); } for (i = 0; i < DY4THERMAL_MAX; i++) { if (tempHandlerRan[i] == TRUE ) { printf("MSG:tempSensTest:Temperature sensor %d detected undertemp\n", i + 1 ); } else { printf("MSG:tempSensTest:Temperature sensor %d did not detect undertemp\n", i + 1 ); } } /* * Restore the high and low temp values */ for (i = 0; i < DY4THERMAL_MAX; i++) { dy4ThermalSetHighTemp( i, dy4ThermalTHighTemps[i] ); dy4ThermalSetLowTemp( i, dy4ThermalTLowTemps[i] ); } /* * Find out what the tempertures are now */ for (i = 0; i < DY4THERMAL_MAX; i++) { temp[i] = 0; if (dy4ThermalReadTemp(i, DY4THERMAL_CELSIUS, &temp[i]) == OK) { printf("MSG:tempSensTest:Temperature sensor %d reading is: %d C\n", i + 1, temp[i]); } else { printf("MSG:tempSensTest:Temperature sensor %d reading failed\n", i + 1); } } printf("\n"); }/* --------------------------------------------------------------------------- *//* END OF FILE *//* --------------------------------------------------------------------------- */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -