Example #1
0
int i_EepromReadMainHeader(unsigned short w_PCIBoardEepromAddress,
                           char *pc_PCIChipInformation, struct comedi_device *dev)
{
    unsigned short w_Temp, i, w_Count = 0;
    unsigned int ui_Temp;
    struct str_MainHeader s_MainHeader;
    struct str_DigitalInputHeader s_DigitalInputHeader;
    struct str_DigitalOutputHeader s_DigitalOutputHeader;
    /* struct str_TimerMainHeader     s_TimerMainHeader,s_WatchdogMainHeader; */
    str_AnalogOutputHeader s_AnalogOutputHeader;
    struct str_AnalogInputHeader s_AnalogInputHeader;

    /* Read size */
    s_MainHeader.w_HeaderSize =
        w_EepromReadWord(w_PCIBoardEepromAddress, pc_PCIChipInformation,
                         0x100 + 8);

    /* Read nbr of functionality */
    w_Temp = w_EepromReadWord(w_PCIBoardEepromAddress,
                              pc_PCIChipInformation, 0x100 + 10);
    s_MainHeader.b_Nfunctions = (unsigned char) w_Temp & 0x00FF;

    /* Read functionality details */
    for (i = 0; i < s_MainHeader.b_Nfunctions; i++) {
        /* Read Type */
        w_Temp = w_EepromReadWord(w_PCIBoardEepromAddress,
                                  pc_PCIChipInformation, 0x100 + 12 + w_Count);
        s_MainHeader.s_Functions[i].b_Type = (unsigned char) w_Temp & 0x3F;
        w_Count = w_Count + 2;
        /* Read Address */
        s_MainHeader.s_Functions[i].w_Address =
            w_EepromReadWord(w_PCIBoardEepromAddress,
                             pc_PCIChipInformation, 0x100 + 12 + w_Count);
        w_Count = w_Count + 2;
    }

    /* Display main header info */
    for (i = 0; i < s_MainHeader.b_Nfunctions; i++) {

        switch (s_MainHeader.s_Functions[i].b_Type) {
        case EEPROM_DIGITALINPUT:
            i_EepromReadDigitalInputHeader(w_PCIBoardEepromAddress,
                                           pc_PCIChipInformation,
                                           s_MainHeader.s_Functions[i].w_Address,
                                           &s_DigitalInputHeader);
            this_board->i_NbrDiChannel =
                s_DigitalInputHeader.w_Nchannel;
            break;

        case EEPROM_DIGITALOUTPUT:
            i_EepromReadDigitalOutputHeader(w_PCIBoardEepromAddress,
                                            pc_PCIChipInformation,
                                            s_MainHeader.s_Functions[i].w_Address,
                                            &s_DigitalOutputHeader);
            this_board->i_NbrDoChannel =
                s_DigitalOutputHeader.w_Nchannel;
            ui_Temp = 0xffffffff;
            this_board->i_DoMaxdata =
                ui_Temp >> (32 - this_board->i_NbrDoChannel);
            break;

        case EEPROM_ANALOGINPUT:
            i_EepromReadAnlogInputHeader(w_PCIBoardEepromAddress,
                                         pc_PCIChipInformation,
                                         s_MainHeader.s_Functions[i].w_Address,
                                         &s_AnalogInputHeader);
            if (!(strcmp(this_board->pc_DriverName, "apci3200")))
                this_board->i_NbrAiChannel =
                    s_AnalogInputHeader.w_Nchannel * 4;
            else
                this_board->i_NbrAiChannel =
                    s_AnalogInputHeader.w_Nchannel;
            this_board->i_Dma = s_AnalogInputHeader.b_HasDma;
            this_board->ui_MinAcquisitiontimeNs =
                (unsigned int) s_AnalogInputHeader.w_MinConvertTiming *
                1000;
            this_board->ui_MinDelaytimeNs =
                (unsigned int) s_AnalogInputHeader.w_MinDelayTiming *
                1000;
            ui_Temp = 0xffff;
            this_board->i_AiMaxdata =
                ui_Temp >> (16 -
                            s_AnalogInputHeader.b_Resolution);
            break;

        case EEPROM_ANALOGOUTPUT:
            i_EepromReadAnlogOutputHeader(w_PCIBoardEepromAddress,
                                          pc_PCIChipInformation,
                                          s_MainHeader.s_Functions[i].w_Address,
                                          &s_AnalogOutputHeader);
            this_board->i_NbrAoChannel =
                s_AnalogOutputHeader.w_Nchannel;
            ui_Temp = 0xffff;
            this_board->i_AoMaxdata =
                ui_Temp >> (16 -
                            s_AnalogOutputHeader.b_Resolution);
            break;

        case EEPROM_TIMER:
            this_board->i_Timer = 1;	/* Timer subdevice present */
            break;

        case EEPROM_WATCHDOG:
            this_board->i_Timer = 1;	/* Timer subdevice present */
            break;

        case EEPROM_TIMER_WATCHDOG_COUNTER:
            this_board->i_Timer = 1;	/* Timer subdevice present */
        }
    }

    return 0;
}
int i_EepromReadMainHeader(unsigned short w_PCIBoardEepromAddress,
                           char *pc_PCIChipInformation, struct comedi_device *dev)
{
    unsigned short w_Temp, i, w_Count = 0;
    unsigned int ui_Temp;
    struct str_MainHeader s_MainHeader;
    struct str_DigitalInputHeader s_DigitalInputHeader;
    struct str_DigitalOutputHeader s_DigitalOutputHeader;

    struct str_AnalogOutputHeader s_AnalogOutputHeader;
    struct str_AnalogInputHeader s_AnalogInputHeader;


    s_MainHeader.w_HeaderSize =
        w_EepromReadWord(w_PCIBoardEepromAddress, pc_PCIChipInformation,
                         0x100 + 8);


    w_Temp = w_EepromReadWord(w_PCIBoardEepromAddress,
                              pc_PCIChipInformation, 0x100 + 10);
    s_MainHeader.b_Nfunctions = (unsigned char) w_Temp & 0x00FF;


    for (i = 0; i < s_MainHeader.b_Nfunctions; i++) {

        w_Temp = w_EepromReadWord(w_PCIBoardEepromAddress,
                                  pc_PCIChipInformation, 0x100 + 12 + w_Count);
        s_MainHeader.s_Functions[i].b_Type = (unsigned char) w_Temp & 0x3F;
        w_Count = w_Count + 2;

        s_MainHeader.s_Functions[i].w_Address =
            w_EepromReadWord(w_PCIBoardEepromAddress,
                             pc_PCIChipInformation, 0x100 + 12 + w_Count);
        w_Count = w_Count + 2;
    }


    for (i = 0; i < s_MainHeader.b_Nfunctions; i++) {

        switch (s_MainHeader.s_Functions[i].b_Type) {
        case EEPROM_DIGITALINPUT:
            i_EepromReadDigitalInputHeader(w_PCIBoardEepromAddress,
                                           pc_PCIChipInformation,
                                           s_MainHeader.s_Functions[i].w_Address,
                                           &s_DigitalInputHeader);
            devpriv->s_EeParameters.i_NbrDiChannel =
                s_DigitalInputHeader.w_Nchannel;
            break;

        case EEPROM_DIGITALOUTPUT:
            i_EepromReadDigitalOutputHeader(w_PCIBoardEepromAddress,
                                            pc_PCIChipInformation,
                                            s_MainHeader.s_Functions[i].w_Address,
                                            &s_DigitalOutputHeader);
            devpriv->s_EeParameters.i_NbrDoChannel =
                s_DigitalOutputHeader.w_Nchannel;
            ui_Temp = 0xffffffff;
            devpriv->s_EeParameters.i_DoMaxdata =
                ui_Temp >> (32 -
                            devpriv->s_EeParameters.i_NbrDoChannel);
            break;

        case EEPROM_ANALOGINPUT:
            i_EepromReadAnlogInputHeader(w_PCIBoardEepromAddress,
                                         pc_PCIChipInformation,
                                         s_MainHeader.s_Functions[i].w_Address,
                                         &s_AnalogInputHeader);
            if (!(strcmp(this_board->pc_DriverName, "apci3200")))
                devpriv->s_EeParameters.i_NbrAiChannel =
                    s_AnalogInputHeader.w_Nchannel * 4;
            else
                devpriv->s_EeParameters.i_NbrAiChannel =
                    s_AnalogInputHeader.w_Nchannel;
            devpriv->s_EeParameters.i_Dma =
                s_AnalogInputHeader.b_HasDma;
            devpriv->s_EeParameters.ui_MinAcquisitiontimeNs =
                (unsigned int) s_AnalogInputHeader.w_MinConvertTiming *
                1000;
            devpriv->s_EeParameters.ui_MinDelaytimeNs =
                (unsigned int) s_AnalogInputHeader.w_MinDelayTiming *
                1000;
            ui_Temp = 0xffff;
            devpriv->s_EeParameters.i_AiMaxdata =
                ui_Temp >> (16 -
                            s_AnalogInputHeader.b_Resolution);
            break;

        case EEPROM_ANALOGOUTPUT:
            i_EepromReadAnlogOutputHeader(w_PCIBoardEepromAddress,
                                          pc_PCIChipInformation,
                                          s_MainHeader.s_Functions[i].w_Address,
                                          &s_AnalogOutputHeader);
            devpriv->s_EeParameters.i_NbrAoChannel =
                s_AnalogOutputHeader.w_Nchannel;
            ui_Temp = 0xffff;
            devpriv->s_EeParameters.i_AoMaxdata =
                ui_Temp >> (16 -
                            s_AnalogOutputHeader.b_Resolution);
            break;

        case EEPROM_TIMER:

            devpriv->s_EeParameters.i_Timer = 1;
            break;

        case EEPROM_WATCHDOG:

            devpriv->s_EeParameters.i_Timer = 1;
            break;

        case EEPROM_TIMER_WATCHDOG_COUNTER:

            devpriv->s_EeParameters.i_Timer = 1;
            break;
        }
    }

    return 0;
}