4 Copyright (C) 2004,2005 ADDI-DATA GmbH for the source code of this module.
10 Fax: +49(0)7223/9493-92
11 http://www.addi-data-com
14 This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
16 This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 You shoud also find the complete GPL in the COPYING file accompanying this source code.
26 +-----------------------------------------------------------------------+
27 | (C) ADDI-DATA GmbH Dieselstrasse 3 D-77833 Ottersweier |
28 +-----------------------------------------------------------------------+
29 | Tel : +49 (0) 7223/9493-0 | email : info@addi-data.com |
30 | Fax : +49 (0) 7223/9493-92 | Internet : http://www.addi-data.com |
31 +-----------------------------------------------------------------------+
32 | Project : ADDI DATA | Compiler : GCC |
33 | Modulname : addi_eeprom.c | Version : 2.96 |
34 +-------------------------------+---------------------------------------+
35 | Project manager: Eric Stolz | Date : 02/12/2002 |
36 +-----------------------------------------------------------------------+
37 | Description : ADDI EEPROM Module |
38 +-----------------------------------------------------------------------+
40 +-----------------------------------------------------------------------+
41 | Date | Author | Description of updates |
42 +----------+-----------+------------------------------------------------+
45 +----------+-----------+------------------------------------------------+
48 #define NVCMD_BEGIN_READ (0x7 << 5 ) // nvRam begin read command
49 #define NVCMD_LOAD_LOW (0x4 << 5 ) // nvRam load low command
50 #define NVCMD_LOAD_HIGH (0x5 << 5 ) // nvRam load high command
51 #define EE76_CMD_LEN 13 // bits in instructions
52 #define EE_READ 0x0180 // 01 1000 0000 read instruction
54 #define WORD unsigned short
55 #define PWORD unsigned short *
56 #define PDWORD unsigned int *
59 #define DWORD unsigned int
62 #define EEPROM_DIGITALINPUT 0
63 #define EEPROM_DIGITALOUTPUT 1
64 #define EEPROM_ANALOGINPUT 2
65 #define EEPROM_ANALOGOUTPUT 3
66 #define EEPROM_TIMER 4
67 #define EEPROM_WATCHDOG 5
68 #define EEPROM_TIMER_WATCHDOG_COUNTER 10
70 struct str_Functionality {
78 struct str_Functionality s_Functions[7];
84 WORD w_NinterruptLogic;
85 } str_DigitalInputHeader;
89 } str_DigitalOutputHeader;
91 // used for timer as well as watchdog
96 BYTE b_Mode; // in case of Watchdog it is functionality
103 str_TimerDetails s_TimerDetails[4]; // supports 4 timers
104 } str_TimerMainHeader;
109 } str_AnalogOutputHeader;
113 WORD w_MinConvertTiming;
114 WORD w_MinDelayTiming;
117 } str_AnalogInputHeader;
119 /*****************************************/
120 /* Read Header Functions */
121 /*****************************************/
123 INT i_EepromReadMainHeader(WORD w_PCIBoardEepromAddress,
124 PCHAR pc_PCIChipInformation, struct comedi_device *dev);
126 INT i_EepromReadDigitalInputHeader(WORD w_PCIBoardEepromAddress,
127 PCHAR pc_PCIChipInformation, WORD w_Address,
128 str_DigitalInputHeader * s_Header);
130 INT i_EepromReadDigitalOutputHeader(WORD w_PCIBoardEepromAddress,
131 PCHAR pc_PCIChipInformation, WORD w_Address,
132 str_DigitalOutputHeader * s_Header);
134 INT i_EepromReadTimerHeader(WORD w_PCIBoardEepromAddress,
135 PCHAR pc_PCIChipInformation, WORD w_Address,
136 str_TimerMainHeader * s_Header);
138 INT i_EepromReadAnlogOutputHeader(WORD w_PCIBoardEepromAddress,
139 PCHAR pc_PCIChipInformation, WORD w_Address,
140 str_AnalogOutputHeader * s_Header);
142 INT i_EepromReadAnlogInputHeader(WORD w_PCIBoardEepromAddress,
143 PCHAR pc_PCIChipInformation, WORD w_Address,
144 str_AnalogInputHeader * s_Header);
146 /******************************************/
147 /* Eeprom Specific Functions */
148 /******************************************/
149 WORD w_EepromReadWord(WORD w_PCIBoardEepromAddress, PCHAR pc_PCIChipInformation,
150 WORD w_EepromStartAddress);
151 VOID v_EepromWaitBusy(WORD w_PCIBoardEepromAddress);
152 VOID v_EepromClock76(DWORD dw_Address, DWORD dw_RegisterValue);
153 VOID v_EepromWaitBusy(WORD w_PCIBoardEepromAddress);
154 VOID v_EepromSendCommand76(DWORD dw_Address, DWORD dw_EepromCommand,
155 BYTE b_DataLengthInBits);
156 VOID v_EepromCs76Read(DWORD dw_Address, WORD w_offset, PWORD pw_Value);
159 +----------------------------------------------------------------------------+
160 | Function Name : WORD w_EepromReadWord |
161 | (WORD w_PCIBoardEepromAddress, |
162 | PCHAR pc_PCIChipInformation, |
163 | WORD w_EepromStartAddress) |
164 +----------------------------------------------------------------------------+
165 | Task : Read from eepromn a word |
166 +----------------------------------------------------------------------------+
167 | Input Parameters : WORD w_PCIBoardEepromAddress : PCI eeprom address |
169 | PCHAR pc_PCIChipInformation : PCI Chip Type. |
171 | WORD w_EepromStartAddress : Selected eeprom address |
172 +----------------------------------------------------------------------------+
173 | Output Parameters : - |
174 +----------------------------------------------------------------------------+
175 | Return Value : Read word value from eeprom |
176 +----------------------------------------------------------------------------+
179 WORD w_EepromReadWord(WORD w_PCIBoardEepromAddress, PCHAR pc_PCIChipInformation,
180 WORD w_EepromStartAddress)
187 BYTE b_ReadLowByte = 0;
189 BYTE b_ReadHighByte = 0;
191 BYTE b_SelectedAddressLow = 0;
193 BYTE b_SelectedAddressHigh = 0;
197 /**************************/
199 /* Test the PCI chip type */
201 /**************************/
203 if ((!strcmp(pc_PCIChipInformation, "S5920")) ||
204 (!strcmp(pc_PCIChipInformation, "S5933")))
207 for (b_Counter = 0; b_Counter < 2; b_Counter++)
210 b_SelectedAddressLow = (w_EepromStartAddress + b_Counter) % 256; //Read the low 8 bit part
212 b_SelectedAddressHigh = (w_EepromStartAddress + b_Counter) / 256; //Read the high 8 bit part
214 /************************************/
216 /* Select the load low address mode */
218 /************************************/
220 outb(NVCMD_LOAD_LOW, w_PCIBoardEepromAddress + 0x3F);
228 v_EepromWaitBusy(w_PCIBoardEepromAddress);
230 /************************/
232 /* Load the low address */
234 /************************/
236 outb(b_SelectedAddressLow,
237 w_PCIBoardEepromAddress + 0x3E);
245 v_EepromWaitBusy(w_PCIBoardEepromAddress);
247 /*************************************/
249 /* Select the load high address mode */
251 /*************************************/
253 outb(NVCMD_LOAD_HIGH, w_PCIBoardEepromAddress + 0x3F);
261 v_EepromWaitBusy(w_PCIBoardEepromAddress);
263 /*************************/
265 /* Load the high address */
267 /*************************/
269 outb(b_SelectedAddressHigh,
270 w_PCIBoardEepromAddress + 0x3E);
278 v_EepromWaitBusy(w_PCIBoardEepromAddress);
280 /************************/
282 /* Select the READ mode */
284 /************************/
286 outb(NVCMD_BEGIN_READ, w_PCIBoardEepromAddress + 0x3F);
294 v_EepromWaitBusy(w_PCIBoardEepromAddress);
296 /*****************************/
298 /* Read data into the EEPROM */
300 /*****************************/
302 b_ReadByte = inb(w_PCIBoardEepromAddress + 0x3E);
310 v_EepromWaitBusy(w_PCIBoardEepromAddress);
312 /*********************************/
314 /* Select the upper address part */
316 /*********************************/
321 b_ReadLowByte = b_ReadByte;
323 } // if(b_Counter==0)
328 b_ReadHighByte = b_ReadByte;
330 } // if(b_Counter==0)
332 } // for (b_Counter=0; b_Counter<2; b_Counter++)
334 w_ReadWord = (b_ReadLowByte | (((WORD) b_ReadHighByte) * 256));
336 } // end of if ((!strcmp(pc_PCIChipInformation, "S5920")) || (!strcmp(pc_PCIChipInformation, "S5933")))
338 if (!strcmp(pc_PCIChipInformation, "93C76"))
341 /*************************************/
343 /* Read 16 bit from the EEPROM 93C76 */
345 /*************************************/
347 v_EepromCs76Read(w_PCIBoardEepromAddress, w_EepromStartAddress,
358 +----------------------------------------------------------------------------+
360 | Function Name : VOID v_EepromWaitBusy |
362 | (WORD w_PCIBoardEepromAddress) |
364 +----------------------------------------------------------------------------+
366 | Task : Wait the busy flag from PCI controller |
368 +----------------------------------------------------------------------------+
370 | Input Parameters : WORD w_PCIBoardEepromAddress : PCI eeprom base address |
372 +----------------------------------------------------------------------------+
374 | Output Parameters : - |
376 +----------------------------------------------------------------------------+
380 +----------------------------------------------------------------------------+
384 VOID v_EepromWaitBusy(WORD w_PCIBoardEepromAddress)
387 BYTE b_EepromBusy = 0;
398 /************************************************************************/
400 /* An error has been written in the AMCC 5933 book at the page B-13 */
402 /* Ex: if you read a byte and look for the busy statusEEPROM=0x80 and */
404 /* the operator register is AMCC_OP_REG_MCSR+3 */
406 /* WORD read EEPROM=0x8000 andAMCC_OP_REG_MCSR+2 */
408 /* DWORD read EEPROM=0x80000000 and AMCC_OP_REG_MCSR */
410 /************************************************************************/
412 b_EepromBusy = inb(w_PCIBoardEepromAddress + 0x3F);
413 b_EepromBusy = b_EepromBusy & 0x80;
416 while (b_EepromBusy == 0x80);
422 +---------------------------------------------------------------------------------+
424 | Function Name : VOID v_EepromClock76(DWORD dw_Address, |
426 | DWORD dw_RegisterValue) |
428 +---------------------------------------------------------------------------------+
430 | Task : This function sends the clocking sequence to the EEPROM. |
432 +---------------------------------------------------------------------------------+
434 | Input Parameters : DWORD dw_Address : PCI eeprom base address |
436 | DWORD dw_RegisterValue : PCI eeprom register value to write.|
438 +---------------------------------------------------------------------------------+
440 | Output Parameters : - |
442 +---------------------------------------------------------------------------------+
446 +---------------------------------------------------------------------------------+
450 VOID v_EepromClock76(DWORD dw_Address, DWORD dw_RegisterValue)
453 /************************/
455 /* Set EEPROM clock Low */
457 /************************/
459 outl(dw_RegisterValue & 0x6, dw_Address);
469 /*************************/
471 /* Set EEPROM clock High */
473 /*************************/
475 outl(dw_RegisterValue | 0x1, dw_Address);
489 +---------------------------------------------------------------------------------+
491 | Function Name : VOID v_EepromSendCommand76(DWORD dw_Address, |
493 | DWORD dw_EepromCommand, |
495 | BYTE b_DataLengthInBits) |
497 +---------------------------------------------------------------------------------+
499 | Task : This function sends a Command to the EEPROM 93C76. |
501 +---------------------------------------------------------------------------------+
503 | Input Parameters : DWORD dw_Address : PCI eeprom base address |
505 | DWORD dw_EepromCommand : PCI eeprom command to write. |
507 | BYTE b_DataLengthInBits : PCI eeprom command data length. |
509 +---------------------------------------------------------------------------------+
511 | Output Parameters : - |
513 +---------------------------------------------------------------------------------+
517 +---------------------------------------------------------------------------------+
521 VOID v_EepromSendCommand76(DWORD dw_Address, DWORD dw_EepromCommand,
522 BYTE b_DataLengthInBits)
527 DWORD dw_RegisterValue = 0;
529 /*****************************/
531 /* Enable EEPROM Chip Select */
533 /*****************************/
535 dw_RegisterValue = 0x2;
537 /********************************************************************/
539 /* Toggle EEPROM's Chip select to get it out of Shift Register Mode */
541 /********************************************************************/
543 outl(dw_RegisterValue, dw_Address);
553 /*******************************************/
555 /* Send EEPROM command - one bit at a time */
557 /*******************************************/
559 for (c_BitPos = (b_DataLengthInBits - 1); c_BitPos >= 0; c_BitPos--)
562 /**********************************/
564 /* Check if current bit is 0 or 1 */
566 /**********************************/
568 if (dw_EepromCommand & (1 << c_BitPos))
577 dw_RegisterValue = dw_RegisterValue | 0x4;
590 dw_RegisterValue = dw_RegisterValue & 0x3;
594 /*********************/
596 /* Write the command */
598 /*********************/
600 outl(dw_RegisterValue, dw_Address);
610 /****************************/
612 /* Trigger the EEPROM clock */
614 /****************************/
616 v_EepromClock76(dw_Address, dw_RegisterValue);
624 +---------------------------------------------------------------------------------+
626 | Function Name : VOID v_EepromCs76Read(DWORD dw_Address, |
632 +---------------------------------------------------------------------------------+
634 | Task : This function read a value from the EEPROM 93C76. |
636 +---------------------------------------------------------------------------------+
638 | Input Parameters : DWORD dw_Address : PCI eeprom base address |
640 | WORD w_offset : Offset of the adress to read |
642 | PWORD pw_Value : PCI eeprom 16 bit read value. |
644 +---------------------------------------------------------------------------------+
646 | Output Parameters : - |
648 +---------------------------------------------------------------------------------+
652 +---------------------------------------------------------------------------------+
656 VOID v_EepromCs76Read(DWORD dw_Address, WORD w_offset, PWORD pw_Value)
661 DWORD dw_RegisterValue = 0;
663 DWORD dw_RegisterValueRead = 0;
665 /*************************************************/
667 /* Send EEPROM read command and offset to EEPROM */
669 /*************************************************/
671 v_EepromSendCommand76(dw_Address, (EE_READ << 4) | (w_offset / 2),
674 /*******************************/
676 /* Get the last register value */
678 /*******************************/
680 dw_RegisterValue = (((w_offset / 2) & 0x1) << 2) | 0x2;
682 /*****************************/
684 /* Set the 16-bit value of 0 */
686 /*****************************/
690 /************************/
692 /* Get the 16-bit value */
694 /************************/
696 for (c_BitPos = 0; c_BitPos < 16; c_BitPos++)
699 /****************************/
701 /* Trigger the EEPROM clock */
703 /****************************/
705 v_EepromClock76(dw_Address, dw_RegisterValue);
707 /**********************/
709 /* Get the result bit */
711 /**********************/
713 dw_RegisterValueRead = inl(dw_Address);
723 /***************************************/
725 /* Get bit value and shift into result */
727 /***************************************/
729 if (dw_RegisterValueRead & 0x8)
738 *pw_Value = (*pw_Value << 1) | 0x1;
751 *pw_Value = (*pw_Value << 1);
757 /*************************/
759 /* Clear all EEPROM bits */
761 /*************************/
763 dw_RegisterValue = 0x0;
765 /********************************************************************/
767 /* Toggle EEPROM's Chip select to get it out of Shift Register Mode */
769 /********************************************************************/
771 outl(dw_RegisterValue, dw_Address);
783 /******************************************/
784 /* EEPROM HEADER READ FUNCTIONS */
785 /******************************************/
788 +----------------------------------------------------------------------------+
789 | Function Name : INT i_EepromReadMainHeader(WORD w_PCIBoardEepromAddress, |
790 | PCHAR pc_PCIChipInformation,struct comedi_device *dev) |
791 +----------------------------------------------------------------------------+
792 | Task : Read from eeprom Main Header |
793 +----------------------------------------------------------------------------+
794 | Input Parameters : WORD w_PCIBoardEepromAddress : PCI eeprom address |
796 | PCHAR pc_PCIChipInformation : PCI Chip Type. |
798 | struct comedi_device *dev : comedi device structure |
800 +----------------------------------------------------------------------------+
801 | Output Parameters : - |
802 +----------------------------------------------------------------------------+
804 +----------------------------------------------------------------------------+
807 INT i_EepromReadMainHeader(WORD w_PCIBoardEepromAddress,
808 PCHAR pc_PCIChipInformation, struct comedi_device *dev)
810 WORD w_Temp, i, w_Count = 0;
812 str_MainHeader s_MainHeader;
813 str_DigitalInputHeader s_DigitalInputHeader;
814 str_DigitalOutputHeader s_DigitalOutputHeader;
815 //str_TimerMainHeader s_TimerMainHeader,s_WatchdogMainHeader;
816 str_AnalogOutputHeader s_AnalogOutputHeader;
817 str_AnalogInputHeader s_AnalogInputHeader;
820 s_MainHeader.w_HeaderSize =
821 w_EepromReadWord(w_PCIBoardEepromAddress, pc_PCIChipInformation,
824 // Read nbr of functionality
825 w_Temp = w_EepromReadWord(w_PCIBoardEepromAddress,
826 pc_PCIChipInformation, 0x100 + 10);
827 s_MainHeader.b_Nfunctions = (BYTE) w_Temp & 0x00FF;
829 // Read functionality details
830 for (i = 0; i < s_MainHeader.b_Nfunctions; i++) {
832 w_Temp = w_EepromReadWord(w_PCIBoardEepromAddress,
833 pc_PCIChipInformation, 0x100 + 12 + w_Count);
834 s_MainHeader.s_Functions[i].b_Type = (BYTE) w_Temp & 0x3F;
835 w_Count = w_Count + 2;
837 s_MainHeader.s_Functions[i].w_Address =
838 w_EepromReadWord(w_PCIBoardEepromAddress,
839 pc_PCIChipInformation, 0x100 + 12 + w_Count);
840 w_Count = w_Count + 2;
843 // Display main header info
844 for (i = 0; i < s_MainHeader.b_Nfunctions; i++) {
846 switch (s_MainHeader.s_Functions[i].b_Type) {
847 case EEPROM_DIGITALINPUT:
848 i_EepromReadDigitalInputHeader(w_PCIBoardEepromAddress,
849 pc_PCIChipInformation,
850 s_MainHeader.s_Functions[i].w_Address,
851 &s_DigitalInputHeader);
852 this_board->i_NbrDiChannel =
853 s_DigitalInputHeader.w_Nchannel;
856 case EEPROM_DIGITALOUTPUT:
857 i_EepromReadDigitalOutputHeader(w_PCIBoardEepromAddress,
858 pc_PCIChipInformation,
859 s_MainHeader.s_Functions[i].w_Address,
860 &s_DigitalOutputHeader);
861 this_board->i_NbrDoChannel =
862 s_DigitalOutputHeader.w_Nchannel;
863 ui_Temp = 0xffffffff;
864 this_board->i_DoMaxdata =
865 ui_Temp >> (32 - this_board->i_NbrDoChannel);
868 case EEPROM_ANALOGINPUT:
869 i_EepromReadAnlogInputHeader(w_PCIBoardEepromAddress,
870 pc_PCIChipInformation,
871 s_MainHeader.s_Functions[i].w_Address,
872 &s_AnalogInputHeader);
873 if (!(strcmp(this_board->pc_DriverName, "apci3200")))
874 this_board->i_NbrAiChannel =
875 s_AnalogInputHeader.w_Nchannel * 4;
877 this_board->i_NbrAiChannel =
878 s_AnalogInputHeader.w_Nchannel;
879 this_board->i_Dma = s_AnalogInputHeader.b_HasDma;
880 this_board->ui_MinAcquisitiontimeNs =
881 (UINT) s_AnalogInputHeader.w_MinConvertTiming *
883 this_board->ui_MinDelaytimeNs =
884 (UINT) s_AnalogInputHeader.w_MinDelayTiming *
887 this_board->i_AiMaxdata =
889 s_AnalogInputHeader.b_Resolution);
892 case EEPROM_ANALOGOUTPUT:
893 i_EepromReadAnlogOutputHeader(w_PCIBoardEepromAddress,
894 pc_PCIChipInformation,
895 s_MainHeader.s_Functions[i].w_Address,
896 &s_AnalogOutputHeader);
897 this_board->i_NbrAoChannel =
898 s_AnalogOutputHeader.w_Nchannel;
900 this_board->i_AoMaxdata =
902 s_AnalogOutputHeader.b_Resolution);
906 this_board->i_Timer = 1; //Timer subdevice present
909 case EEPROM_WATCHDOG:
910 this_board->i_Timer = 1; //Timer subdevice present
913 case EEPROM_TIMER_WATCHDOG_COUNTER:
914 this_board->i_Timer = 1; //Timer subdevice present
922 +----------------------------------------------------------------------------+
923 | Function Name : INT i_EepromReadDigitalInputHeader(WORD |
924 | w_PCIBoardEepromAddress,PCHAR pc_PCIChipInformation, |
925 | WORD w_Address,str_DigitalInputHeader *s_Header) |
927 +----------------------------------------------------------------------------+
928 | Task : Read Digital Input Header |
929 +----------------------------------------------------------------------------+
930 | Input Parameters : WORD w_PCIBoardEepromAddress : PCI eeprom address |
932 | PCHAR pc_PCIChipInformation : PCI Chip Type. |
934 | str_DigitalInputHeader *s_Header: Digita Input Header |
936 +----------------------------------------------------------------------------+
937 | Output Parameters : - |
938 +----------------------------------------------------------------------------+
940 +----------------------------------------------------------------------------+
942 INT i_EepromReadDigitalInputHeader(WORD w_PCIBoardEepromAddress,
943 PCHAR pc_PCIChipInformation, WORD w_Address,
944 str_DigitalInputHeader * s_Header)
948 // read nbr of channels
949 s_Header->w_Nchannel =
950 w_EepromReadWord(w_PCIBoardEepromAddress, pc_PCIChipInformation,
951 0x100 + w_Address + 6);
953 // interruptible or not
954 w_Temp = w_EepromReadWord(w_PCIBoardEepromAddress,
955 pc_PCIChipInformation, 0x100 + w_Address + 8);
956 s_Header->b_Interruptible = (BYTE) (w_Temp >> 7) & 0x01;
958 // How many interruptible logic
959 s_Header->w_NinterruptLogic =
960 w_EepromReadWord(w_PCIBoardEepromAddress, pc_PCIChipInformation,
961 0x100 + w_Address + 10);
967 +----------------------------------------------------------------------------+
968 | Function Name : INT i_EepromReadDigitalOutputHeader(WORD |
969 | w_PCIBoardEepromAddress,PCHAR pc_PCIChipInformation, |
970 | WORD w_Address,str_DigitalOutputHeader *s_Header) |
972 +----------------------------------------------------------------------------+
973 | Task : Read Digital Output Header |
974 +----------------------------------------------------------------------------+
975 | Input Parameters : WORD w_PCIBoardEepromAddress : PCI eeprom address |
977 | PCHAR pc_PCIChipInformation : PCI Chip Type. |
979 | str_DigitalOutputHeader *s_Header: Digital Output Header|
981 +----------------------------------------------------------------------------+
982 | Output Parameters : - |
983 +----------------------------------------------------------------------------+
985 +----------------------------------------------------------------------------+
987 INT i_EepromReadDigitalOutputHeader(WORD w_PCIBoardEepromAddress,
988 PCHAR pc_PCIChipInformation, WORD w_Address,
989 str_DigitalOutputHeader * s_Header)
992 s_Header->w_Nchannel =
993 w_EepromReadWord(w_PCIBoardEepromAddress, pc_PCIChipInformation,
994 0x100 + w_Address + 6);
999 +----------------------------------------------------------------------------+
1000 | Function Name : INT i_EepromReadTimerHeader(WORD w_PCIBoardEepromAddress, |
1001 | PCHAR pc_PCIChipInformation,WORD w_Address, |
1002 | str_TimerMainHeader *s_Header) |
1003 +----------------------------------------------------------------------------+
1004 | Task : Read Timer or Watchdog Header |
1005 +----------------------------------------------------------------------------+
1006 | Input Parameters : WORD w_PCIBoardEepromAddress : PCI eeprom address |
1008 | PCHAR pc_PCIChipInformation : PCI Chip Type. |
1010 | str_TimerMainHeader *s_Header: Timer Header |
1012 +----------------------------------------------------------------------------+
1013 | Output Parameters : - |
1014 +----------------------------------------------------------------------------+
1015 | Return Value : 0 |
1016 +----------------------------------------------------------------------------+
1018 INT i_EepromReadTimerHeader(WORD w_PCIBoardEepromAddress,
1019 PCHAR pc_PCIChipInformation, WORD w_Address,
1020 str_TimerMainHeader * s_Header)
1023 WORD i, w_Size = 0, w_Temp;
1026 s_Header->w_Ntimer =
1027 w_EepromReadWord(w_PCIBoardEepromAddress, pc_PCIChipInformation,
1028 0x100 + w_Address + 6);
1031 for (i = 0; i < s_Header->w_Ntimer; i++) {
1032 s_Header->s_TimerDetails[i].w_HeaderSize =
1033 w_EepromReadWord(w_PCIBoardEepromAddress,
1034 pc_PCIChipInformation,
1035 0x100 + w_Address + 8 + w_Size + 0);
1036 w_Temp = w_EepromReadWord(w_PCIBoardEepromAddress,
1037 pc_PCIChipInformation,
1038 0x100 + w_Address + 8 + w_Size + 2);
1041 s_Header->s_TimerDetails[i].b_Resolution =
1042 (BYTE) (w_Temp >> 10) & 0x3F;
1045 s_Header->s_TimerDetails[i].b_Mode =
1046 (BYTE) (w_Temp >> 4) & 0x3F;
1048 w_Temp = w_EepromReadWord(w_PCIBoardEepromAddress,
1049 pc_PCIChipInformation,
1050 0x100 + w_Address + 8 + w_Size + 4);
1053 s_Header->s_TimerDetails[i].w_MinTiming = (w_Temp >> 6) & 0x3FF;
1056 s_Header->s_TimerDetails[i].b_TimeBase = (BYTE) (w_Temp) & 0x3F;
1057 w_Size += s_Header->s_TimerDetails[i].w_HeaderSize;
1064 +----------------------------------------------------------------------------+
1065 | Function Name : INT i_EepromReadAnlogOutputHeader(WORD |
1066 | w_PCIBoardEepromAddress,PCHAR pc_PCIChipInformation, |
1067 | WORD w_Address,str_AnalogOutputHeader *s_Header) |
1068 +----------------------------------------------------------------------------+
1069 | Task : Read Nalog Output Header |
1070 +----------------------------------------------------------------------------+
1071 | Input Parameters : WORD w_PCIBoardEepromAddress : PCI eeprom address |
1073 | PCHAR pc_PCIChipInformation : PCI Chip Type. |
1075 | str_AnalogOutputHeader *s_Header:Anlog Output Header |
1077 +----------------------------------------------------------------------------+
1078 | Output Parameters : - |
1079 +----------------------------------------------------------------------------+
1080 | Return Value : 0 |
1081 +----------------------------------------------------------------------------+
1084 INT i_EepromReadAnlogOutputHeader(WORD w_PCIBoardEepromAddress,
1085 PCHAR pc_PCIChipInformation, WORD w_Address,
1086 str_AnalogOutputHeader * s_Header)
1089 // No of channels for 1st hard component
1090 w_Temp = w_EepromReadWord(w_PCIBoardEepromAddress,
1091 pc_PCIChipInformation, 0x100 + w_Address + 10);
1092 s_Header->w_Nchannel = (w_Temp >> 4) & 0x03FF;
1093 // Resolution for 1st hard component
1094 w_Temp = w_EepromReadWord(w_PCIBoardEepromAddress,
1095 pc_PCIChipInformation, 0x100 + w_Address + 16);
1096 s_Header->b_Resolution = (BYTE) (w_Temp >> 8) & 0xFF;
1101 +----------------------------------------------------------------------------+
1102 | Function Name : INT i_EepromReadAnlogInputHeader(WORD |
1103 | w_PCIBoardEepromAddress,PCHAR pc_PCIChipInformation, |
1104 | WORD w_Address,str_AnalogInputHeader *s_Header) |
1105 +----------------------------------------------------------------------------+
1106 | Task : Read Nalog Output Header |
1107 +----------------------------------------------------------------------------+
1108 | Input Parameters : WORD w_PCIBoardEepromAddress : PCI eeprom address |
1110 | PCHAR pc_PCIChipInformation : PCI Chip Type. |
1112 | str_AnalogInputHeader *s_Header:Anlog Input Header |
1114 +----------------------------------------------------------------------------+
1115 | Output Parameters : - |
1116 +----------------------------------------------------------------------------+
1117 | Return Value : 0 |
1118 +----------------------------------------------------------------------------+
1121 // Reads only for ONE hardware component
1122 INT i_EepromReadAnlogInputHeader(WORD w_PCIBoardEepromAddress,
1123 PCHAR pc_PCIChipInformation, WORD w_Address,
1124 str_AnalogInputHeader * s_Header)
1126 WORD w_Temp, w_Offset;
1127 w_Temp = w_EepromReadWord(w_PCIBoardEepromAddress,
1128 pc_PCIChipInformation, 0x100 + w_Address + 10);
1129 s_Header->w_Nchannel = (w_Temp >> 4) & 0x03FF;
1130 s_Header->w_MinConvertTiming =
1131 w_EepromReadWord(w_PCIBoardEepromAddress, pc_PCIChipInformation,
1132 0x100 + w_Address + 16);
1133 s_Header->w_MinDelayTiming =
1134 w_EepromReadWord(w_PCIBoardEepromAddress, pc_PCIChipInformation,
1135 0x100 + w_Address + 30);
1136 w_Temp = w_EepromReadWord(w_PCIBoardEepromAddress,
1137 pc_PCIChipInformation, 0x100 + w_Address + 20);
1138 s_Header->b_HasDma = (w_Temp >> 13) & 0x01; // whether dma present or not
1140 w_Temp = w_EepromReadWord(w_PCIBoardEepromAddress, pc_PCIChipInformation, 0x100 + w_Address + 72); // reading Y
1141 w_Temp = w_Temp & 0x00FF;
1144 w_Offset = 74 + (2 * w_Temp) + (10 * (1 + (w_Temp / 16))); // offset of first analog input single header
1145 w_Offset = w_Offset + 2; // resolution
1149 w_Offset = w_Offset + 2; // resolution
1153 w_Temp = w_EepromReadWord(w_PCIBoardEepromAddress,
1154 pc_PCIChipInformation, 0x100 + w_Address + w_Offset);
1155 s_Header->b_Resolution = w_Temp & 0x001F; // last 5 bits