none
unable to find the I2C API definition in BSP RRS feed

  • Question

  • Hello,

            I am writing I2C application in wince7. I used the following  API's like WriteFile , ReadFile, SetFilepointer in my application. If try to go definition of  this API's by using right click on API and select " Go to definition " its showing

    prototype only not definition of that API. How to find the definition of this API's in BSP. I have also searched all these API's but I am unable to see. What is the appropriate way to find the API's???

    Wednesday, March 18, 2015 10:24 AM

Answers

  •  What is the appropriate way to find the API's???

    The answer really is that there is no standard API for I2C, so the appropriate way is to contact your vendor.  If you vendor has provided an I2C driver, then they should also provide documentation on how to use it.

    Bruce Eitman (eMVP) Senior Engineer Bruce.Eitman AT Eurotech DOT com My BLOG http://geekswithblogs.net/bruceeitman Eurotech Inc. www.Eurotech.com

    • Marked as answer by vamsikolla Thursday, March 19, 2015 10:07 AM
    Wednesday, March 18, 2015 1:51 PM
    Moderator
  • Dear Developer's

    Greetings!!

    Vamsi, ReadFile, WriteFile, SetFilePointer is not an API's. These are system defined function and there is a difference between functions and API's.

    I have an example of I2C application and in that application, there is a use of SetFilePointer function as

    SetFilePointer(hI2C, subaddr, NULL, FILE_BEGIN);

    But when I click on the function, the controller jumped to the winbase.h header file as

    WINBASEAPI
    DWORD
    WINAPI
    SetFilePointer(
        HANDLE hFile,
        LONG lDistanceToMove,
        PLONG lpDistanceToMoveHigh,
        DWORD dwMoveMethod
        );
    

    and I am sure that same thing is happening in your case???

    • Marked as answer by vamsikolla Thursday, March 19, 2015 10:08 AM
    Thursday, March 19, 2015 4:34 AM
  • Check SetFilePointer and XXX_Seek links.

    You will be able to map these arguments.

    SetFilePointer

    This function moves the file pointer of an open file.

    DWORD SetFilePointer( 
      HANDLE hFile, 
      LONG lDistanceToMove, 
      PLONG lpDistanceToMoveHigh, 
      DWORD dwMoveMethod
    ); 
    

    Parameters

    hFile
    [in] Handle to the file whose file pointer is to be moved. The file handle must have been created with GENERIC_READ or GENERIC_WRITE access to the file.
    lDistanceToMove
    Low-order 32 bits of a signed value that specifies the number of bytes to move the file pointer. A positive value for lDistanceToMove moves the file pointer forward in the file, and a negative value moves the file pointer backward. Note that you cannot use a negative value to move back past beyond the beginning of a file.
    lpDistanceToMoveHigh
    Not supported; must be NULL or point to a value of zero.
    dwMoveMethod
    [in] Starting point for the file pointer move. The following table shows possible values for this parameter.
    Value Description
    FILE_BEGIN Indicates that the starting point is zero or the beginning of the file.
    FILE_CURRENT Indicates that the starting point is the current value of the file pointer.
    FILE_END Indicates that the starting point is the current EOF position.

    XXX_Seek

    This function moves the data pointer in the device.

    DWORD XXX_Seek(
      DWORD hOpenContext,
      long Amount,
      WORD Type 
    );
    

    Parameters

    hOpenContext
    [in] Handle to the open context of the device. The XXX_Open (Device Manager) function creates and returns this identifier.
    Amount
    [in] Number of bytes to move the data pointer in the device. A positive value moves the data pointer toward the end of the file and a negative value moves it toward the beginning.
    Type
    [in] Starting point for the data pointer. The following table shows the available values for this parameter.
    Value Description
    FILE_BEGIN Indicates that the starting point is zero or the beginning of the file.
    FILE_CURRENT Indicates that the current value of the file pointer is the starting point.
    FILE_END Indicates that the current end-of-file position is the starting point.
    • Marked as answer by vamsikolla Thursday, March 19, 2015 10:08 AM
    Thursday, March 19, 2015 5:58 AM

All replies

  •  What is the appropriate way to find the API's???

    The answer really is that there is no standard API for I2C, so the appropriate way is to contact your vendor.  If you vendor has provided an I2C driver, then they should also provide documentation on how to use it.

    Bruce Eitman (eMVP) Senior Engineer Bruce.Eitman AT Eurotech DOT com My BLOG http://geekswithblogs.net/bruceeitman Eurotech Inc. www.Eurotech.com

    • Marked as answer by vamsikolla Thursday, March 19, 2015 10:07 AM
    Wednesday, March 18, 2015 1:51 PM
    Moderator
  • Dear Developer's

    Greetings!!

    Vamsi, ReadFile, WriteFile, SetFilePointer is not an API's. These are system defined function and there is a difference between functions and API's.

    I have an example of I2C application and in that application, there is a use of SetFilePointer function as

    SetFilePointer(hI2C, subaddr, NULL, FILE_BEGIN);

    But when I click on the function, the controller jumped to the winbase.h header file as

    WINBASEAPI
    DWORD
    WINAPI
    SetFilePointer(
        HANDLE hFile,
        LONG lDistanceToMove,
        PLONG lpDistanceToMoveHigh,
        DWORD dwMoveMethod
        );
    

    and I am sure that same thing is happening in your case???

    • Marked as answer by vamsikolla Thursday, March 19, 2015 10:08 AM
    Thursday, March 19, 2015 4:34 AM
  • Your I2C driver is stream driver. So from application, you are using file IO functions for accessing the driver functions.

    So, mapping will be like:

    CreateFile -> XXX_Open

    ReadFile -> XXX_Read

    WriteFile -> XXX_Write

    SetFilePointer-> XXX_Seek

    Where XXX is prefix.. like I2C_Read. Check your I2C driver or it's registry entry to find what is exact prefix for your driver.

    • Proposed as answer by Keshava GN Thursday, March 19, 2015 5:59 AM
    Thursday, March 19, 2015 5:02 AM
  • Yes, Partap the prototype of the SetFilePointer is  SetFilePointer(hI2C, subaddr, NULL, FILE_BEGIN);

    and the same function I am using from my application and here second argument is subaddr. But when I searched it on google I got

    DWORD WINAPI SetFilePointer( _In_         HANDLE hFile, _In_         LONG lDistanceToMove, _Inout_opt_  PLONG lpDistanceToMoveHigh, _In_         DWORD dwMoveMethod );

    As, you mentioned in you comment. But here the second argument is some thing else

    Keshava, I agree with your point and know the mapping of ReadFile and WriteFile but I was not aware about SetFilePointer with XXX_seek

    So, when I searched my driver I found I2C_Seek function as

    BOOL I2C_Seek(DWORD context, long  amount, WORD  type)

    I have added some retailmsg statements and while running the application I am getting the printf statements

    But here it has 3 arguments and in SetFilePointer Function have 4 arguments So, I am confused about this?????



    Thursday, March 19, 2015 5:46 AM
  • Check SetFilePointer and XXX_Seek links.

    You will be able to map these arguments.

    SetFilePointer

    This function moves the file pointer of an open file.

    DWORD SetFilePointer( 
      HANDLE hFile, 
      LONG lDistanceToMove, 
      PLONG lpDistanceToMoveHigh, 
      DWORD dwMoveMethod
    ); 
    

    Parameters

    hFile
    [in] Handle to the file whose file pointer is to be moved. The file handle must have been created with GENERIC_READ or GENERIC_WRITE access to the file.
    lDistanceToMove
    Low-order 32 bits of a signed value that specifies the number of bytes to move the file pointer. A positive value for lDistanceToMove moves the file pointer forward in the file, and a negative value moves the file pointer backward. Note that you cannot use a negative value to move back past beyond the beginning of a file.
    lpDistanceToMoveHigh
    Not supported; must be NULL or point to a value of zero.
    dwMoveMethod
    [in] Starting point for the file pointer move. The following table shows possible values for this parameter.
    Value Description
    FILE_BEGIN Indicates that the starting point is zero or the beginning of the file.
    FILE_CURRENT Indicates that the starting point is the current value of the file pointer.
    FILE_END Indicates that the starting point is the current EOF position.

    XXX_Seek

    This function moves the data pointer in the device.

    DWORD XXX_Seek(
      DWORD hOpenContext,
      long Amount,
      WORD Type 
    );
    

    Parameters

    hOpenContext
    [in] Handle to the open context of the device. The XXX_Open (Device Manager) function creates and returns this identifier.
    Amount
    [in] Number of bytes to move the data pointer in the device. A positive value moves the data pointer toward the end of the file and a negative value moves it toward the beginning.
    Type
    [in] Starting point for the data pointer. The following table shows the available values for this parameter.
    Value Description
    FILE_BEGIN Indicates that the starting point is zero or the beginning of the file.
    FILE_CURRENT Indicates that the current value of the file pointer is the starting point.
    FILE_END Indicates that the current end-of-file position is the starting point.
    • Marked as answer by vamsikolla Thursday, March 19, 2015 10:08 AM
    Thursday, March 19, 2015 5:58 AM
  • Dear Developers,

    GNKeshava,

    My case is also similar to Vamsi, We are passing second argument as the sub address of the slave device. Sub address means the register address in the selected slave. but it is mapped with the XXX_Seek 

    long Amount

    Can you give some clarity on this

    As, per the conversation I understand that what actually Vamsi is looking for?

    I think so what I asked to you, he is on doubt for the same thing

    ??

    Thursday, March 19, 2015 6:10 AM
  • LONG lDistanceToMove

    is mapped to

    long Amount

    I cant understand what is confusing thing here.

    But confusing thing for me is why you are passing second argument as the sub address of the slave device.

    Anyway, this entirely depends on your requirement, your driver XXX_Seek function implementation and your application code.

    Thursday, March 19, 2015 6:23 AM
  • I took reference from testAPP in my BSP. In this test application their using like this

    SetFilePointer(hI2C, subaddr, NULL, FILE_BEGIN);

    So passed the subaddress as second argument, here subaddr is register address of device.

    Thursday, March 19, 2015 6:48 AM
  • It is possible that they are setting the pointer (seek) to subaddr.

    I mean "Number of bytes to move the data pointer in the device." Here, number of bytes = subaddr.

    Thursday, March 19, 2015 6:53 AM