This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

XIO2001 I2C control under windows

Other Parts Discussed in Thread: XIO2001

Hi there

We have implemented an IO card function based on the XIO2001 using the I2C bus controller.

Do you have source code examples showing how to access the I2C control registers under windows (32 or 64 bit)

Alan

  • Hello Alan,

     

    Unfortunately we have no source code examples we can provide; although I just found a code snippet that I hope can help to clarify the process in case you have any doubts.

     

    Example: Write a value of 0x55 to address 0x00 on an I2C EEPROM which slave address is 0xA0

     

    I2C Write Byte

     

    // Write the address to register offset 0xB1

    WritePciByte(Local_Device.BUS_NUMBER, Local_Device.DEVICE_NUMBER, 0, 0xB1, 0x00)

     

    // Write the data to register offset 0xB0

    WritePciByte(Local_Device.BUS_NUMBER, Local_Device.DEVICE_NUMBER, 0, 0xB0, 0x55)

     

    // Write the device’s slave address and write command to register offset 0xB2

    WritePciByte(Local_Device.BUS_NUMBER, Local_Device.DEVICE_NUMBER, 0, 0xB2, 0xA0)

     

                    Where

    • WritePciByte(PCI Bus Number, PCI Device Number, PCI Function Number, Register Offset, Data);

     

    Example:  Read back the data written on the previous example

     

    I2C Read Byte

     

                    Byte ROM_Busy_Counter = 0

     

                    // Write the address to register offset 0xB1

                   WritePciByte(Local_Device.BUS_NUMBER, Local_Device.DEVICE_NUMBER, 0, 0xB1, 0x00)

     

                    // Write the device’s slave address and read command to register offset 0xB2

                    WritePciByte(Local_Device.BUS_NUMBER, Local_Device.DEVICE_NUMBER, 0, 0xB2, 0xA1)

     

     

                    // Wait for EEPROM to come ready

                    Do

    {

    ROM_Busy_Counter ++

     

                                    If ( ROM_Busy_Counter >= 50 )

                                    {

                                                    Print("EEPROM BUSY TIMEOUT REACHED!");

                                                    break;

                                    }

    } while ( REQBUSY() == true )

     

                    // Check for errors

                    If (SB_ERR() )

                        // There was a read error. Data is not valid.

                        Data_Returned = -1

                    Else

                        Data_Returned = ReadPciByte(Local_Device.BUS_NUMBER, Local_Device.DEVICE_NUMBER, 0, 0xB0)

                  

                    Where

     

    • ReadPciByte(PCI Bus Number, PCI Device Number, PCI Function Number, Register Offset);

     

    • Bool REQBUSY()

                    {

                                    Byte Busy_Register = ReadPciByte(Local_Device.BUS_NUMBER, Local_Device.DEVICE_NUMBER, 0, 0xB3)

     

                                    If ( (Busy_Register && 0x20) == 0x20 )

                                    {

                                                    // EEPROM busy. Wait a bit.

                                                    mS_Wait(0.4)

                                                    return True

    }

                                    else

                                                    return False                                       

                    }

     

    • Bool SB_ERR()

                    {

                                    Byte Error_Register = ReadPciByte(Local_Device.BUS_NUMBER, Local_Device.DEVICE_NUMBER, 0, 0xB3)

     

                                    If ( (Error_Register && 0x02) == 0x02 )                                                                  

                                                    return True

                                    else

                                                    return False                                       

                    }

  • Thanks for the snippet - I will pass it on to our softies..

  • Feed back from the software

    They understood the general task structure, and agreed it was OK, however they queried the calls

    ReadPciByte(Local_Device.BUS_NUMBER, Local_Device.DEVICE_NUMBER, 0, 0xB0)

    writePciByte(Local_Device.BUS_NUMBER, Local_Device.DEVICE_NUMBER, 0, 0xB0)


    Are these part of a Windows library or a third party library?

    They have Googled both calls and could not find any libraries that referenced these two calls, ReadPciByte() or WritePciByte().

    Separately and possibly related

    The topHAT package provided with the development board had a dll called

    HardwareAcess.dll - do you know where this comes from?


    many thanks
  • HardwareAcess.dll is a TI internal library that calls a custom kernel driver performing reads and writes to the PCI bus configuration space.

    Unfortunately this library or the driver cannot be distributed and source code cannot be provided.

    Your software guys will have to figure out how to perform standard PCI read and write operations

    msdn.microsoft.com/.../ff536890(v=vs.85).aspx