Hi,
Please Let me know if any one know the procedure to toggle the GPIO on i.MX QSB board
Thanks in Advance
Shaik.
Please take a look at the following :
Hi Yuri Muhin,
Thanks for your reply,
The link which you have given is for Linux, i am working on WinEC7,if you have any information share or suggest me the way to do,
Board i am using is i.MX53 QSB,
OS : WinEC7
Thanks in advance,
Thanks & Regards,
Mujeeb Shaik.
You may try using the DDK lib ; corresponding Chapter [Chip Support Package Driver Development Kit (CSPDDK)] of
i.MX53 WinCE BSP Reference Manual provides information about the DDK_GPIO. The problem is, that DDK requests are not
intended to be called in user space, therefore it is needed to create special driver as some kind of "wrapper" for
user applications. Alas, we have no such example, it may be recommended to apply WinCE help support regarding WinCE
driver architecture.
Another approach : Please try to build CSPDDK the lib for both modes : user and kernel.
For this, in files platform.bib
(..\platform\<platform>...\FILES\platform.bib,
..\platform\<platform>...\cesysgen\FILES\platform.bib),
please set option Q instead of K :
;------------------------------------------------------------------------------
; CSPDDK Driver
;
IF BSP_NOCSPDDK !
cspddk.dll $(_FLATRELEASEDIR)\cspddk.dll NK SHQ
ENDIF BSP_NOCSPDDK !
; -----------------------------------------------------------------------------
After system re-building, in image directory (debug or release) both modules
will be presented : cspddk.dll - for user space and k.cspddk.dll - for kernel space.
So, functions in cspddk.dll may be used in user space.
(Strictly speaking, this is not fully safe solution, so be careful.)
Hi Yuri Muhin,
Thanks for your reply,
As you said,user dont have direct access to GPIO driver, we have one NLED (notification LED ) Driver through that we can access GPIOs,so what i am doing is i am accessing the NLED driver using the IOCTLs from application,IOCTL_NLED_SETDEVICE is one IOCTLS to set perticular LED,My plan is i will fill the NLED_SETIINGS_INFO structure with required data,i will pass that to driver, i will refer LED number in Driver level i will compare in driver that if LED Number is equals to 1 i will access one GPIO as per my requirement,if led number is equal to some X i will access some X GPIO,that is my plan but here problem is when i am passing the structure from application the address of the structure is corrupting some where so the values which i am passing from application same is not getting at Driver level,i have created an IOCTL to pass one single argument then i can process GPIO but the IOCTL which i created also getting fail.
please refer the code given below.
BOOL NLED_Init(void)
{
NLED_SETTINGS_INFO LED_Config;
NLED_COUNT_INFO Leds_info; //Number of NLEDs on Board
int GPIO_Test_Variable;
int Number_of_Bytes_Rtnd;
Leds_info.cLeds = 0;
LED_Config.LedNum = 0; // LED number, 0 is first LED
LED_Config.OffOnBlink = 2; // 0 == off, 1 == on, 2 == blink
LED_Config.TotalCycleTime = 10; // total cycle time of a blink in microseconds
LED_Config.OnTime = 5; // on time of a cycle in microseconds
LED_Config.OffTime = 5; // off time of a cycle in microseconds
LED_Config.MetaCycleOn = 3; // number of on blink cycles
LED_Config.MetaCycleOff = 3; // number of off blink cycles
printf("********************************************* \n");
printf("********************************************* \n");
printf("APP:NLED Launched... \n");
RETAILMSG(1,(TEXT("APP:NLED Launched... \r\n")));
NLED_Handle = CreateFile(L"NLD1:", // name of device L"I2C1:",
GENERIC_READ|GENERIC_WRITE, // desired access
FILE_SHARE_READ|FILE_SHARE_WRITE, // sharing mode
NULL, // security attributes (ignored)
OPEN_EXISTING, // creation disposition
NULL,//FILE_FLAG_RANDOM_ACCESS, // flags/attributes
NULL); // template file (ignored)
if (NLED_Handle == (HANDLE)-1)
{
printf("APP:Unable to open handle to NLED\r\n");
RETAILMSG(1,(TEXT("APP:Unable to open handle to NLED Error:%d \r\n"),GetLastError()));
return FALSE;
}
else
{
printf("APP:NLED Init Success...\r\n");
RETAILMSG(1,(TEXT("APP:NLED Init Success... \r\n")));
printf("\r\nAPP:NLED_Handle = %d\r\n",NLED_Handle);
RETAILMSG(1,(TEXT("\r\n APP:NLED_Handle = %d\r\n"),NLED_Handle));
}
if (!DeviceIoControl(NLED_Handle, // file handle to the driver
IOCTL_NLED_SETDEVICE, // I/O control code
&LED_Config, // in buffer
sizeof(LED_Config), // in buffer size
NULL, // out buffer
0, // out buffer size
NULL, // pointer to number of bytes returned
NULL)) // ignored (=NULL)
{
RETAILMSG(1,(TEXT("\r\n APP:IOCTL_NLED_SETDEVICE Fail...\r\n")));
return FALSE;
}
else
{
RETAILMSG(1,(TEXT("\r\n APP:IOCTL_NLED_SETDEVICE Success...\r\n")));
}
Thanks & Regards,
Mujeeb Shaik.
Hi, Mujeeb
you mean on linux kernel via user space interface, or just how to config the GPIO hardware register to achieve the toggling? If you meant from linux kernel, then I think there is such topic in imx community, you can search for that. If you mean for hardware register, I can give you a simple guide, take pin KEY_COL0 of iMX53 as example:
1. Set IOMUXC's MUX register to set pin to GPIO mode, then set its PAD config, or leaving its PAD config as reset value should be OK; For example, i.MX53 IOMUXC_SW_MUX_CTL_PAD_KEY_COL0, need to set register offset 0x24 of IOMUXC to 0x1, then this pin is selected as GPIO4_6.
2. Now this pin is GPIO4_6, you need to set this GPIO as output, in GPIO module, set GPIO4_GDIR bit 6 to 1 to enable it as output;
3. Now you can toggle this GPIO4_6 by setting the GPIO4_DR register bit 6, 0 means low, 1 means high.
Hi Yongcai Huang,
Thanks for your reply,
On my Target i have WinEC7, I would luke to Toggle the GPIO from Application level by calling related GPIO APIs,
I didnt found any API for GPIO,so i ahve NLED drievr which we can control from Appliaction,is there any other way to Access GPIO from Application level itself.
Thanks in advance
Thanks & Regards,
Mujeeb.
Hi Yongcai Huang,
Thanks for your reply,
On my Target i have WinEC7, I would luke to Toggle the GPIO from Application level by calling related GPIO APIs,
I didnt found any API for GPIO,so i ahve NLED drievr which we can control from Appliaction,is there any other way to Access GPIO from Application level itself.
Thanks in advance
Thanks & Regards,
Mujeeb.