none
How to access GPIO ports with the help of BSP in WinCE 6.0 RRS feed

  • Question

  • Hello everyone,

    I am working on a development board called "SBC6410" from Boardcon.

    here is the link :

    http://www.armdesigner.com/SBC6410.html

    I have installed Windows CE 6.0 on it. The manufacturers have provided a BSP with
    it. I wanted to ask that how can I access various peripharels of the board
    such as, GPIO ports, I2C bus SPI bus, ADC, etc. Can anyone suggest me any
    tutorial/sample codes/wabsites where I can find it ? I am developing
    applications in Visual C++.

    Thanks,
    Dhaval Mehta

    Wednesday, February 9, 2011 6:24 AM

All replies

  • Go through the link to learn windows ce 6.0.

    http://msdn.microsoft.com/en-US/windowsembedded/ce/dd367860

    http://msdn.microsoft.com/en-us/windowsembedded/ce/aa731296

    They have explained in detail of how to use your BSP, How to create your own project and build it etc..

    Then see the below blogs for creating the GPIO Driver, API set and application etc..

    http://geekswithblogs.net/BruceEitman/archive/2010/08/01/windows-ce-using-a-driver-to-readwrite-hardware-registers.aspx

    http://geekswithblogs.net/BruceEitman/archive/2010/08/01/windows-ce-developing-an-api-to-access-a-driver.aspx

    http://geekswithblogs.net/BruceEitman/archive/2010/08/01/windows-ce-writing-an-application-to-test-gpio-pins.aspx

    Also use this wizard for creating the stream driver easily

    http://cedriverwiz.codeplex.com/

     


    Vinoth.R http://vinoth-vinothblog.blogspot.com http://www.e-consystems.com
    Wednesday, February 9, 2011 6:50 AM
  • Thank you for your help.

    I have develped a driver using the tutorials.

    I wanted to ask that how can I return data to the application from the XXX_IOControl call?

    I have tried using the pBuffOut pointer, but when I try to access the lpBufOut variable of DeviceIoControl function in application, the following error occurs when I call the DeviceIoControl Function :

    " Exception Data Abort[4] "

     

    Here is my code for XXX_IOControl and application code:


    BOOL XXX_IOControl(DWORD hOpenContext, DWORD dwCode, PBYTE pBufIn, DWORD dwLenIn, PBYTE pBufOut, DWORD dwLenOut, PDWORD pdwActualOut)
    {

     OPEN_CONTEXT *pOpenContext = (OPEN_CONTEXT *)hOpenContext;
     DRIVERSHELL_CONTEXT *pDriverContext = pOpenContext->pHWContext;
     BOOL RetVal = TRUE;

     BYTE dat1 = 0x05; //Dummy data
     *pBufOut = dat1;   //Store data to out buffer

        RETAILMSG( 1, (TEXT("XXX_IOCTL\n")));

        return RetVal;
    }

     

    and here is the application code :

    {

    HANDLE hDS;

    LPVOID DatBuffOut;
     
          
     hDS = CreateFile( TEXT( "XXX1:"), GENERIC_READ|GENERIC_WRITE,  FILE_SHARE_READ|FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, 0 );


     if(hDS == INVALID_HANDLE_VALUE)
      {
       MessageBox(_T("XXX Initialized Failed"));
     }

    LPVOID inBuff;
    LPDWORD noOfBytes;
    PBYTE datbyte;

    DeviceIoControl(hDS,0x11000000,inBuff,0x00000001,DatBuffOut,0x00000001,noOfBytes,NULL);    

    datbyte = (BYTE*)DatBuffOut;

    RETAILMSG(1,(TEXT("datbuffout = %d"),*datbyte));
     
                    // CloseHandle will call XXX_Close
                    CloseHandle( hDS );
    }

    Tuesday, February 22, 2011 6:28 AM
  • You should allocate the buffer in the application and then pass it to the driver for filling.Currentlly you have just declared the pointer but did n't allocated any memory,which is why exception is occuring.
     
    Try the below code.
     
    UINT8 DatBuffOut;
    DWORD noOfBytes = 0;
     
    DeviceIoControl(hDS,0x11000000,inBuff,0x00000001,(LPVOID)&DatBuffOut,0x00000001,&noOfBytes,NULL);  
     
    RETAILMSG(1,(TEXT("datbuffout = %d"),DatBuffOut));


    --
    Regards,
    Prabu [eMVP]
    http://prabukumar.wordpress.com/
    www.e-consystems.com
    "mehtadhaval07" wrote in message news:29b2219d-7e03-4881-aac7-f00c39ab7dad...

    Thank you for your help.

    I have develped a driver using the tutorials.

    I wanted to ask that how can I return data to the application from the XXX_IOControl call?

    I have tried using the pBuffOut pointer, but when I try to access the lpBufOut variable of DeviceIoControl function in application, the following error occurs when I call the DeviceIoControl Function :

    " Exception Data Abort[4] "

     

    Here is my code for XXX_IOControl and application code:


    BOOL XXX_IOControl(DWORD hOpenContext, DWORD dwCode, PBYTE pBufIn, DWORD dwLenIn, PBYTE pBufOut, DWORD dwLenOut, PDWORD pdwActualOut)
    {

     OPEN_CONTEXT *pOpenContext = (OPEN_CONTEXT *)hOpenContext;
     DRIVERSHELL_CONTEXT *pDriverContext = pOpenContext->pHWContext;
     BOOL RetVal = TRUE;

     BYTE dat1 = 0x05; //Dummy data
     *pBufOut = dat1;   //Store data to out buffer

        RETAILMSG( 1, (TEXT("XXX_IOCTL\n")));

        return RetVal;
    }

     

    and here is the application code :

    {

    HANDLE hDS;

    LPVOID DatBuffOut;
     
          
     hDS = CreateFile( TEXT( "XXX1:"), GENERIC_READ|GENERIC_WRITE,  FILE_SHARE_READ|FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, 0 );


     if(hDS == INVALID_HANDLE_VALUE)
      {
       MessageBox(_T("XXX Initialized Failed"));
     }

    LPVOID inBuff;
    LPDWORD noOfBytes;
    PBYTE datbyte;

    DeviceIoControl(hDS,0x11000000,inBuff,0x00000001,DatBuffOut,0x00000001,noOfBytes,NULL);    

    datbyte = (BYTE*)DatBuffOut;

    RETAILMSG(1,(TEXT("datbuffout = %d"),*datbyte));
     
                    // CloseHandle will call XXX_Close
                    CloseHandle( hDS );
    }

    • Proposed as answer by Vinoth[MCTS] Tuesday, February 22, 2011 7:01 AM
    Tuesday, February 22, 2011 6:44 AM
  • The problem with your code, is that there is no buffer to store your datas !

    this code will work:

    HANDLE hDS;
    BYTE DatBuffOut[2];
    DWORD noOfBytes;
     
    hDS = CreateFile( TEXT( "XXX1:"), GENERIC_READ|GENERIC_WRITE, FILE_SHARE_READ|FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, 0 );
    
    if(hDS == INVALID_HANDLE_VALUE)
    {
      MessageBox(_T("XXX Initialized Failed"));
    }
    else
    {
     DeviceIoControl(hDS,0x11000000, NULL, 0, DatBuffOut, 2, &noOfBytes, NULL);
     RETAILMSG(1,(TEXT("datbuffout = %d"), DatBuffOut[0]));
     
      // CloseHandle will call XXX_Close
      CloseHandle( hDS );
    }

    I think, you have any things to learn about C/C++ programming !

    Regards

    Fabrice

    Tuesday, February 22, 2011 6:51 AM