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.

I/O Interface API

Hello

I have a sample code for programming GPIO in Devkit8000. Anyway, I have a question.

How can I find some information about "DeviceType" and "Function" in "CTL_CODE" specially for my board "Devkit8000"?

for example this line of code:

 >> FILE_DEVICE_UNKNOWN 0x00000022

how can i know that "FILE_DEVICE_UNKNOWN" is the hex number "0x00000022" ?

best regards...

  • Hi,

    Could you specify which software you are using?

    The CTL_CODE macro has the following definition in the .../linux/drivers/scsi/aacraid/aacraid.h header file from TI DVSDK linux:

    /*
     *    Ugly - non Linux like ioctl coding for back compat.
     */

    #define CTL_CODE(function, method) (                 \
        (4<< 16) | ((function) << 2) | (method) \
    )

    In the same file you can find some definitions for specific methods and functions.

    About the FILE_DEVIE_UNKNOWN macro it should be defined in your code as 0x00000022 but this value is unacceptable if you are using the definition above because the return value of CTL_CODE is result of (4<<16) or some other numbers depending on parameters function and method. Therefore the returned value by CTL_CODE should be greater of equal to 0x00040000.

    BR

    Tsvetolin Shulev

  • thank you for reply...

    I'm using Microsoft Visual Studio (both C++ / C#) for app development in WinCE 6.0.

    #ifndef CTL_CODE

    #define CTL_CODE( DeviceType, Function, Method, Access ) ( \

    ((DeviceType) << 16) | ((Access) << 14) | ((Function) << 2) | (Method) \
    )
    #endif

    #define IOCTL_GPIO_SETBIT  \
    CTL_CODE(FILE_DEVICE_UNKNOWN, 0x0300, METHOD_BUFFERED, FILE_ANY_ACCESS)


    Now, my questions is:

    • What's the meaning of function "0x0300" in above code?  
    • It's SET the GPIO:bit TRUE, But how?
    • Is it same in any kit, even my custom board?

    Best regards...

  • The description of the CTL_CODE macro for Win CE is available on the link below:

    http://msdn.microsoft.com/en-us/library/ms904001.aspx

    The second parameter - Function (0x0300 in your case) defines an action within the device category. Function codes 0-2047 are reserved for Microsoft; codes 2048-4095 are reserved for OEMs and IHVs. A function code can be no larger then 4095.

    For more details about what is the meaning of function value 0x0300 you can ask on WinCE E2E forum or on the Microsoft's web site.

    BR

    Tsvetolin Shulev