138 unsigned int ul_TimerValue = 0;
139 unsigned int ul_TimingInterval = 0;
140 unsigned int ul_RealTimingInterval = 0;
141 double d_RealTimingInterval = 0;
142 unsigned int dw_ModeArray[8] =
143 { 0x01, 0x05, 0x00, 0x04, 0x02, 0x0E, 0x0A, 0x06 };
144 unsigned char b_ModulNbr, b_ChronoMode, b_PCIInputClock, b_TimingUnit;
147 b_ChronoMode = (
unsigned char) data[0];
148 b_PCIInputClock = (
unsigned char) data[1];
149 b_TimingUnit = (
unsigned char) data[2];
150 ul_TimingInterval = (
unsigned int) data[3];
151 i_ReturnValue = insn->
n;
157 if (b_ModulNbr < 4) {
163 dw_MolduleConfiguration[b_ModulNbr] &
169 if (b_ChronoMode <= 7) {
181 if (b_TimingUnit <= 4) {
186 if (((b_PCIInputClock ==
APCI1710_30MHZ) && (b_TimingUnit == 0) && (ul_TimingInterval >= 66) && (ul_TimingInterval <= 0xFFFFFFFFUL)) || ((b_PCIInputClock == APCI1710_30MHZ) && (b_TimingUnit == 1) && (ul_TimingInterval >= 1) && (ul_TimingInterval <= 143165576
UL)) || ((b_PCIInputClock ==
APCI1710_30MHZ) && (b_TimingUnit == 2) && (ul_TimingInterval >= 1) && (ul_TimingInterval <= 143165UL)) || ((b_PCIInputClock == APCI1710_30MHZ) && (b_TimingUnit == 3) && (ul_TimingInterval >= 1) && (ul_TimingInterval <= 143
UL)) || ((b_PCIInputClock ==
APCI1710_30MHZ) && (b_TimingUnit == 4) && (ul_TimingInterval >= 1) && (ul_TimingInterval <= 2UL)) || ((b_PCIInputClock == APCI1710_33MHZ) && (b_TimingUnit == 0) && (ul_TimingInterval >= 60) && (ul_TimingInterval <= 0xFFFFFFFFUL)) || ((b_PCIInputClock ==
APCI1710_33MHZ) && (b_TimingUnit == 1) && (ul_TimingInterval >= 1) && (ul_TimingInterval <= 130150240UL)) || ((b_PCIInputClock == APCI1710_33MHZ) && (b_TimingUnit == 2) && (ul_TimingInterval >= 1) && (ul_TimingInterval <= 130150
UL)) || ((b_PCIInputClock ==
APCI1710_33MHZ) && (b_TimingUnit == 3) && (ul_TimingInterval >= 1) && (ul_TimingInterval <= 130UL)) || ((b_PCIInputClock == APCI1710_33MHZ) && (b_TimingUnit == 4) && (ul_TimingInterval >= 1) && (ul_TimingInterval <= 2
UL)) || ((b_PCIInputClock ==
APCI1710_40MHZ) && (b_TimingUnit == 0) && (ul_TimingInterval >= 50) && (ul_TimingInterval <= 0xFFFFFFFFUL)) || ((b_PCIInputClock == APCI1710_40MHZ) && (b_TimingUnit == 1) && (ul_TimingInterval >= 1) && (ul_TimingInterval <= 107374182
UL)) || ((b_PCIInputClock ==
APCI1710_40MHZ) && (b_TimingUnit == 2) && (ul_TimingInterval >= 1) && (ul_TimingInterval <= 107374UL)) || ((b_PCIInputClock == APCI1710_40MHZ) && (b_TimingUnit == 3) && (ul_TimingInterval >= 1) && (ul_TimingInterval <= 107
UL)) || ((b_PCIInputClock ==
APCI1710_40MHZ) && (b_TimingUnit == 4) && (ul_TimingInterval >= 1) && (ul_TimingInterval <= 1
UL))) {
204 switch (b_TimingUnit) {
220 (0.001 * b_PCIInputClock));
226 if ((
double)((double)ul_TimingInterval * (0.001 * (
double)b_PCIInputClock)) >= ((double)((
double)ul_TimerValue + 0.5))) {
238 ul_RealTimingInterval
243 (0.001 * (
double)b_PCIInputClock));
254 if ((
double)((double)ul_TimerValue / (0.001 * (
double)b_PCIInputClock)) >= (double)((
double)ul_RealTimingInterval + 0.5)) {
255 ul_RealTimingInterval
257 ul_RealTimingInterval
300 (1.0 * b_PCIInputClock));
306 if ((
double)((double)ul_TimingInterval * (1.0 * (
double)b_PCIInputClock)) >= ((double)((
double)ul_TimerValue + 0.5))) {
318 ul_RealTimingInterval
323 (1.0 * (
double)b_PCIInputClock));
336 if ((
double)((double)ul_TimerValue / (1.0 * (
double)b_PCIInputClock)) >= (double)((
double)ul_RealTimingInterval + 0.5)) {
337 ul_RealTimingInterval
339 ul_RealTimingInterval
389 if ((
double)((double)ul_TimingInterval * (1000.0 * (
double)b_PCIInputClock)) >= ((double)((
double)ul_TimerValue + 0.5))) {
401 ul_RealTimingInterval
406 (1000.0 * (
double)b_PCIInputClock));
417 if ((
double)((double)ul_TimerValue / (1000.0 * (
double)b_PCIInputClock)) >= (double)((
double)ul_RealTimingInterval + 0.5)) {
418 ul_RealTimingInterval
420 ul_RealTimingInterval
471 if ((
double)((double)ul_TimingInterval * (1000000.0 * (
double)b_PCIInputClock)) >= ((double)((
double)ul_TimerValue + 0.5))) {
483 ul_RealTimingInterval
502 if ((
double)((double)ul_TimerValue / (1000000.0 * (
double)b_PCIInputClock)) >= (double)((
double)ul_RealTimingInterval + 0.5)) {
503 ul_RealTimingInterval
505 ul_RealTimingInterval
559 if ((
double)((double)(ul_TimingInterval * 60.0) * (1000000.0 * (double)b_PCIInputClock)) >= ((
double)((double)ul_TimerValue + 0.5))) {
571 ul_RealTimingInterval
588 (0.001 * (
double)b_PCIInputClock)) / 60.0;
590 if ((
double)(((double)ul_TimerValue / (1000000.0 * (
double)b_PCIInputClock)) / 60.0) >= (double)((
double)ul_RealTimingInterval + 0.5)) {
591 ul_RealTimingInterval
593 ul_RealTimingInterval
658 d_RealTimingInterval;
693 outl(
devpriv->s_ModuleInfo[b_ModulNbr].s_ChronoModuleInfo.dw_ConfigReg,
devpriv->s_BoardInfos.ui_Address + 16 + (64 * b_ModulNbr));
699 outl(ul_TimerValue,
devpriv->s_BoardInfos.ui_Address + (64 * b_ModulNbr));
717 DPRINTK(
"TOR version error for 40MHz clock selection\n");
727 DPRINTK(
"You can not used the 40MHz clock selection with this board\n");
736 DPRINTK(
"Base timing selection is wrong\n");
745 DPRINTK(
"Timing unity selection is wrong\n");
754 DPRINTK(
"The selected PCI input clock is wrong\n");
763 DPRINTK(
"Chronometer mode selection is wrong\n");
771 DPRINTK(
"The module is not a Chronometer module\n");
779 DPRINTK(
"Module number error\n");
782 data[0] = ul_RealTimingInterval;
849 b_Action = (
unsigned char) data[0];
850 b_CycleMode = (
unsigned char) data[1];
851 b_InterruptEnable = (
unsigned char) data[2];
852 i_ReturnValue = insn->
n;
858 if (b_ModulNbr < 4) {
864 dw_MolduleConfiguration[b_ModulNbr] &
870 if (
devpriv->s_ModuleInfo[b_ModulNbr].
871 s_ChronoModuleInfo.b_ChronoInit == 1) {
888 if ((b_InterruptEnable ==
890 || (b_InterruptEnable ==
937 if (b_InterruptEnable ==
989 DPRINTK(
"Interrupt parameter is wrong\n");
998 DPRINTK(
"Chronometer acquisition mode cycle is wrong\n");
1007 b_InterruptMask = 0;
1015 dw_ConfigReg & 0x2F;
1023 s_ChronoModuleInfo.dw_ConfigReg,
1032 if (
devpriv->s_ModuleInfo[b_ModulNbr].
1047 DPRINTK(
"Inputs wrong! Enable or Disable chrono\n");
1055 DPRINTK(
"Chronometer not initialised\n");
1063 DPRINTK(
"The module is not a Chronometer module\n");
1071 DPRINTK(
"Module number error\n");
1096 unsigned char b_ReadType;
1101 switch (b_ReadType) {
1110 (
unsigned int) insn->
unused[0],
1111 (
unsigned char *) &data[0], (
unsigned int *) &data[1]);
1117 (
unsigned int) insn->
unused[0],
1118 (
unsigned int *) &data[0],
1119 (
unsigned char *) &data[1],
1120 (
unsigned char *) &data[2],
1121 (
unsigned int *) &data[3],
1122 (
unsigned int *) &data[4], (
unsigned int *) &data[5]);
1126 printk(
"In Chrono Read Interrupt\n");
1128 data[0] =
devpriv->s_InterruptParameters.
1129 s_FIFOInterruptParameters[
devpriv->
1130 s_InterruptParameters.ui_Read].b_OldModuleMask;
1131 data[1] =
devpriv->s_InterruptParameters.
1132 s_FIFOInterruptParameters[
devpriv->
1133 s_InterruptParameters.ui_Read].ul_OldInterruptMask;
1134 data[2] =
devpriv->s_InterruptParameters.
1135 s_FIFOInterruptParameters[
devpriv->
1136 s_InterruptParameters.ui_Read].ul_OldCounterLatchValue;
1143 s_InterruptParameters.
1145 s_InterruptParameters.
1150 printk(
"ReadType Parameter wrong\n");
1153 if (i_ReturnValue >= 0)
1154 i_ReturnValue = insn->
n;
1198 unsigned char b_ModulNbr,
unsigned char *pb_ChronoStatus)
1201 unsigned int dw_Status;
1207 if (b_ModulNbr < 4) {
1213 dw_MolduleConfiguration[b_ModulNbr] &
1220 s_ModuleInfo[b_ModulNbr].
1221 s_ChronoModuleInfo.b_ChronoInit == 1) {
1224 ui_Address + 8 + (64 * b_ModulNbr));
1230 if ((dw_Status & 8) == 8) {
1235 *pb_ChronoStatus = 3;
1242 if ((dw_Status & 2) == 2) {
1247 *pb_ChronoStatus = 2;
1254 if ((dw_Status & 1) == 1) {
1259 *pb_ChronoStatus = 1;
1266 *pb_ChronoStatus = 0;
1274 DPRINTK(
"Chronometer not initialised\n");
1281 DPRINTK(
"The module is not a Chronometer module\n");
1288 DPRINTK(
"Module number error\n");
1360 unsigned int ui_TimeOut,
unsigned char *pb_ChronoStatus,
unsigned int *pul_ChronoValue)
1363 unsigned int dw_Status;
1364 unsigned int dw_TimeOut = 0;
1370 if (b_ModulNbr < 4) {
1376 dw_MolduleConfiguration[b_ModulNbr] &
1383 s_ModuleInfo[b_ModulNbr].
1384 s_ChronoModuleInfo.b_ChronoInit == 1) {
1389 if (ui_TimeOut <= 65535
UL) {
1406 if ((dw_Status & 8) == 8) {
1411 *pb_ChronoStatus = 3;
1428 outl(0,
devpriv->s_BoardInfos.ui_Address + 36 + (64 * b_ModulNbr));
1438 if ((dw_Status & 2) ==
1463 outl(0,
devpriv->s_BoardInfos.ui_Address + 36 + (64 * b_ModulNbr));
1472 if ((dw_Status & 1) == 1) {
1493 if (dw_TimeOut == ui_TimeOut) {
1515 if (*pb_ChronoStatus == 2) {
1526 if (*pul_ChronoValue != 0) {
1536 if ((*pb_ChronoStatus != 3)
1539 && (ui_TimeOut != 0)) {
1544 *pb_ChronoStatus = 4;
1552 DPRINTK(
"Timeout parameter is wrong\n");
1559 DPRINTK(
"Chronometer not initialised\n");
1566 DPRINTK(
"The module is not a Chronometer module\n");
1573 DPRINTK(
"Module number error\n");
1623 unsigned int ul_ChronoValue,
1624 unsigned int *pul_Hour,
1625 unsigned char *pb_Minute,
1626 unsigned char *pb_Second,
1627 unsigned int *pui_MilliSecond,
unsigned int *pui_MicroSecond,
unsigned int *pui_NanoSecond)
1633 double d_MilliSecond;
1634 double d_MicroSecond;
1635 double d_NanoSecond;
1641 if (b_ModulNbr < 4) {
1647 dw_MolduleConfiguration[b_ModulNbr] &
1654 s_ModuleInfo[b_ModulNbr].
1655 s_ChronoModuleInfo.b_ChronoInit == 1) {
1658 d_Hour = (double)ul_ChronoValue *(
double)
1660 s_ChronoModuleInfo.d_TimingInterval;
1663 s_ModuleInfo[b_ModulNbr].
1664 s_ChronoModuleInfo.b_TimingUnit) {
1666 d_Hour = d_Hour / (double)1000.0;
1669 d_Hour = d_Hour / (double)1000.0;
1672 d_Hour = d_Hour / (double)1000.0;
1675 d_Hour = d_Hour / (double)60.0;
1682 d_Hour = d_Hour / (double)60.0;
1683 *pul_Hour = (
unsigned int) d_Hour;
1689 d_Minute = d_Hour - *pul_Hour;
1690 d_Minute = d_Minute * 60;
1691 *pb_Minute = (
unsigned char) d_Minute;
1697 d_Second = d_Minute - *pb_Minute;
1698 d_Second = d_Second * 60;
1699 *pb_Second = (
unsigned char) d_Second;
1705 d_MilliSecond = d_Second - *pb_Second;
1706 d_MilliSecond = d_MilliSecond * 1000;
1707 *pui_MilliSecond = (
unsigned int) d_MilliSecond;
1716 d_MicroSecond = d_MicroSecond * 1000;
1717 *pui_MicroSecond = (
unsigned int) d_MicroSecond;
1726 d_NanoSecond = d_NanoSecond * 1000;
1727 *pui_NanoSecond = (
unsigned int) d_NanoSecond;
1736 DPRINTK(
"Chronometer not initialised\n");
1743 DPRINTK(
"The module is not a Chronometer module\n");
1750 DPRINTK(
"Module number error\n");
1883 unsigned int dw_Status;
1884 unsigned char *pb_ChannelStatus;
1885 unsigned char *pb_PortValue;
1888 i_ReturnValue = insn->
n;
1889 b_IOType = (
unsigned char) data[0];
1895 if (b_ModulNbr < 4) {
1901 dw_MolduleConfiguration[b_ModulNbr] &
1907 if (
devpriv->s_ModuleInfo[b_ModulNbr].
1908 s_ChronoModuleInfo.b_ChronoInit == 1) {
1918 if (b_OutputChannel <= 2) {
1922 (b_OutputChannel * 4) +
1930 DPRINTK(
"The selected digital output is wrong\n");
1941 if (b_OutputChannel <= 2) {
1945 (b_OutputChannel * 4) +
1953 DPRINTK(
"The selected digital output is wrong\n");
1964 pb_ChannelStatus = (
unsigned char *) &data[0];
1968 if (b_InputChannel <= 2) {
1977 (
unsigned char) (((dw_Status >>
1986 DPRINTK(
"The selected digital input is wrong\n");
1994 pb_PortValue = (
unsigned char *) &data[0];
2002 (
unsigned char) ((dw_Status & 0x7) ^ 7);
2010 DPRINTK(
"Chronometer not initialised\n");
2018 DPRINTK(
"The module is not a Chronometer module\n");
2026 DPRINTK(
"Module number error\n");