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 EEPROM_DIGITALINPUT 0
55 #define EEPROM_DIGITALOUTPUT 1
56 #define EEPROM_ANALOGINPUT 2
57 #define EEPROM_ANALOGOUTPUT 3
58 #define EEPROM_TIMER 4
59 #define EEPROM_WATCHDOG 5
60 #define EEPROM_TIMER_WATCHDOG_COUNTER 10
62 struct str_Functionality {
64 unsigned short w_Address;
67 struct str_MainHeader {
68 unsigned short w_HeaderSize;
69 unsigned char b_Nfunctions;
70 struct str_Functionality s_Functions[7];
73 struct str_DigitalInputHeader {
74 unsigned short w_Nchannel;
75 unsigned char b_Interruptible;
76 unsigned short w_NinterruptLogic;
79 struct str_DigitalOutputHeader {
81 unsigned short w_Nchannel;
85 // used for timer as well as watchdog
87 struct str_TimerDetails {
89 unsigned short w_HeaderSize;
90 unsigned char b_Resolution;
91 unsigned char b_Mode; // in case of Watchdog it is functionality
92 unsigned short w_MinTiming;
93 unsigned char b_TimeBase;
98 unsigned short w_Ntimer;
99 struct str_TimerDetails s_TimerDetails[4]; // supports 4 timers
100 } str_TimerMainHeader;
103 unsigned short w_Nchannel;
104 unsigned char b_Resolution;
105 } str_AnalogOutputHeader;
108 unsigned short w_Nchannel;
109 unsigned short w_MinConvertTiming;
110 unsigned short w_MinDelayTiming;
111 unsigned char b_HasDma;
112 unsigned char b_Resolution;
113 } str_AnalogInputHeader;
115 /*****************************************/
116 /* Read Header Functions */
117 /*****************************************/
119 int i_EepromReadMainHeader(unsigned short w_PCIBoardEepromAddress,
120 char *pc_PCIChipInformation, struct comedi_device *dev);
122 int i_EepromReadDigitalInputHeader(unsigned short w_PCIBoardEepromAddress,
123 char *pc_PCIChipInformation, unsigned short w_Address,
124 struct str_DigitalInputHeader * s_Header);
126 int i_EepromReadDigitalOutputHeader(unsigned short w_PCIBoardEepromAddress,
127 char *pc_PCIChipInformation, unsigned short w_Address,
128 struct str_DigitalOutputHeader * s_Header);
130 int i_EepromReadTimerHeader(unsigned short w_PCIBoardEepromAddress,
131 char *pc_PCIChipInformation, unsigned short w_Address,
132 str_TimerMainHeader * s_Header);
134 int i_EepromReadAnlogOutputHeader(unsigned short w_PCIBoardEepromAddress,
135 char *pc_PCIChipInformation, unsigned short w_Address,
136 str_AnalogOutputHeader * s_Header);
138 int i_EepromReadAnlogInputHeader(unsigned short w_PCIBoardEepromAddress,
139 char *pc_PCIChipInformation, unsigned short w_Address,
140 str_AnalogInputHeader * s_Header);
142 /******************************************/
143 /* Eeprom Specific Functions */
144 /******************************************/
145 unsigned short w_EepromReadWord(unsigned short w_PCIBoardEepromAddress, char *pc_PCIChipInformation,
146 unsigned short w_EepromStartAddress);
147 void v_EepromWaitBusy(unsigned short w_PCIBoardEepromAddress);
148 void v_EepromClock76(unsigned int dw_Address, unsigned int dw_RegisterValue);
149 void v_EepromWaitBusy(unsigned short w_PCIBoardEepromAddress);
150 void v_EepromSendCommand76(unsigned int dw_Address, unsigned int dw_EepromCommand,
151 unsigned char b_DataLengthInBits);
152 void v_EepromCs76Read(unsigned int dw_Address, unsigned short w_offset, unsigned short * pw_Value);
155 +----------------------------------------------------------------------------+
156 | Function Name : unsigned short w_EepromReadWord |
157 | (unsigned short w_PCIBoardEepromAddress, |
158 | char * pc_PCIChipInformation, |
159 | unsigned short w_EepromStartAddress) |
160 +----------------------------------------------------------------------------+
161 | Task : Read from eepromn a word |
162 +----------------------------------------------------------------------------+
163 | Input Parameters : unsigned short w_PCIBoardEepromAddress : PCI eeprom address |
165 | char *pc_PCIChipInformation : PCI Chip Type. |
167 | unsigned short w_EepromStartAddress : Selected eeprom address |
168 +----------------------------------------------------------------------------+
169 | Output Parameters : - |
170 +----------------------------------------------------------------------------+
171 | Return Value : Read word value from eeprom |
172 +----------------------------------------------------------------------------+
175 unsigned short w_EepromReadWord(unsigned short w_PCIBoardEepromAddress, char *pc_PCIChipInformation,
176 unsigned short w_EepromStartAddress)
179 unsigned char b_Counter = 0;
181 unsigned char b_ReadByte = 0;
183 unsigned char b_ReadLowByte = 0;
185 unsigned char b_ReadHighByte = 0;
187 unsigned char b_SelectedAddressLow = 0;
189 unsigned char b_SelectedAddressHigh = 0;
191 unsigned short w_ReadWord = 0;
193 /**************************/
195 /* Test the PCI chip type */
197 /**************************/
199 if ((!strcmp(pc_PCIChipInformation, "S5920")) ||
200 (!strcmp(pc_PCIChipInformation, "S5933")))
203 for (b_Counter = 0; b_Counter < 2; b_Counter++)
206 b_SelectedAddressLow = (w_EepromStartAddress + b_Counter) % 256; //Read the low 8 bit part
208 b_SelectedAddressHigh = (w_EepromStartAddress + b_Counter) / 256; //Read the high 8 bit part
210 /************************************/
212 /* Select the load low address mode */
214 /************************************/
216 outb(NVCMD_LOAD_LOW, w_PCIBoardEepromAddress + 0x3F);
224 v_EepromWaitBusy(w_PCIBoardEepromAddress);
226 /************************/
228 /* Load the low address */
230 /************************/
232 outb(b_SelectedAddressLow,
233 w_PCIBoardEepromAddress + 0x3E);
241 v_EepromWaitBusy(w_PCIBoardEepromAddress);
243 /*************************************/
245 /* Select the load high address mode */
247 /*************************************/
249 outb(NVCMD_LOAD_HIGH, w_PCIBoardEepromAddress + 0x3F);
257 v_EepromWaitBusy(w_PCIBoardEepromAddress);
259 /*************************/
261 /* Load the high address */
263 /*************************/
265 outb(b_SelectedAddressHigh,
266 w_PCIBoardEepromAddress + 0x3E);
274 v_EepromWaitBusy(w_PCIBoardEepromAddress);
276 /************************/
278 /* Select the READ mode */
280 /************************/
282 outb(NVCMD_BEGIN_READ, w_PCIBoardEepromAddress + 0x3F);
290 v_EepromWaitBusy(w_PCIBoardEepromAddress);
292 /*****************************/
294 /* Read data into the EEPROM */
296 /*****************************/
298 b_ReadByte = inb(w_PCIBoardEepromAddress + 0x3E);
306 v_EepromWaitBusy(w_PCIBoardEepromAddress);
308 /*********************************/
310 /* Select the upper address part */
312 /*********************************/
317 b_ReadLowByte = b_ReadByte;
319 } // if(b_Counter==0)
324 b_ReadHighByte = b_ReadByte;
326 } // if(b_Counter==0)
328 } // for (b_Counter=0; b_Counter<2; b_Counter++)
330 w_ReadWord = (b_ReadLowByte | (((unsigned short) b_ReadHighByte) * 256));
332 } // end of if ((!strcmp(pc_PCIChipInformation, "S5920")) || (!strcmp(pc_PCIChipInformation, "S5933")))
334 if (!strcmp(pc_PCIChipInformation, "93C76"))
337 /*************************************/
339 /* Read 16 bit from the EEPROM 93C76 */
341 /*************************************/
343 v_EepromCs76Read(w_PCIBoardEepromAddress, w_EepromStartAddress,
354 +----------------------------------------------------------------------------+
356 | Function Name : void v_EepromWaitBusy |
358 | (unsigned short w_PCIBoardEepromAddress) |
360 +----------------------------------------------------------------------------+
362 | Task : Wait the busy flag from PCI controller |
364 +----------------------------------------------------------------------------+
366 | Input Parameters : unsigned short w_PCIBoardEepromAddress : PCI eeprom base address |
368 +----------------------------------------------------------------------------+
370 | Output Parameters : - |
372 +----------------------------------------------------------------------------+
376 +----------------------------------------------------------------------------+
380 void v_EepromWaitBusy(unsigned short w_PCIBoardEepromAddress)
383 unsigned char b_EepromBusy = 0;
394 /************************************************************************/
396 /* An error has been written in the AMCC 5933 book at the page B-13 */
398 /* Ex: if you read a byte and look for the busy statusEEPROM=0x80 and */
400 /* the operator register is AMCC_OP_REG_MCSR+3 */
402 /* unsigned short read EEPROM=0x8000 andAMCC_OP_REG_MCSR+2 */
404 /* unsigned int read EEPROM=0x80000000 and AMCC_OP_REG_MCSR */
406 /************************************************************************/
408 b_EepromBusy = inb(w_PCIBoardEepromAddress + 0x3F);
409 b_EepromBusy = b_EepromBusy & 0x80;
412 while (b_EepromBusy == 0x80);
418 +---------------------------------------------------------------------------------+
420 | Function Name : void v_EepromClock76(unsigned int dw_Address, |
422 | unsigned int dw_RegisterValue) |
424 +---------------------------------------------------------------------------------+
426 | Task : This function sends the clocking sequence to the EEPROM. |
428 +---------------------------------------------------------------------------------+
430 | Input Parameters : unsigned int dw_Address : PCI eeprom base address |
432 | unsigned int dw_RegisterValue : PCI eeprom register value to write.|
434 +---------------------------------------------------------------------------------+
436 | Output Parameters : - |
438 +---------------------------------------------------------------------------------+
442 +---------------------------------------------------------------------------------+
446 void v_EepromClock76(unsigned int dw_Address, unsigned int dw_RegisterValue)
449 /************************/
451 /* Set EEPROM clock Low */
453 /************************/
455 outl(dw_RegisterValue & 0x6, dw_Address);
465 /*************************/
467 /* Set EEPROM clock High */
469 /*************************/
471 outl(dw_RegisterValue | 0x1, dw_Address);
485 +---------------------------------------------------------------------------------+
487 | Function Name : void v_EepromSendCommand76(unsigned int dw_Address, |
489 | unsigned int dw_EepromCommand, |
491 | unsigned char b_DataLengthInBits) |
493 +---------------------------------------------------------------------------------+
495 | Task : This function sends a Command to the EEPROM 93C76. |
497 +---------------------------------------------------------------------------------+
499 | Input Parameters : unsigned int dw_Address : PCI eeprom base address |
501 | unsigned int dw_EepromCommand : PCI eeprom command to write. |
503 | unsigned char b_DataLengthInBits : PCI eeprom command data length. |
505 +---------------------------------------------------------------------------------+
507 | Output Parameters : - |
509 +---------------------------------------------------------------------------------+
513 +---------------------------------------------------------------------------------+
517 void v_EepromSendCommand76(unsigned int dw_Address, unsigned int dw_EepromCommand,
518 unsigned char b_DataLengthInBits)
523 unsigned int dw_RegisterValue = 0;
525 /*****************************/
527 /* Enable EEPROM Chip Select */
529 /*****************************/
531 dw_RegisterValue = 0x2;
533 /********************************************************************/
535 /* Toggle EEPROM's Chip select to get it out of Shift Register Mode */
537 /********************************************************************/
539 outl(dw_RegisterValue, dw_Address);
549 /*******************************************/
551 /* Send EEPROM command - one bit at a time */
553 /*******************************************/
555 for (c_BitPos = (b_DataLengthInBits - 1); c_BitPos >= 0; c_BitPos--)
558 /**********************************/
560 /* Check if current bit is 0 or 1 */
562 /**********************************/
564 if (dw_EepromCommand & (1 << c_BitPos))
573 dw_RegisterValue = dw_RegisterValue | 0x4;
586 dw_RegisterValue = dw_RegisterValue & 0x3;
590 /*********************/
592 /* Write the command */
594 /*********************/
596 outl(dw_RegisterValue, dw_Address);
606 /****************************/
608 /* Trigger the EEPROM clock */
610 /****************************/
612 v_EepromClock76(dw_Address, dw_RegisterValue);
620 +---------------------------------------------------------------------------------+
622 | Function Name : void v_EepromCs76Read(unsigned int dw_Address, |
624 | unsigned short w_offset, |
626 | unsigned short * pw_Value) |
628 +---------------------------------------------------------------------------------+
630 | Task : This function read a value from the EEPROM 93C76. |
632 +---------------------------------------------------------------------------------+
634 | Input Parameters : unsigned int dw_Address : PCI eeprom base address |
636 | unsigned short w_offset : Offset of the adress to read |
638 | unsigned short * pw_Value : PCI eeprom 16 bit read value. |
640 +---------------------------------------------------------------------------------+
642 | Output Parameters : - |
644 +---------------------------------------------------------------------------------+
648 +---------------------------------------------------------------------------------+
652 void v_EepromCs76Read(unsigned int dw_Address, unsigned short w_offset, unsigned short * pw_Value)
657 unsigned int dw_RegisterValue = 0;
659 unsigned int dw_RegisterValueRead = 0;
661 /*************************************************/
663 /* Send EEPROM read command and offset to EEPROM */
665 /*************************************************/
667 v_EepromSendCommand76(dw_Address, (EE_READ << 4) | (w_offset / 2),
670 /*******************************/
672 /* Get the last register value */
674 /*******************************/
676 dw_RegisterValue = (((w_offset / 2) & 0x1) << 2) | 0x2;
678 /*****************************/
680 /* Set the 16-bit value of 0 */
682 /*****************************/
686 /************************/
688 /* Get the 16-bit value */
690 /************************/
692 for (c_BitPos = 0; c_BitPos < 16; c_BitPos++)
695 /****************************/
697 /* Trigger the EEPROM clock */
699 /****************************/
701 v_EepromClock76(dw_Address, dw_RegisterValue);
703 /**********************/
705 /* Get the result bit */
707 /**********************/
709 dw_RegisterValueRead = inl(dw_Address);
719 /***************************************/
721 /* Get bit value and shift into result */
723 /***************************************/
725 if (dw_RegisterValueRead & 0x8)
734 *pw_Value = (*pw_Value << 1) | 0x1;
747 *pw_Value = (*pw_Value << 1);
753 /*************************/
755 /* Clear all EEPROM bits */
757 /*************************/
759 dw_RegisterValue = 0x0;
761 /********************************************************************/
763 /* Toggle EEPROM's Chip select to get it out of Shift Register Mode */
765 /********************************************************************/
767 outl(dw_RegisterValue, dw_Address);
779 /******************************************/
780 /* EEPROM HEADER READ FUNCTIONS */
781 /******************************************/
784 +----------------------------------------------------------------------------+
785 | Function Name : int i_EepromReadMainHeader(unsigned short w_PCIBoardEepromAddress, |
786 | char * pc_PCIChipInformation,struct comedi_device *dev) |
787 +----------------------------------------------------------------------------+
788 | Task : Read from eeprom Main Header |
789 +----------------------------------------------------------------------------+
790 | Input Parameters : unsigned short w_PCIBoardEepromAddress : PCI eeprom address |
792 | char *pc_PCIChipInformation : PCI Chip Type. |
794 | struct comedi_device *dev : comedi device structure |
796 +----------------------------------------------------------------------------+
797 | Output Parameters : - |
798 +----------------------------------------------------------------------------+
800 +----------------------------------------------------------------------------+
803 int i_EepromReadMainHeader(unsigned short w_PCIBoardEepromAddress,
804 char *pc_PCIChipInformation, struct comedi_device *dev)
806 unsigned short w_Temp, i, w_Count = 0;
807 unsigned int ui_Temp;
808 struct str_MainHeader s_MainHeader;
809 struct str_DigitalInputHeader s_DigitalInputHeader;
810 struct str_DigitalOutputHeader s_DigitalOutputHeader;
811 //str_TimerMainHeader s_TimerMainHeader,s_WatchdogMainHeader;
812 str_AnalogOutputHeader s_AnalogOutputHeader;
813 str_AnalogInputHeader s_AnalogInputHeader;
816 s_MainHeader.w_HeaderSize =
817 w_EepromReadWord(w_PCIBoardEepromAddress, pc_PCIChipInformation,
820 // Read nbr of functionality
821 w_Temp = w_EepromReadWord(w_PCIBoardEepromAddress,
822 pc_PCIChipInformation, 0x100 + 10);
823 s_MainHeader.b_Nfunctions = (unsigned char) w_Temp & 0x00FF;
825 // Read functionality details
826 for (i = 0; i < s_MainHeader.b_Nfunctions; i++) {
828 w_Temp = w_EepromReadWord(w_PCIBoardEepromAddress,
829 pc_PCIChipInformation, 0x100 + 12 + w_Count);
830 s_MainHeader.s_Functions[i].b_Type = (unsigned char) w_Temp & 0x3F;
831 w_Count = w_Count + 2;
833 s_MainHeader.s_Functions[i].w_Address =
834 w_EepromReadWord(w_PCIBoardEepromAddress,
835 pc_PCIChipInformation, 0x100 + 12 + w_Count);
836 w_Count = w_Count + 2;
839 // Display main header info
840 for (i = 0; i < s_MainHeader.b_Nfunctions; i++) {
842 switch (s_MainHeader.s_Functions[i].b_Type) {
843 case EEPROM_DIGITALINPUT:
844 i_EepromReadDigitalInputHeader(w_PCIBoardEepromAddress,
845 pc_PCIChipInformation,
846 s_MainHeader.s_Functions[i].w_Address,
847 &s_DigitalInputHeader);
848 this_board->i_NbrDiChannel =
849 s_DigitalInputHeader.w_Nchannel;
852 case EEPROM_DIGITALOUTPUT:
853 i_EepromReadDigitalOutputHeader(w_PCIBoardEepromAddress,
854 pc_PCIChipInformation,
855 s_MainHeader.s_Functions[i].w_Address,
856 &s_DigitalOutputHeader);
857 this_board->i_NbrDoChannel =
858 s_DigitalOutputHeader.w_Nchannel;
859 ui_Temp = 0xffffffff;
860 this_board->i_DoMaxdata =
861 ui_Temp >> (32 - this_board->i_NbrDoChannel);
864 case EEPROM_ANALOGINPUT:
865 i_EepromReadAnlogInputHeader(w_PCIBoardEepromAddress,
866 pc_PCIChipInformation,
867 s_MainHeader.s_Functions[i].w_Address,
868 &s_AnalogInputHeader);
869 if (!(strcmp(this_board->pc_DriverName, "apci3200")))
870 this_board->i_NbrAiChannel =
871 s_AnalogInputHeader.w_Nchannel * 4;
873 this_board->i_NbrAiChannel =
874 s_AnalogInputHeader.w_Nchannel;
875 this_board->i_Dma = s_AnalogInputHeader.b_HasDma;
876 this_board->ui_MinAcquisitiontimeNs =
877 (unsigned int) s_AnalogInputHeader.w_MinConvertTiming *
879 this_board->ui_MinDelaytimeNs =
880 (unsigned int) s_AnalogInputHeader.w_MinDelayTiming *
883 this_board->i_AiMaxdata =
885 s_AnalogInputHeader.b_Resolution);
888 case EEPROM_ANALOGOUTPUT:
889 i_EepromReadAnlogOutputHeader(w_PCIBoardEepromAddress,
890 pc_PCIChipInformation,
891 s_MainHeader.s_Functions[i].w_Address,
892 &s_AnalogOutputHeader);
893 this_board->i_NbrAoChannel =
894 s_AnalogOutputHeader.w_Nchannel;
896 this_board->i_AoMaxdata =
898 s_AnalogOutputHeader.b_Resolution);
902 this_board->i_Timer = 1; //Timer subdevice present
905 case EEPROM_WATCHDOG:
906 this_board->i_Timer = 1; //Timer subdevice present
909 case EEPROM_TIMER_WATCHDOG_COUNTER:
910 this_board->i_Timer = 1; //Timer subdevice present
918 +----------------------------------------------------------------------------+
919 | Function Name : int i_EepromReadDigitalInputHeader(unsigned short |
920 | w_PCIBoardEepromAddress,char *pc_PCIChipInformation, |
921 | unsigned short w_Address,struct str_DigitalInputHeader *s_Header) |
923 +----------------------------------------------------------------------------+
924 | Task : Read Digital Input Header |
925 +----------------------------------------------------------------------------+
926 | Input Parameters : unsigned short w_PCIBoardEepromAddress : PCI eeprom address |
928 | char *pc_PCIChipInformation : PCI Chip Type. |
930 | struct str_DigitalInputHeader *s_Header: Digita Input Header |
932 +----------------------------------------------------------------------------+
933 | Output Parameters : - |
934 +----------------------------------------------------------------------------+
936 +----------------------------------------------------------------------------+
938 int i_EepromReadDigitalInputHeader(unsigned short w_PCIBoardEepromAddress,
939 char *pc_PCIChipInformation, unsigned short w_Address,
940 struct str_DigitalInputHeader *s_Header)
942 unsigned short w_Temp;
944 // read nbr of channels
945 s_Header->w_Nchannel =
946 w_EepromReadWord(w_PCIBoardEepromAddress, pc_PCIChipInformation,
947 0x100 + w_Address + 6);
949 // interruptible or not
950 w_Temp = w_EepromReadWord(w_PCIBoardEepromAddress,
951 pc_PCIChipInformation, 0x100 + w_Address + 8);
952 s_Header->b_Interruptible = (unsigned char) (w_Temp >> 7) & 0x01;
954 // How many interruptible logic
955 s_Header->w_NinterruptLogic =
956 w_EepromReadWord(w_PCIBoardEepromAddress, pc_PCIChipInformation,
957 0x100 + w_Address + 10);
963 +----------------------------------------------------------------------------+
964 | Function Name : int i_EepromReadDigitalOutputHeader(unsigned short |
965 | w_PCIBoardEepromAddress,char *pc_PCIChipInformation, |
966 | unsigned short w_Address,struct str_DigitalOutputHeader *s_Header) |
968 +----------------------------------------------------------------------------+
969 | Task : Read Digital Output Header |
970 +----------------------------------------------------------------------------+
971 | Input Parameters : unsigned short w_PCIBoardEepromAddress : PCI eeprom address |
973 | char *pc_PCIChipInformation : PCI Chip Type. |
975 | struct str_DigitalOutputHeader *s_Header: Digital Output Header|
977 +----------------------------------------------------------------------------+
978 | Output Parameters : - |
979 +----------------------------------------------------------------------------+
981 +----------------------------------------------------------------------------+
983 int i_EepromReadDigitalOutputHeader(unsigned short w_PCIBoardEepromAddress,
984 char *pc_PCIChipInformation, unsigned short w_Address,
985 struct str_DigitalOutputHeader * s_Header)
988 s_Header->w_Nchannel =
989 w_EepromReadWord(w_PCIBoardEepromAddress, pc_PCIChipInformation,
990 0x100 + w_Address + 6);
995 +----------------------------------------------------------------------------+
996 | Function Name : int i_EepromReadTimerHeader(unsigned short w_PCIBoardEepromAddress, |
997 | char *pc_PCIChipInformation,WORD w_Address, |
998 | str_TimerMainHeader *s_Header) |
999 +----------------------------------------------------------------------------+
1000 | Task : Read Timer or Watchdog Header |
1001 +----------------------------------------------------------------------------+
1002 | Input Parameters : unsigned short w_PCIBoardEepromAddress : PCI eeprom address |
1004 | char *pc_PCIChipInformation : PCI Chip Type. |
1006 | str_TimerMainHeader *s_Header: Timer Header |
1008 +----------------------------------------------------------------------------+
1009 | Output Parameters : - |
1010 +----------------------------------------------------------------------------+
1011 | Return Value : 0 |
1012 +----------------------------------------------------------------------------+
1014 int i_EepromReadTimerHeader(unsigned short w_PCIBoardEepromAddress,
1015 char *pc_PCIChipInformation, unsigned short w_Address,
1016 str_TimerMainHeader * s_Header)
1019 unsigned short i, w_Size = 0, w_Temp;
1022 s_Header->w_Ntimer =
1023 w_EepromReadWord(w_PCIBoardEepromAddress, pc_PCIChipInformation,
1024 0x100 + w_Address + 6);
1027 for (i = 0; i < s_Header->w_Ntimer; i++) {
1028 s_Header->s_TimerDetails[i].w_HeaderSize =
1029 w_EepromReadWord(w_PCIBoardEepromAddress,
1030 pc_PCIChipInformation,
1031 0x100 + w_Address + 8 + w_Size + 0);
1032 w_Temp = w_EepromReadWord(w_PCIBoardEepromAddress,
1033 pc_PCIChipInformation,
1034 0x100 + w_Address + 8 + w_Size + 2);
1037 s_Header->s_TimerDetails[i].b_Resolution =
1038 (unsigned char) (w_Temp >> 10) & 0x3F;
1041 s_Header->s_TimerDetails[i].b_Mode =
1042 (unsigned char) (w_Temp >> 4) & 0x3F;
1044 w_Temp = w_EepromReadWord(w_PCIBoardEepromAddress,
1045 pc_PCIChipInformation,
1046 0x100 + w_Address + 8 + w_Size + 4);
1049 s_Header->s_TimerDetails[i].w_MinTiming = (w_Temp >> 6) & 0x3FF;
1052 s_Header->s_TimerDetails[i].b_TimeBase = (unsigned char) (w_Temp) & 0x3F;
1053 w_Size += s_Header->s_TimerDetails[i].w_HeaderSize;
1060 +----------------------------------------------------------------------------+
1061 | Function Name : int i_EepromReadAnlogOutputHeader(unsigned short |
1062 | w_PCIBoardEepromAddress,char *pc_PCIChipInformation, |
1063 | unsigned short w_Address,str_AnalogOutputHeader *s_Header) |
1064 +----------------------------------------------------------------------------+
1065 | Task : Read Nalog Output Header |
1066 +----------------------------------------------------------------------------+
1067 | Input Parameters : unsigned short w_PCIBoardEepromAddress : PCI eeprom address |
1069 | char *pc_PCIChipInformation : PCI Chip Type. |
1071 | str_AnalogOutputHeader *s_Header:Anlog Output Header |
1073 +----------------------------------------------------------------------------+
1074 | Output Parameters : - |
1075 +----------------------------------------------------------------------------+
1076 | Return Value : 0 |
1077 +----------------------------------------------------------------------------+
1080 int i_EepromReadAnlogOutputHeader(unsigned short w_PCIBoardEepromAddress,
1081 char *pc_PCIChipInformation, unsigned short w_Address,
1082 str_AnalogOutputHeader * s_Header)
1084 unsigned short w_Temp;
1085 // No of channels for 1st hard component
1086 w_Temp = w_EepromReadWord(w_PCIBoardEepromAddress,
1087 pc_PCIChipInformation, 0x100 + w_Address + 10);
1088 s_Header->w_Nchannel = (w_Temp >> 4) & 0x03FF;
1089 // Resolution for 1st hard component
1090 w_Temp = w_EepromReadWord(w_PCIBoardEepromAddress,
1091 pc_PCIChipInformation, 0x100 + w_Address + 16);
1092 s_Header->b_Resolution = (unsigned char) (w_Temp >> 8) & 0xFF;
1097 +----------------------------------------------------------------------------+
1098 | Function Name : int i_EepromReadAnlogInputHeader(unsigned short |
1099 | w_PCIBoardEepromAddress,char *pc_PCIChipInformation, |
1100 | unsigned short w_Address,str_AnalogInputHeader *s_Header) |
1101 +----------------------------------------------------------------------------+
1102 | Task : Read Nalog Output Header |
1103 +----------------------------------------------------------------------------+
1104 | Input Parameters : unsigned short w_PCIBoardEepromAddress : PCI eeprom address |
1106 | char *pc_PCIChipInformation : PCI Chip Type. |
1108 | str_AnalogInputHeader *s_Header:Anlog Input Header |
1110 +----------------------------------------------------------------------------+
1111 | Output Parameters : - |
1112 +----------------------------------------------------------------------------+
1113 | Return Value : 0 |
1114 +----------------------------------------------------------------------------+
1117 // Reads only for ONE hardware component
1118 int i_EepromReadAnlogInputHeader(unsigned short w_PCIBoardEepromAddress,
1119 char *pc_PCIChipInformation, unsigned short w_Address,
1120 str_AnalogInputHeader * s_Header)
1122 unsigned short w_Temp, w_Offset;
1123 w_Temp = w_EepromReadWord(w_PCIBoardEepromAddress,
1124 pc_PCIChipInformation, 0x100 + w_Address + 10);
1125 s_Header->w_Nchannel = (w_Temp >> 4) & 0x03FF;
1126 s_Header->w_MinConvertTiming =
1127 w_EepromReadWord(w_PCIBoardEepromAddress, pc_PCIChipInformation,
1128 0x100 + w_Address + 16);
1129 s_Header->w_MinDelayTiming =
1130 w_EepromReadWord(w_PCIBoardEepromAddress, pc_PCIChipInformation,
1131 0x100 + w_Address + 30);
1132 w_Temp = w_EepromReadWord(w_PCIBoardEepromAddress,
1133 pc_PCIChipInformation, 0x100 + w_Address + 20);
1134 s_Header->b_HasDma = (w_Temp >> 13) & 0x01; // whether dma present or not
1136 w_Temp = w_EepromReadWord(w_PCIBoardEepromAddress, pc_PCIChipInformation, 0x100 + w_Address + 72); // reading Y
1137 w_Temp = w_Temp & 0x00FF;
1140 w_Offset = 74 + (2 * w_Temp) + (10 * (1 + (w_Temp / 16))); // offset of first analog input single header
1141 w_Offset = w_Offset + 2; // resolution
1145 w_Offset = w_Offset + 2; // resolution
1149 w_Temp = w_EepromReadWord(w_PCIBoardEepromAddress,
1150 pc_PCIChipInformation, 0x100 + w_Address + w_Offset);
1151 s_Header->b_Resolution = w_Temp & 0x001F; // last 5 bits